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