Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/StackFrame/GetValues/getvalues001a.java
41162 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.StackFrame.GetValues;
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 getvalues001a {
36
37
// name of the tested object and thread classes
38
public static final String OBJECT_CLASS_NAME = "TestedObjectClass";
39
public static final String THREAD_CLASS_NAME = "TestedThreadClass";
40
public static final String THREAD_NAME = "TestedThreadName";
41
42
// name of the static fields with the tested object values
43
public static final String THREAD_FIELD_NAME = "thread";
44
public static final String OBJECT_FIELD_NAME = "object";
45
public static final String OBJECT_METHOD_NAME = "testedMethod";
46
47
// notification object to notify debuggee that thread is ready
48
private static Object threadReady = new Object();
49
// lock object to prevent thread from exit
50
private static Object threadLock = new Object();
51
52
// scaffold objects
53
private static volatile ArgumentHandler argumentHandler = null;
54
private static volatile Log log = null;
55
56
public static void main(String args[]) {
57
getvalues001a _getvalues001a = new getvalues001a();
58
System.exit(getvalues001.JCK_STATUS_BASE + _getvalues001a.runIt(args, System.err));
59
}
60
61
public int runIt(String args[], PrintStream out) {
62
//make log for debugee messages
63
argumentHandler = new ArgumentHandler(args);
64
log = new Log(out, argumentHandler);
65
66
// make communication pipe to debugger
67
log.display("Creating pipe");
68
IOPipe pipe = argumentHandler.createDebugeeIOPipe(log);
69
70
// lock the object to prevent thread from exit
71
synchronized (threadLock) {
72
73
// load tested class and create tested thread and object
74
log.display("Creating object of tested class");
75
TestedObjectClass.object = new TestedObjectClass();
76
log.display("Creating tested thread");
77
TestedObjectClass.thread = new TestedThreadClass(THREAD_NAME);
78
79
// start the thread and wait for notification from it
80
synchronized (threadReady) {
81
TestedObjectClass.thread.start();
82
try {
83
threadReady.wait();
84
// send debugger signal READY
85
log.display("Sending signal to debugger: " + getvalues001.READY);
86
pipe.println(getvalues001.READY);
87
} catch (InterruptedException e) {
88
log.complain("Interruption while waiting for thread started: " + e);
89
pipe.println(getvalues001.ERROR);
90
}
91
}
92
93
// wait for signal QUIT from debugeer
94
log.display("Waiting for signal from debugger: " + getvalues001.QUIT);
95
String signal = pipe.readln();
96
log.display("Received signal from debugger: " + signal);
97
98
// check received signal
99
if (signal == null || !signal.equals(getvalues001.QUIT)) {
100
log.complain("Unexpected communication signal from debugee: " + signal
101
+ " (expected: " + getvalues001.QUIT + ")");
102
log.complain("Debugee FAILED");
103
return getvalues001.FAILED;
104
}
105
106
// allow started thread to finish
107
}
108
109
// wait for tested thread finished
110
try {
111
log.display("Waiting for tested thread finished");
112
TestedObjectClass.thread.join();
113
} catch (InterruptedException e) {
114
log.complain("Interruption while waiting for tested thread finished:\n\t"
115
+ e);
116
log.complain("Debugee FAILED");
117
return getvalues001.FAILED;
118
}
119
120
// exit debugee
121
log.display("Debugee PASSED");
122
return getvalues001.PASSED;
123
}
124
125
// tested thread class
126
public static class TestedThreadClass extends Thread {
127
128
TestedThreadClass(String name) {
129
super(name);
130
}
131
132
public void run() {
133
log.display("Tested thread started");
134
135
// invoke tested method for the tested object from the tested thread
136
TestedObjectClass.object.testedMethod();
137
138
log.display("Tested thread finished");
139
}
140
141
}
142
143
// tested object class
144
public static class TestedObjectClass {
145
146
// field with the tested thread and object values
147
public static volatile TestedThreadClass thread = null;
148
public static volatile TestedObjectClass object = null;
149
150
public void testedMethod() {
151
// local variables
152
boolean booleanValue = true;
153
byte byteValue = (byte)0x0F;
154
char charValue = 'Z';
155
int intValue = 100;
156
short shortValue = (short)10;
157
long longValue = (long)1000000;
158
float floatValue = (float)3.14;
159
double doubleValue = (double)2.8e-12;
160
Object objectValue = null;
161
162
log.display("Tested frame entered");
163
164
// notify debuggee that tested thread ready for testing
165
synchronized (threadReady) {
166
threadReady.notifyAll();
167
}
168
169
// wait for lock object released
170
synchronized (threadLock) {
171
log.display("Tested frame dropped");
172
}
173
}
174
175
}
176
177
}
178
179