Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/FrameCount/framecnt001a.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.FrameCount;
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 framecnt001a {
36
37
// name for the tested thread
38
public static final String THREAD_NAME = "TestedThreadName";
39
public static final String FIELD_NAME = "thread";
40
41
// frames count for tested thread in recursive method invokation
42
public static final int FRAMES_COUNT = 10;
43
44
// notification object to notify debuggee that thread is ready
45
private static Object threadReady = new Object();
46
// lock object to prevent thread from exit
47
private static Object threadLock = new Object();
48
49
// scaffold objects
50
private static volatile ArgumentHandler argumentHandler = null;
51
private static volatile Log log = null;
52
53
public static void main(String args[]) {
54
framecnt001a _framecnt001a = new framecnt001a();
55
System.exit(framecnt001.JCK_STATUS_BASE + _framecnt001a.runIt(args, System.err));
56
}
57
58
public int runIt(String args[], PrintStream out) {
59
//make log for debugee messages
60
argumentHandler = new ArgumentHandler(args);
61
log = new Log(out, argumentHandler);
62
63
// make communication pipe to debugger
64
log.display("Creating pipe");
65
IOPipe pipe = argumentHandler.createDebugeeIOPipe(log);
66
67
// lock the object to prevent thread from exit
68
synchronized (threadLock) {
69
70
// load tested class and create tested thread
71
log.display("Creating object of tested class");
72
TestedClass.thread = new TestedClass(THREAD_NAME);
73
74
// start the thread and wait for notification from it
75
synchronized (threadReady) {
76
TestedClass.thread.start();
77
try {
78
threadReady.wait();
79
// send debugger signal READY
80
log.display("Sending signal to debugger: " + framecnt001.READY);
81
pipe.println(framecnt001.READY);
82
} catch (InterruptedException e) {
83
log.complain("Interruption while waiting for thread started: " + e);
84
pipe.println(framecnt001.ERROR);
85
}
86
}
87
88
// wait for signal QUIT from debugeer
89
log.display("Waiting for signal from debugger: " + framecnt001.QUIT);
90
String signal = pipe.readln();
91
log.display("Received signal from debugger: " + signal);
92
93
// check received signal
94
if (signal == null || !signal.equals(framecnt001.QUIT)) {
95
log.complain("Unexpected communication signal from debugee: " + signal
96
+ " (expected: " + framecnt001.QUIT + ")");
97
log.display("Debugee FAILED");
98
return framecnt001.FAILED;
99
}
100
101
// allow started thread to exit
102
}
103
104
// exit debugee
105
log.display("Debugee PASSED");
106
return framecnt001.PASSED;
107
}
108
109
// tested thread class
110
public static class TestedClass extends Thread {
111
112
// field with the tested Thread value
113
public static volatile TestedClass thread = null;
114
115
int frames = 0;
116
117
TestedClass(String name) {
118
super(name);
119
}
120
121
// start the thread and recursive invoke makeFrames()
122
public void run() {
123
log.display("Tested thread started");
124
125
// make remaining frames already having one
126
frames = 1;
127
makeFrames(FRAMES_COUNT - frames);
128
}
129
130
// recursive make thread frames and notify debuggee
131
public void makeFrames(int count) {
132
frames++;
133
count--;
134
int local = frames + count;
135
if (count > 0) {
136
makeFrames(count);
137
} else {
138
log.display("Thread frames made: " + frames);
139
140
// notify debuggee that thread ready for testing
141
synchronized (threadReady) {
142
threadReady.notifyAll();
143
}
144
145
// wait for lock object released
146
synchronized (threadLock) {
147
log.display("Tested thread finished");
148
}
149
}
150
}
151
152
}
153
154
}
155
156