Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Field/isVolatile/isvol001.java
41160 views
1
/*
2
* Copyright (c) 2000, 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
25
package nsk.jdi.Field.isVolatile;
26
27
import nsk.share.*;
28
import nsk.share.jpda.*;
29
import nsk.share.jdi.*;
30
31
import com.sun.jdi.*;
32
import java.util.*;
33
import java.io.*;
34
35
public class isvol001 {
36
final static String IS_VOL = "volatile";
37
final static String NOT_VOL = "";
38
final static int TOTAL_FIELDS = 207;
39
final static String FIELDS_TYPE_NAME[][] = {
40
{"z0", NOT_VOL},
41
{"z1", NOT_VOL},
42
{"z2", NOT_VOL},
43
{"b0", NOT_VOL},
44
{"b1", NOT_VOL},
45
{"b2", NOT_VOL},
46
{"c0", NOT_VOL},
47
{"c1", NOT_VOL},
48
{"c2", NOT_VOL},
49
{"d0", NOT_VOL},
50
{"d1", NOT_VOL},
51
{"d2", NOT_VOL},
52
{"f0", NOT_VOL},
53
{"f1", NOT_VOL},
54
{"f2", NOT_VOL},
55
{"i0", NOT_VOL},
56
{"i1", NOT_VOL},
57
{"i2", NOT_VOL},
58
{"l0", NOT_VOL},
59
{"l1", NOT_VOL},
60
{"l2", NOT_VOL},
61
62
{"z0V", IS_VOL},
63
{"z1V", IS_VOL},
64
{"z2V", IS_VOL},
65
{"b0V", IS_VOL},
66
{"b1V", IS_VOL},
67
{"b2V", IS_VOL},
68
{"c0V", IS_VOL},
69
{"c1V", IS_VOL},
70
{"c2V", IS_VOL},
71
{"d0V", IS_VOL},
72
{"d1V", IS_VOL},
73
{"d2V", IS_VOL},
74
{"f0V", IS_VOL},
75
{"f1V", IS_VOL},
76
{"f2V", IS_VOL},
77
{"i0V", IS_VOL},
78
{"i1V", IS_VOL},
79
{"i2V", IS_VOL},
80
{"l0V", IS_VOL},
81
{"l1V", IS_VOL},
82
{"l2V", IS_VOL},
83
84
{"lS0", NOT_VOL},
85
{"lS1", NOT_VOL},
86
{"lS2", NOT_VOL},
87
{"lP0", NOT_VOL},
88
{"lP1", NOT_VOL},
89
{"lP2", NOT_VOL},
90
{"lU0", NOT_VOL},
91
{"lU1", NOT_VOL},
92
{"lU2", NOT_VOL},
93
{"lR0", NOT_VOL},
94
{"lR1", NOT_VOL},
95
{"lR2", NOT_VOL},
96
{"lT0", NOT_VOL},
97
{"lT1", NOT_VOL},
98
{"lT2", NOT_VOL},
99
{"lF0", NOT_VOL},
100
{"lF1", NOT_VOL},
101
{"lF2", NOT_VOL},
102
103
{"lS0V", IS_VOL},
104
{"lS1V", IS_VOL},
105
{"lS2V", IS_VOL},
106
{"lP0V", IS_VOL},
107
{"lP1V", IS_VOL},
108
{"lP2V", IS_VOL},
109
{"lU0V", IS_VOL},
110
{"lU1V", IS_VOL},
111
{"lU2V", IS_VOL},
112
{"lR0V", IS_VOL},
113
{"lR1V", IS_VOL},
114
{"lR2V", IS_VOL},
115
{"lT0V", IS_VOL},
116
{"lT1V", IS_VOL},
117
{"lT2V", IS_VOL},
118
119
{"X0", NOT_VOL},
120
{"X1", NOT_VOL},
121
{"X2", NOT_VOL},
122
{"Z0", NOT_VOL},
123
{"Z1", NOT_VOL},
124
{"Z2", NOT_VOL},
125
{"B0", NOT_VOL},
126
{"B1", NOT_VOL},
127
{"B2", NOT_VOL},
128
{"C0", NOT_VOL},
129
{"C1", NOT_VOL},
130
{"C2", NOT_VOL},
131
{"D0", NOT_VOL},
132
{"D1", NOT_VOL},
133
{"D2", NOT_VOL},
134
{"F0", NOT_VOL},
135
{"F1", NOT_VOL},
136
{"F2", NOT_VOL},
137
{"I0", NOT_VOL},
138
{"I1", NOT_VOL},
139
{"I2", NOT_VOL},
140
{"L0", NOT_VOL},
141
{"L1", NOT_VOL},
142
{"L2", NOT_VOL},
143
{"S0", NOT_VOL},
144
{"S1", NOT_VOL},
145
{"S2", NOT_VOL},
146
{"O0", NOT_VOL},
147
{"O1", NOT_VOL},
148
{"O2", NOT_VOL},
149
150
{"X0V", IS_VOL},
151
{"X1V", IS_VOL},
152
{"X2V", IS_VOL},
153
{"Z0V", IS_VOL},
154
{"Z1V", IS_VOL},
155
{"Z2V", IS_VOL},
156
{"B0V", IS_VOL},
157
{"B1V", IS_VOL},
158
{"B2V", IS_VOL},
159
{"C0V", IS_VOL},
160
{"C1V", IS_VOL},
161
{"C2V", IS_VOL},
162
{"D0V", IS_VOL},
163
{"D1V", IS_VOL},
164
{"D2V", IS_VOL},
165
{"F0V", IS_VOL},
166
{"F1V", IS_VOL},
167
{"F2V", IS_VOL},
168
{"I0V", IS_VOL},
169
{"I1V", IS_VOL},
170
{"I2V", IS_VOL},
171
{"L0V", IS_VOL},
172
{"L1V", IS_VOL},
173
{"L2V", IS_VOL},
174
{"S0V", IS_VOL},
175
{"S1V", IS_VOL},
176
{"S2V", IS_VOL},
177
{"O0V", IS_VOL},
178
{"O1V", IS_VOL},
179
{"O2V", IS_VOL},
180
181
{"LS0", NOT_VOL},
182
{"LS1", NOT_VOL},
183
{"LS2", NOT_VOL},
184
{"LP0", NOT_VOL},
185
{"LP1", NOT_VOL},
186
{"LP2", NOT_VOL},
187
{"LU0", NOT_VOL},
188
{"LU1", NOT_VOL},
189
{"LU2", NOT_VOL},
190
{"LR0", NOT_VOL},
191
{"LR1", NOT_VOL},
192
{"LR2", NOT_VOL},
193
{"LT0", NOT_VOL},
194
{"LT1", NOT_VOL},
195
{"LT2", NOT_VOL},
196
{"LF0", NOT_VOL},
197
{"LF1", NOT_VOL},
198
{"LF2", NOT_VOL},
199
200
{"LS0V", IS_VOL},
201
{"LS1V", IS_VOL},
202
{"LS2V", IS_VOL},
203
{"LP0V", IS_VOL},
204
{"LP1V", IS_VOL},
205
{"LP2V", IS_VOL},
206
{"LU0V", IS_VOL},
207
{"LU1V", IS_VOL},
208
{"LU2V", IS_VOL},
209
{"LR0V", IS_VOL},
210
{"LR1V", IS_VOL},
211
{"LR2V", IS_VOL},
212
{"LT0V", IS_VOL},
213
{"LT1V", IS_VOL},
214
{"LT2V", IS_VOL},
215
216
{"E0", NOT_VOL},
217
{"E1", NOT_VOL},
218
{"E2", NOT_VOL},
219
220
{"E0V", IS_VOL},
221
{"E1V", IS_VOL},
222
{"E2V", IS_VOL},
223
224
{"ES0", NOT_VOL},
225
{"ES1", NOT_VOL},
226
{"ES2", NOT_VOL},
227
{"EP0", NOT_VOL},
228
{"EP1", NOT_VOL},
229
{"EP2", NOT_VOL},
230
{"EU0", NOT_VOL},
231
{"EU1", NOT_VOL},
232
{"EU2", NOT_VOL},
233
{"ER0", NOT_VOL},
234
{"ER1", NOT_VOL},
235
{"ER2", NOT_VOL},
236
{"ET0", NOT_VOL},
237
{"ET1", NOT_VOL},
238
{"ET2", NOT_VOL},
239
{"EF0", NOT_VOL},
240
{"EF1", NOT_VOL},
241
{"EF2", NOT_VOL},
242
243
{"ES0V", IS_VOL},
244
{"ES1V", IS_VOL},
245
{"ES2V", IS_VOL},
246
{"EP0V", IS_VOL},
247
{"EP1V", IS_VOL},
248
{"EP2V", IS_VOL},
249
{"EU0V", IS_VOL},
250
{"EU1V", IS_VOL},
251
{"EU2V", IS_VOL},
252
{"ER0V", IS_VOL},
253
{"ER1V", IS_VOL},
254
{"ER2V", IS_VOL},
255
{"ET0V", IS_VOL},
256
{"ET1V", IS_VOL},
257
{"ET2V", IS_VOL}
258
};
259
private static Log log;
260
private final static String prefix = "nsk.jdi.Field.isVolatile.";
261
private final static String className = "isvol001";
262
private final static String debugerName = prefix + className;
263
private final static String debugeeName = debugerName + "a";
264
265
public static void main(String argv[]) {
266
System.exit(95 + run(argv, System.out));
267
}
268
269
public static int run(String argv[], PrintStream out) {
270
ArgumentHandler argHandler = new ArgumentHandler(argv);
271
log = new Log(out, argHandler);
272
Binder binder = new Binder(argHandler, log);
273
Debugee debugee = binder.bindToDebugee(debugeeName
274
+ (argHandler.verbose() ? " -verbose" : ""));
275
IOPipe pipe = new IOPipe(debugee);
276
boolean testFailed = false;
277
List fields;
278
279
// Connect with debugee and resume it
280
debugee.redirectStderr(out);
281
debugee.resume();
282
String line = pipe.readln();
283
if (line == null) {
284
log.complain("debuger FAILURE> UNEXPECTED debugee's signal - null");
285
return 2;
286
}
287
if (!line.equals("ready")) {
288
log.complain("debuger FAILURE> UNEXPECTED debugee's signal - "
289
+ line);
290
return 2;
291
}
292
else {
293
log.display("debuger> debugee's \"ready\" signal recieved.");
294
}
295
296
// Get all fields from debugee
297
ReferenceType refType = debugee.classByName(debugeeName);
298
if (refType == null) {
299
log.complain("debuger FAILURE> Class " + debugeeName
300
+ " not found.");
301
return 2;
302
}
303
try {
304
fields = refType.allFields();
305
} catch (Exception e) {
306
log.complain("debuger FAILURE> Can't get fields from class");
307
log.complain("debuger FAILURE> Exception: " + e);
308
return 2;
309
}
310
int totalFields = fields.size();
311
if (totalFields < 1) {
312
log.complain("debuger FAILURE> Total number of fields read "
313
+ totalFields + ", should be " + TOTAL_FIELDS);
314
return 2;
315
}
316
log.display("debuger> Total fields found: " + totalFields);
317
Iterator fieldsIterator = fields.iterator();
318
for (int i = 0; fieldsIterator.hasNext(); i++) {
319
Field field = (Field)fieldsIterator.next();
320
boolean isVol = field.isVolatile();
321
String name = field.name();
322
String realIsVol;
323
324
if (name == null) {
325
log.complain("debuger FAILURE 1> Name is null for " + i
326
+ " field");
327
testFailed = true;
328
continue;
329
}
330
log.display("debuger> " + i + " field (" + name + "), "
331
+ "isVolatile = " + isVol + " read.");
332
try {
333
realIsVol = getVolByName(name);
334
} catch (Error e) {
335
log.complain("debuger FAILURE 2> Unexpected Error " + e);
336
return 2;
337
}
338
// isVolatile() returns true if the field is volatile,
339
// returns false if the field is not volatile
340
if ((isVol && !realIsVol.equals(IS_VOL)) ||
341
(!isVol && realIsVol.equals(IS_VOL))
342
) {
343
log.complain("debuger FAILURE> " + i + " field " + name
344
+ ": read field.isVolatile() = " + isVol
345
+ " real isVolatile should be " + realIsVol);
346
testFailed = true;
347
}
348
}
349
pipe.println("quit");
350
debugee.waitFor();
351
int status = debugee.getStatus();
352
if (testFailed) {
353
log.complain("debuger FAILURE> TEST FAILED");
354
return 2;
355
} else {
356
if (status == 95) {
357
log.display("debuger> expected Debugee's exit "
358
+ "status - " + status);
359
return 0;
360
} else {
361
log.complain("debuger FAILURE> UNEXPECTED Debugee's exit "
362
+ "status (not 95) - " + status);
363
return 2;
364
}
365
}
366
}
367
368
private static String getVolByName(String name)
369
throws Error
370
{
371
for (int i = 0; i < TOTAL_FIELDS; i++) {
372
String fieldName = FIELDS_TYPE_NAME[i][0];
373
if (fieldName.equals(name)) {
374
return FIELDS_TYPE_NAME[i][1];
375
}
376
}
377
throw new Error("Error in test. Unknown field " + name);
378
}
379
}
380
381