Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/LocalVariable/name/name001.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.jdi.LocalVariable.name;
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
* LocalVariable. <BR>
37
* <BR>
38
* The test checks up that results of the method <BR>
39
* <code>com.sun.jdi.LocalVariable.name()</code> <BR>
40
* complies with its spec. <BR>
41
* <BR>
42
* The cases for testing are as follows. <BR>
43
* <BR>
44
* When a gebuggee creates an object containing <BR>
45
* the following method: <BR>
46
* public void testmethod (int param) { <BR>
47
* boolean bl1 = false, bl2 = true; <BR>
48
* byte bt1 = 0, bt2 = 1; <BR>
49
* char ch1 = 0, ch2 = 1; <BR>
50
* double db1 = 0.0d, db2 = 1.0d; <BR>
51
* float fl1 = 0.0f, fl2 = 1.0f; <BR>
52
* int in1 = 0, in2 = 1; <BR>
53
* long ln1 = 0, ln2 = 1; <BR>
54
* short sh1 = 0, sh2 = 1; <BR>
55
* ClassForCheck_2 class2 = new ClassForCheck_2(); <BR>
56
* InterfaceForCheck iface = class2; <BR>
57
* ClassForCheck cfc[] = { new ClassForCheck(), <BR>
58
* new ClassForCheck() }; <BR>
59
* return; <BR>
60
* } <BR>
61
* a debugger checks up that the method <BR>
62
* LocalVariable.name() applied to each of <BR>
63
* method variable returns its name. <BR>
64
* <BR>
65
*/
66
67
public class name001 {
68
69
//----------------------------------------------------- templete section
70
static final int PASSED = 0;
71
static final int FAILED = 2;
72
static final int PASS_BASE = 95;
73
74
//----------------------------------------------------- templete parameters
75
static final String
76
sHeader1 = "\n==> nsk/jdi/LocalVariable/name/name001 ",
77
sHeader2 = "--> name001: ",
78
sHeader3 = "##> name001: ";
79
80
//----------------------------------------------------- main method
81
82
public static void main (String argv[]) {
83
int result = run(argv, System.out);
84
System.exit(result + PASS_BASE);
85
}
86
87
public static int run (String argv[], PrintStream out) {
88
return new name001().runThis(argv, out);
89
}
90
91
//-------------------------------------------------- log procedures
92
93
//private static boolean verbMode = false;
94
95
private static Log logHandler;
96
97
private static void log1(String message) {
98
logHandler.display(sHeader1 + message);
99
}
100
private static void log2(String message) {
101
logHandler.display(sHeader2 + message);
102
}
103
private static void log3(String message) {
104
logHandler.complain(sHeader3 + message);
105
}
106
107
// ************************************************ test parameters
108
109
private String debuggeeName =
110
"nsk.jdi.LocalVariable.name.name001a";
111
112
String mName = "nsk.jdi.LocalVariable.name";
113
114
//====================================================== test program
115
116
static ArgumentHandler argsHandler;
117
static int testExitCode = PASSED;
118
119
//------------------------------------------------------ common section
120
121
private int runThis (String argv[], PrintStream out) {
122
123
Debugee debuggee;
124
125
argsHandler = new ArgumentHandler(argv);
126
logHandler = new Log(out, argsHandler);
127
Binder binder = new Binder(argsHandler, logHandler);
128
129
if (argsHandler.verbose()) {
130
debuggee = binder.bindToDebugee(debuggeeName + " -vbs"); // *** tp
131
} else {
132
debuggee = binder.bindToDebugee(debuggeeName); // *** tp
133
}
134
135
IOPipe pipe = new IOPipe(debuggee);
136
137
debuggee.redirectStderr(out);
138
log2("name001a debuggee launched");
139
debuggee.resume();
140
141
String line = pipe.readln();
142
if ((line == null) || !line.equals("ready")) {
143
log3("signal received is not 'ready' but: " + line);
144
return FAILED;
145
} else {
146
log2("'ready' recieved");
147
}
148
149
VirtualMachine vm = debuggee.VM();
150
151
//------------------------------------------------------ testing section
152
log1(" TESTING BEGINS");
153
154
for (int i = 0; ; i++) {
155
pipe.println("newcheck");
156
line = pipe.readln();
157
158
if (line.equals("checkend")) {
159
log2(" : returned string is 'checkend'");
160
break ;
161
} else if (!line.equals("checkready")) {
162
log3("ERROR: returned string is not 'checkready'");
163
testExitCode = FAILED;
164
break ;
165
}
166
167
log1("new check: #" + i);
168
169
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
170
171
List listOfLoadedClasses = vm.classesByName(mName + ".TestClass");
172
173
if (listOfLoadedClasses.size() != 1) {
174
testExitCode = FAILED;
175
log3("ERROR: listOfLoadedClasses.size() != 1 " +
176
listOfLoadedClasses.size());
177
break ;
178
}
179
180
List methods =
181
((ReferenceType) listOfLoadedClasses.get(0)).
182
methodsByName("testmethod");
183
184
Method testMethod = (Method) methods.get(0);
185
186
187
String names[] = { "bl1", "bt1", "ch1", "db1",
188
"fl1", "in1", "ln1", "sh1",
189
"class2", "iface", "cfc" };
190
191
int i2;
192
int expresult = 0;
193
194
for (i2 = 0; i2 < names.length; i2++) {
195
196
log2("new check: #" + i2);
197
198
List lVars = null;
199
try {
200
lVars = testMethod.variablesByName(names[i2]);
201
} catch ( AbsentInformationException e ) {
202
log3("ERROR: AbsentInformationException for " +
203
"lVars = testMethod.variablesByName(names[i2])" );
204
testExitCode = FAILED;
205
continue;
206
}
207
if (lVars.size() != 1) {
208
testExitCode = FAILED;
209
log3("ERROR: lVars.size() != 1 for i2=" + i2 + " : " + lVars.size());
210
continue;
211
}
212
213
LocalVariable lVar = (LocalVariable) lVars.get(0);
214
215
String lVarName = lVar.name();
216
217
switch (i2) {
218
219
case 0: // BooleanType
220
if (!lVarName.equals("bl1")) {
221
testExitCode = FAILED;
222
log3("ERROR: !lVarName.equals('bl1')");
223
}
224
225
break;
226
227
case 1: // ByteType
228
229
if (!lVarName.equals("bt1")) {
230
testExitCode = FAILED;
231
log3("ERROR: !lVarName.equals('bt1')");
232
}
233
break;
234
235
case 2: // CharType
236
if (!lVarName.equals("ch1")) {
237
testExitCode = FAILED;
238
log3("ERROR: !lVarName.equals('ch1')");
239
}
240
break;
241
242
case 3: // DoubleType
243
if (!lVarName.equals("db1")) {
244
testExitCode = FAILED;
245
log3("ERROR: !lVarName.equals('db1')");
246
}
247
break;
248
249
case 4: // FloatType
250
if (!lVarName.equals("fl1")) {
251
testExitCode = FAILED;
252
log3("ERROR: !lVarName.equals('fl1')");
253
}
254
break;
255
256
case 5: // IntegerType
257
if (!lVarName.equals("in1")) {
258
testExitCode = FAILED;
259
log3("ERROR: !lVarName.equals('in1')");
260
}
261
break;
262
263
case 6: // LongType
264
if (!lVarName.equals("ln1")) {
265
testExitCode = FAILED;
266
log3("ERROR: !lVarName.equals('ln1')");
267
}
268
break;
269
270
case 7: // ShortType
271
if (!lVarName.equals("sh1")) {
272
testExitCode = FAILED;
273
log3("ERROR: !lVarName.equals('sh1')");
274
}
275
break;
276
277
278
case 8: // ClassType
279
if (!lVarName.equals("class2")) {
280
testExitCode = FAILED;
281
log3("ERROR: !lVarName.equals('class2')");
282
}
283
break;
284
285
case 9: // InterfaceType
286
if (!lVarName.equals("iface")) {
287
testExitCode = FAILED;
288
log3("ERROR: !lVarName.equals('iface')");
289
}
290
break;
291
292
case 10: // ArrayType
293
if (!lVarName.equals("cfc")) {
294
testExitCode = FAILED;
295
log3("ERROR: !lVarName.equals('cfc')");
296
}
297
break;
298
299
300
default: expresult = 2;
301
break ;
302
}
303
304
if (expresult == 2) {
305
log2(" test cases finished");
306
break ;
307
}
308
}
309
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310
}
311
log1(" TESTING ENDS");
312
313
//-------------------------------------------------- test summary section
314
//------------------------------------------------- standard end section
315
316
pipe.println("quit");
317
log2("waiting for the debuggee to finish ...");
318
debuggee.waitFor();
319
320
int status = debuggee.getStatus();
321
if (status != PASSED + PASS_BASE) {
322
log3("debuggee returned UNEXPECTED exit status: " +
323
status + " != PASS_BASE");
324
testExitCode = FAILED;
325
} else {
326
log2("debuggee returned expected exit status: " +
327
status + " == PASS_BASE");
328
}
329
330
if (testExitCode != PASSED) {
331
logHandler.complain("TEST FAILED");
332
}
333
return testExitCode;
334
}
335
}
336
337