Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Locatable/location/location001.java
41171 views
1
/*
2
* Copyright (c) 2001, 2019, 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.jdi.Locatable.location;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
import com.sun.jdi.*;
31
import java.util.*;
32
import java.io.*;
33
34
/**
35
* The test for the implementation of an object of the type <BR>
36
* Locatable. <BR>
37
* <BR>
38
* The test checks up that results of the method <BR>
39
* <code>com.sun.jdi.Locatable.location()</code> <BR>
40
* complies with its spec when a tested method <BR>
41
* is one of PrimitiveTypes, void or native. <BR>
42
* <BR>
43
* The cases for testing are as follows. <BR>
44
* <BR>
45
* When a gebuggee creates an object of <BR>
46
* the following class type: <BR>
47
* class TestClass { <BR>
48
* public static boolean bl () { return false; } <BR>
49
* public static byte bt () { return 0; } <BR>
50
* private static char ch () { return 0; } <BR>
51
* protected static double db () { return 0.0d; } <BR>
52
* public float fl () { return 0.0f; } <BR>
53
* public int in () { return 0; } <BR>
54
* private long ln () { return 0; } <BR>
55
* protected short sh () { return 0; } <BR>
56
* public void vd () { return ; } <BR>
57
* } <BR>
58
* a debugger checks up that for all of the above methods, <BR>
59
* the invocation of the method Locatable.location() <BR>
60
* returns non-null values. <BR>
61
* <BR>
62
*/
63
64
public class location001 {
65
66
//----------------------------------------------------- templete section
67
static final int PASSED = 0;
68
static final int FAILED = 2;
69
static final int PASS_BASE = 95;
70
71
//----------------------------------------------------- templete parameters
72
static final String
73
sHeader1 = "\n==> nsk/jdi/Locatable/location/location001 ",
74
sHeader2 = "--> location001: ",
75
sHeader3 = "##> location001: ";
76
77
//----------------------------------------------------- main method
78
79
public static void main (String argv[]) {
80
int result = run(argv, System.out);
81
System.exit(result + PASS_BASE);
82
}
83
84
public static int run (String argv[], PrintStream out) {
85
return new location001().runThis(argv, out);
86
}
87
88
//-------------------------------------------------- log procedures
89
90
//private static boolean verbMode = false;
91
92
private static Log logHandler;
93
94
private static void log1(String message) {
95
logHandler.display(sHeader1 + message);
96
}
97
private static void log2(String message) {
98
logHandler.display(sHeader2 + message);
99
}
100
private static void log3(String message) {
101
logHandler.complain(sHeader3 + message);
102
}
103
104
// ************************************************ test parameters
105
106
private String debuggeeName =
107
"nsk.jdi.Locatable.location.location001a";
108
109
String mName = "nsk.jdi.Locatable.location";
110
111
//====================================================== test program
112
113
static ArgumentHandler argsHandler;
114
static int testExitCode = PASSED;
115
116
//------------------------------------------------------ common section
117
118
private int runThis (String argv[], PrintStream out) {
119
120
Debugee debuggee;
121
122
argsHandler = new ArgumentHandler(argv);
123
logHandler = new Log(out, argsHandler);
124
Binder binder = new Binder(argsHandler, logHandler);
125
126
127
if (argsHandler.verbose()) {
128
debuggee = binder.bindToDebugee(debuggeeName + " -vbs"); // *** tp
129
} else {
130
debuggee = binder.bindToDebugee(debuggeeName); // *** tp
131
}
132
133
IOPipe pipe = new IOPipe(debuggee);
134
135
debuggee.redirectStderr(out);
136
log2(debuggeeName + " debuggee launched");
137
debuggee.resume();
138
139
String line = pipe.readln();
140
if ((line == null) || !line.equals("ready")) {
141
log3("signal received is not 'ready' but: " + line);
142
return FAILED;
143
} else {
144
log2("'ready' recieved");
145
}
146
147
VirtualMachine vm = debuggee.VM();
148
149
//------------------------------------------------------ testing section
150
log1(" TESTING BEGINS");
151
152
for (int i = 0; ; i++) {
153
pipe.println("newcheck");
154
line = pipe.readln();
155
156
if (line.equals("checkend")) {
157
log2(" : returned string is 'checkend'");
158
break ;
159
} else if (!line.equals("checkready")) {
160
log3("ERROR: returned string is not 'checkready'");
161
testExitCode = FAILED;
162
break ;
163
}
164
165
log1("new check: #" + i);
166
167
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
168
169
List listOfDebuggeeClasses = vm.classesByName(mName + ".location001aTestClass");
170
if (listOfDebuggeeClasses.size() != 1) {
171
testExitCode = FAILED;
172
log3("ERROR: listOfDebuggeeClasses.size() != 1");
173
break ;
174
}
175
176
List methods = null;
177
Method m = null;
178
Location mLocation = null;
179
180
String bl = "bl";
181
String bt = "bt";
182
String ch = "ch";
183
String db = "db";
184
String fl = "fl";
185
String in = "in";
186
String ln = "ln";
187
String sh = "sh";
188
String vd = "vd";
189
190
int i2;
191
192
for (i2 = 0; ; i2++) {
193
194
int expresult = 0;
195
196
log2("new check: #" + i2);
197
198
switch (i2) {
199
200
case 0: // boolean method
201
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
202
methodsByName(bl);
203
m = (Method) methods.get(0);
204
mLocation = m.location();
205
206
if (mLocation == null) {
207
log3("ERROR: mLocation == null for a boolean method");
208
expresult = 1;
209
break;
210
}
211
break;
212
213
case 1: // byte method
214
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
215
methodsByName(bt);
216
m = (Method) methods.get(0);
217
mLocation = m.location();
218
219
if (mLocation == null) {
220
log3("ERROR: mLocation == null for a byte method");
221
expresult = 1;
222
break;
223
}
224
break;
225
226
case 2: // char method
227
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
228
methodsByName(ch);
229
m = (Method) methods.get(0);
230
mLocation = m.location();
231
232
if (mLocation == null) {
233
log3("ERROR: mLocation == null for a char method");
234
expresult = 1;
235
break;
236
}
237
break;
238
239
case 3: // double method
240
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
241
methodsByName(db);
242
m = (Method) methods.get(0);
243
mLocation = m.location();
244
245
if (mLocation == null) {
246
log3("ERROR: mLocation == null for a double method");
247
expresult = 1;
248
break;
249
}
250
break;
251
252
case 4: // float method
253
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
254
methodsByName(fl);
255
m = (Method) methods.get(0);
256
mLocation = m.location();
257
258
if (mLocation == null) {
259
log3("ERROR: mLocation == null for a float method");
260
expresult = 1;
261
break;
262
}
263
break;
264
265
case 5: // int method
266
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
267
methodsByName(in);
268
m = (Method) methods.get(0);
269
mLocation = m.location();
270
271
if (mLocation == null) {
272
log3("ERROR: mLocation == null for an int method");
273
expresult = 1;
274
break;
275
}
276
break;
277
278
case 6: // long method
279
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
280
methodsByName(ln);
281
m = (Method) methods.get(0);
282
mLocation = m.location();
283
284
if (mLocation == null) {
285
log3("ERROR: mLocation == null for a long method");
286
expresult = 1;
287
break;
288
}
289
break;
290
291
case 7: // short method
292
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
293
methodsByName(sh);
294
m = (Method) methods.get(0);
295
mLocation = m.location();
296
297
if (mLocation == null) {
298
log3("ERROR: mLocation == null for a short method");
299
expresult = 1;
300
break;
301
}
302
break;
303
304
case 8: // void method
305
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
306
methodsByName(vd);
307
m = (Method) methods.get(0);
308
mLocation = m.location();
309
310
if (mLocation == null) {
311
log3("ERROR: mLocation == null for a void method");
312
expresult = 1;
313
break;
314
}
315
break;
316
317
318
default: expresult = 2;
319
break ;
320
}
321
322
if (expresult == 2) {
323
log2(" test cases finished");
324
break ;
325
} else if (expresult == 1) {
326
log3("ERROR: expresult != true; check # = " + i);
327
testExitCode = FAILED;
328
}
329
}
330
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
331
}
332
log1(" TESTING ENDS");
333
334
//-------------------------------------------------- test summary section
335
//------------------------------------------------- standard end section
336
337
pipe.println("quit");
338
log2("waiting for the debuggee to finish ...");
339
debuggee.waitFor();
340
341
int status = debuggee.getStatus();
342
if (status != PASSED + PASS_BASE) {
343
log3("debuggee returned UNEXPECTED exit status: " +
344
status + " != PASS_BASE");
345
testExitCode = FAILED;
346
} else {
347
log2("debuggee returned expected exit status: " +
348
status + " == PASS_BASE");
349
}
350
351
if (testExitCode != PASSED) {
352
logHandler.complain("TEST FAILED");
353
}
354
return testExitCode;
355
}
356
}
357
358