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