Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/Frames/frames001a.java
41161 views
1
/*
2
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
package nsk.jdwp.ThreadReference.Frames;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdwp.*;
29
30
import java.io.*;
31
32
/**
33
* This class represents debuggee part in the test.
34
*/
35
public class frames001a {
36
37
// name for the tested thread
38
public static final String THREAD_NAME = "TestedThreadName";
39
public static final String FIELD_NAME = "thread";
40
public static final String METHOD_NAME = "makeFrames";
41
42
// frames count for tested thread in recursive method invokation
43
public static final int FRAMES_COUNT = 10;
44
45
// notification object to notify debuggee that thread is ready
46
private static Object threadReady = new Object();
47
// lock object to prevent thread from exit
48
private static Object threadLock = new Object();
49
50
// scaffold objects
51
private static volatile ArgumentHandler argumentHandler = null;
52
private static volatile Log log = null;
53
54
public static void main(String args[]) {
55
frames001a _frames001a = new frames001a();
56
System.exit(frames001.JCK_STATUS_BASE + _frames001a.runIt(args, System.err));
57
}
58
59
public int runIt(String args[], PrintStream out) {
60
//make log for debugee messages
61
argumentHandler = new ArgumentHandler(args);
62
log = new Log(out, argumentHandler);
63
64
// make communication pipe to debugger
65
log.display("Creating pipe");
66
IOPipe pipe = argumentHandler.createDebugeeIOPipe(log);
67
68
// lock the object to prevent thread from exit
69
synchronized (threadLock) {
70
71
// load tested class and create tested thread
72
log.display("Creating object of tested class");
73
TestedClass.thread = new TestedClass(THREAD_NAME);
74
75
// start the thread and wait for notification from it
76
synchronized (threadReady) {
77
TestedClass.thread.start();
78
try {
79
threadReady.wait();
80
// send debugger signal READY
81
log.display("Sending signal to debugger: " + frames001.READY);
82
pipe.println(frames001.READY);
83
} catch (InterruptedException e) {
84
log.complain("Interruption while waiting for thread started: " + e);
85
pipe.println(frames001.ERROR);
86
}
87
}
88
89
// wait for signal QUIT from debugeer
90
log.display("Waiting for signal from debugger: " + frames001.QUIT);
91
String signal = pipe.readln();
92
log.display("Received signal from debugger: " + signal);
93
94
// check received signal
95
if (signal == null || !signal.equals(frames001.QUIT)) {
96
log.complain("Unexpected communication signal from debugee: " + signal
97
+ " (expected: " + frames001.QUIT + ")");
98
log.display("Debugee FAILED");
99
return frames001.FAILED;
100
}
101
102
// allow started thread to exit
103
}
104
105
// exit debugee
106
log.display("Debugee PASSED");
107
return frames001.PASSED;
108
}
109
110
// tested thread class
111
public static class TestedClass extends Thread {
112
113
// field with the tested Thread value
114
public static volatile TestedClass thread = null;
115
116
int frames = 0;
117
118
TestedClass(String name) {
119
super(name);
120
}
121
122
// start the thread and recursive invoke makeFrames()
123
public void run() {
124
log.display("Tested thread started");
125
126
// make remaining frames already having one
127
frames = 1;
128
makeFrames(FRAMES_COUNT - frames);
129
130
}
131
132
// recursive make thread frames and notify debuggee
133
public void makeFrames(int count) {
134
frames++;
135
count--;
136
int local = frames + count;
137
if (count > 0) {
138
makeFrames(count);
139
} else {
140
log.display("Thread frames made: " + frames);
141
142
// notify debuggee that thread ready for testing
143
synchronized (threadReady) {
144
threadReady.notifyAll();
145
}
146
147
// wait for lock object released
148
synchronized (threadLock) {
149
log.display("Tested thread finished");
150
}
151
152
}
153
}
154
155
}
156
157
}
158
159