Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/runtime/7116786/Test7116786.java
32284 views
1
/*
2
* Copyright (c) 2012, 2014, 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
/*
26
* @test Test7116786
27
* @summary verify that VerifyError messages are as expected
28
* @library testcases.jar
29
* @run main/othervm -Xverify:all Test7116786
30
*/
31
32
33
/**
34
* This class contains information regarding when a VerifyError is thrown
35
* in the verifier. Most of the data is informational-only, and can be
36
* used to track down where and why VerifyErrors are thrown. As such it
37
* is possible the information may go out-of-date.
38
*
39
* The only fields used for the purpose of testing is the 'caseName' and
40
* the 'message'. The 'caseName' corresponds to a classfile which exhibits
41
* the VerifyError, and the 'message' is a regular expression which we expect
42
* to match the verify error message. If the 'message' doesn't match what
43
* we expect, it warrents investigation to see if we are still triggering
44
* the VerifyError that we expect. It could simply just be that the message
45
* changed, which is fine.
46
*
47
* Some cases are not testable, either because the code is probably unreachable
48
* or the test classfile would be too onerous to create. These cases are
49
* marked with 'testable' == false, and the test runner will skip them.
50
*/
51
class Case {
52
private String caseName; // Name of the case
53
private String file; // Source file where VerifyError is thrown
54
private String location; // enclosing function or switch case
55
private String description; // What causes this VerifyError
56
private String message; // The VerifyError message used.
57
58
private boolean testable; // Whether this case is testable or not.
59
60
public Case(String caseName, String file, boolean testable,
61
String location, String description, String message) {
62
this.caseName = caseName;
63
this.file = file;
64
this.testable = testable;
65
this.location = location;
66
this.description = description;
67
this.message = message;
68
}
69
70
String getCaseName() { return this.caseName; }
71
String getFile() { return this.file; }
72
String getLocation() { return this.location; }
73
String getDescription() { return this.description; }
74
String getMessage() { return this.message; }
75
76
boolean isTestable() { return this.testable; }
77
}
78
79
/**
80
* These are the locations in the source code where VerifyErrors are thrown
81
* as of today, 2012/07/18. These may change as the verification code is
82
* modified, which is ok. This test is trying to provide coverage for all
83
* VerifyErrors (just to make sure there are no crashes) and it's probably
84
* not necessary to update it every time the VM changes.
85
*/
86
class VerifyErrorCases {
87
public static final Case[] cases = {
88
89
new Case("case00", "stackMapFrame.cpp", true, "pop_stack_ex",
90
"stack underflow",
91
"Operand stack underflow"),
92
93
new Case("case01", "stackMapFrame.cpp", true, "pop_stack_ex",
94
"stack pop not assignable to expected",
95
"Bad type on operand stack"),
96
97
new Case("case02", "stackMapFrame.cpp", true, "get_local",
98
"local index out-of-bounds",
99
"Local variable table overflow"),
100
101
new Case("case03", "stackMapFrame.cpp", true, "get_local",
102
"local not assignable to expected",
103
"Bad local variable type"),
104
105
new Case("case04", "stackMapFrame.cpp", true, "get_local_2",
106
"local index out-of-bounds [type2]",
107
"get long/double overflows locals"),
108
109
new Case("case05", "stackMapFrame.cpp", true, "get_local_2",
110
"local not assignabled to expected [type2]",
111
"Bad local variable type"),
112
113
/* Unreachable: Can't split long/double on stack */
114
new Case("case06", "stackMapFrame.cpp", false, "get_local_2",
115
"local second-word not assignabled to expected",
116
"Bad local variable type"),
117
118
new Case("case07", "stackMapFrame.cpp", true, "set_local",
119
"local index out-of-bounds",
120
"Local variable table overflow"),
121
122
new Case("case08", "stackMapFrame.cpp", true, "set_local_2",
123
"local index out-of-bounds [type2]",
124
"Local variable table overflow"),
125
126
new Case("case09", "stackMapFrame.hpp", true, "push_stack",
127
"stack overflow",
128
"Operand stack overflow"),
129
130
new Case("case10", "stackMapFrame.hpp", true, "push_stack_2",
131
"stack overflow [type2]",
132
"Operand stack overflow"),
133
134
new Case("case11", "stackMapFrame.hpp", true, "pop_stack",
135
"stack underflow",
136
"Operand stack underflow"),
137
138
new Case("case12", "stackMapTable.cpp", true, "StackMapTable ctor",
139
"stackmap offset beyond code size",
140
"StackMapTable error: bad offset"),
141
142
new Case("case13", "stackMapTable.cpp", true, "match_stackmap",
143
"no stackmap frame at expected location",
144
"Expecting a stackmap frame at branch target "),
145
146
new Case("case14", "stackMapTable.cpp", true, "check_jump_target",
147
"no stackmap frame at jump location or bad jump",
148
"Inconsistent stackmap frames at branch target "),
149
150
/* Backward jump with uninit is allowed starting with JDK 8 */
151
new Case("case15", "stackMapTable.cpp", false, "check_new_object",
152
"backward jump with uninit",
153
"Uninitialized object exists on backward branch "),
154
155
/* Unreachable: wide instructions verified during bytecode analysis */
156
new Case("case16", "verifier.cpp", false, "loop header",
157
"bad op in wide instruction",
158
"Bad wide instruction"),
159
160
new Case("case17", "verifier.cpp", true, "case iaload",
161
"TOS not X array",
162
"Bad type on operand stack in iaload"),
163
164
new Case("case18", "verifier.cpp", true, "case baload",
165
"TOS not X array",
166
"Bad type on operand stack in baload"),
167
168
new Case("case19", "verifier.cpp", true, "case caload",
169
"TOS not X array",
170
"Bad type on operand stack in caload"),
171
172
new Case("case20", "verifier.cpp", true, "case saload",
173
"TOS not X array",
174
"Bad type on operand stack in saload"),
175
176
new Case("case21", "verifier.cpp", true, "case laload",
177
"TOS not X array",
178
"Bad type on operand stack in laload"),
179
180
new Case("case22", "verifier.cpp", true, "case faload",
181
"TOS not X array",
182
"Bad type on operand stack in faload"),
183
184
new Case("case23", "verifier.cpp", true, "case daload",
185
"TOS not X array",
186
"Bad type on operand stack in daload"),
187
188
new Case("case24", "verifier.cpp", true, "case aaload",
189
"TOS not X array",
190
"Bad type on operand stack in aaload"),
191
192
new Case("case25", "verifier.cpp", true, "case iastore",
193
"TOS not int array",
194
"Bad type on operand stack in iastore"),
195
196
new Case("case26", "verifier.cpp", true, "case bastore",
197
"TOS not byte array",
198
"Bad type on operand stack in bastore"),
199
200
new Case("case27", "verifier.cpp", true, "case castore",
201
"TOS not char array",
202
"Bad type on operand stack in castore"),
203
204
new Case("case28", "verifier.cpp", true, "case sastore",
205
"TOS not short array",
206
"Bad type on operand stack in sastore"),
207
208
new Case("case29", "verifier.cpp", true, "case lastore",
209
"TOS not long array",
210
"Bad type on operand stack in lastore"),
211
212
new Case("case30", "verifier.cpp", true, "case fastore",
213
"TOS not float array",
214
"Bad type on operand stack in fastore"),
215
216
new Case("case31", "verifier.cpp", true, "case dastore",
217
"TOS not double array",
218
"Bad type on operand stack in dastore"),
219
220
new Case("case32", "verifier.cpp", true, "case aastore",
221
"TOS not object array",
222
"Bad type on operand stack in aastore"),
223
224
/* Unreachable: In order to hit this case, we would need a
225
* category2_1st at TOS which is not possible. */
226
new Case("case33", "verifier.cpp", false, "case pop2",
227
"TOS is category2_1st (would split)",
228
"Bad type on operand stack in pop2"),
229
230
/* Unreachable: In order to hit this case, we would need a
231
* category2_1st at stack depth 2 with category_1 on TOS which is not
232
* possible. */
233
new Case("case34", "verifier.cpp", false, "case dup_x2",
234
"TOS-1 is category2_1st (would split)",
235
"Bad type on operand stack in dup_x2"),
236
237
/* Unreachable: In order to hit this case, we would need a
238
* category2_1st at TOS which is not possible. */
239
new Case("case35", "verifier.cpp", false, "case dup2",
240
"TOS-1 is category2_1st (would split)",
241
"Bad type on operand stack in dup2"),
242
243
/* Unreachable: In order to hit this case, we would need a
244
* category2_1st at TOS which is not possible. */
245
new Case("case36", "verifier.cpp", false, "case dup2_x1",
246
"TOS-1 is category2_1st (would split)",
247
"Bad type on operand stack in dup2_x1"),
248
249
/* Unreachable: In order to hit this case, we would need a
250
* category2_1st at TOS which is not possible. */
251
new Case("case37", "verifier.cpp", false, "case dup2_x2",
252
"TOS-1 is category2_1st (would split)",
253
"Bad type on operand stack in dup2_x2"),
254
255
/* Unreachable: In order to hit this case, we would need a
256
* category2_1st at stack depth 3 with either 2 category_1 or 1
257
* category_2 on TOS, which is not possible. */
258
new Case("case38", "verifier.cpp", false, "case dup2_x2",
259
"TOS-3 is category2_1st (would split)",
260
"Bad type on operand stack in dup2_x2"),
261
262
new Case("case39", "verifier.cpp", true, "case return",
263
"return type of method is not void",
264
"Method expects a return value"),
265
266
new Case("case40", "verifier.cpp", true, "case return",
267
"return with uninitialized this ",
268
"Constructor must call super() or this() before return"),
269
270
new Case("case41", "verifier.cpp", true, "case new",
271
"cp index not a class type",
272
"Illegal new instruction"),
273
274
new Case("case42", "verifier.cpp", true, "case arraylength",
275
"TOS is not an array",
276
"Bad type on operand stack in arraylength"),
277
278
new Case("case43", "verifier.cpp", true, "case multianewarray",
279
"CP index does not refer to array type",
280
"Illegal constant pool index in multianewarray instruction"),
281
282
new Case("case44", "verifier.cpp", true, "case multianewarray",
283
"Bad dimension (<1) or does not match CP signature",
284
"Illegal dimension in multianewarray instruction: "),
285
286
new Case("case45", "verifier.cpp", true, "case default",
287
"Unrecognized bytecode",
288
"Bad instruction: "),
289
290
new Case("case46", "verifier.cpp", true, "loop end",
291
"control flow falls off method",
292
"Control flow falls through code end"),
293
294
new Case("case47", "verifier.cpp", true, "generate_code_data",
295
"illegal bytecode via RawBytecodeStream (breakpoint)",
296
"Bad instruction"),
297
298
new Case("case48", "verifier.cpp", true, "generate_code_data",
299
"illegal bytecode via RawBytecodeStream (other illegal)",
300
"Bad instruction"),
301
302
new Case("case49", "verifier.cpp", true,
303
"verify_exception_handler_table",
304
"catch_type is not throwable",
305
"Catch type is not a subclass of Throwable in " +
306
"exception handler "),
307
308
new Case("case50", "verifier.cpp", true, "verify_stackmap_table",
309
"missing a stack map frame @ target location (mid table)",
310
"Expecting a stack map frame"),
311
312
new Case("case51", "verifier.cpp", true, "verify_stackmap_table",
313
"stack map does not match?",
314
"Instruction type does not match stack map"),
315
316
new Case("case52", "verifier.cpp", true, "verify_stackmap_table",
317
"missing a stack map frame @ target location (end of table)",
318
"Expecting a stack map frame"),
319
320
new Case("case53", "verifier.cpp", true,
321
"verify_exception_handler_targets",
322
"stackmap mismatch at exception handler",
323
"Stack map does not match the one at exception handler "),
324
325
new Case("case54", "verifier.cpp", true, "verify_cp_index",
326
"constant pool index is out-of-bounds",
327
"Illegal constant pool index "),
328
329
new Case("case55", "verifier.cpp", true, "verify_cp_type",
330
"constant pool entry is not expected type",
331
"Illegal type at constant pool entry "),
332
333
new Case("case56", "verifier.cpp", true, "verify_cp_class_type",
334
"constant pool entry is not an object type",
335
"Illegal type at constant pool entry "),
336
337
/* Unreachable: verify_cp_type gates this case */
338
new Case("case57", "verifier.cpp", false, "verify_ldc",
339
"invalid constant pool index in ldc",
340
"Invalid index in ldc"),
341
342
/* No longer a valid test case for bytecode version >= 51. Nonzero
343
* padding bytes are permitted with lookupswitch and tableswitch
344
* bytecodes as of JVMS 3d edition */
345
new Case("case58", "verifier.cpp", false, "verify_switch",
346
"bad switch padding",
347
"Nonzero padding byte in lookupswitch or tableswitch"),
348
349
new Case("case59", "verifier.cpp", true, "verify_switch",
350
"tableswitch low is greater than high",
351
"low must be less than or equal to high in tableswitch"),
352
353
/* Unreachable on 64-bit? Only way to get here is to overflow
354
* the 'keys' variable which can't happen on 64-bit since we're dealing
355
* with 32-bit values. Perhaps reachable on 32-bit but the
356
* triggering class would be quite large */
357
new Case("case60", "verifier.cpp", false, "verify_switch",
358
"high - low + 1 < 0 (overflow?)",
359
"too many keys in tableswitch"),
360
361
/* Would have to create a 16G classfile to trip this. Possible but
362
* not reasonable to do in a test. */
363
new Case("case61", "verifier.cpp", false, "verify_switch",
364
"lookupswitch keys < 0",
365
"number of keys in lookupswitch less than 0"),
366
367
new Case("case62", "verifier.cpp", true, "verify_switch",
368
"lookupswitch keys out-of-order",
369
"Bad lookupswitch instruction"),
370
371
/* Unreachable: Class file parser verifies Fieldref contents */
372
new Case("case63", "verifier.cpp", false, "verify_field_instructions",
373
"referenced class is not an CP object",
374
"Expecting reference to class in class "),
375
376
new Case("case64", "verifier.cpp", true, "verify_field_instructions",
377
"TOS not assignable to field type in putfield",
378
"Bad type on operand stack in putfield"),
379
380
new Case("case65", "verifier.cpp", true, "verify_field_instructions",
381
"TOS not assignable to class when accessing protected field",
382
"Bad access to protected data in getfield"),
383
384
new Case("case66", "verifier.cpp", true, "verify_invoke_init",
385
"Uninit_this is not of the current type or it's supertype",
386
"Bad <init> method call"),
387
388
/* Unreachable: Stack map parsing ensures valid type and new
389
* instructions have a valid BCI. */
390
new Case("case67", "verifier.cpp", false, "verify_invoke_init",
391
"Uninit type with bad new instruction index",
392
"Expecting new instruction"),
393
394
new Case("case68", "verifier.cpp", true, "verify_invoke_init",
395
"calling other class's <init> method",
396
"Call to wrong <init> method"),
397
398
new Case("case69", "verifier.cpp", true, "verify_invoke_init",
399
"Calling protected <init> and type unassignable from current",
400
"Bad access to protected <init> method"),
401
402
new Case("case70", "verifier.cpp", true, "verify_invoke_init",
403
"TOS is not an uninitialized (or Uninit_this) type",
404
"Bad operand type when invoking <init>"),
405
406
new Case("case71", "verifier.cpp", true, "verify_invoke_instructions",
407
"Arg count in instruction doesn't match signature",
408
"Inconsistent args count operand in invokeinterface"),
409
410
new Case("case72", "verifier.cpp", true, "verify_invoke_instructions",
411
"Non-zero pad in invokeinterface",
412
"Fourth operand byte of invokeinterface must be zero"),
413
414
new Case("case73", "verifier.cpp", true, "verify_invoke_instructions",
415
"Non-zero pad in invokedynamic",
416
"Third and fourth operand bytes of " +
417
"invokedynamic must be zero"),
418
419
new Case("case74", "verifier.cpp", true, "verify_invoke_instructions",
420
"Non-invokespecial trying to invoke a '<' method",
421
"Illegal call to internal method"),
422
423
new Case("case75", "verifier.cpp", true, "verify_invoke_instructions",
424
"invokespecial and current unassignable from referenced type",
425
"Bad invokespecial instruction: current class isn't " +
426
"assignable to reference class."),
427
428
new Case("case76", "verifier.cpp", true, "verify_invoke_instructions",
429
"TOS not assignable to current when calling protected method",
430
"Bad access to protected data in invokevirtual"),
431
432
/* Unreachable: class file parser enforces void signature */
433
new Case("case77", "verifier.cpp", false, "verify_invoke_instructions",
434
"<init> method is not void return",
435
"Return type must be void in <init> method"),
436
437
new Case("case78", "verifier.cpp", true, "get_newarray_type",
438
"newarray type invalid",
439
"Illegal newarray instruction"),
440
441
new Case("case79", "verifier.cpp", true, "verify_return_value",
442
"void return from method which has a return value",
443
"Method expects a return value"),
444
445
new Case("case80", "verifier.cpp", true, "verify_return_value",
446
"TOS type does not match signature",
447
"Bad return type"),
448
449
new Case("case81", "verifier.cpp", true, "verify_stackmap_table",
450
"stack map does not match (flags)",
451
"Instruction type does not match stack map")
452
};
453
}
454
455
public class Test7116786 {
456
public static void main(String argv[]) throws Exception {
457
for (Case c : VerifyErrorCases.cases) {
458
System.out.println("******** " + c.getCaseName() + " ********");
459
if (c.isTestable()) {
460
try {
461
ClassLoader cl = Test7116786.class.getClassLoader();
462
Class<?> cls = Class.forName(c.getCaseName(), true, cl);
463
throw new RuntimeException(
464
"++ FAIL: No verify error encountered");
465
} catch (VerifyError ve) {
466
String message = c.getMessage();
467
String veMessage = ve.getMessage();
468
System.out.print(veMessage);
469
if (!veMessage.startsWith(message)) {
470
// We're not seeing the message we expect. Could be
471
// that we've gotten the wrong VerifyError case, or
472
// maybe the message changed.
473
System.out.println("++ FAIL? " +
474
"Message does not match what was expected: " +
475
message);
476
continue;
477
}
478
if (!veMessage.contains("Exception Details:") &&
479
!veMessage.contains("Reason:")) {
480
System.out.println("++ FAIL: No details found");
481
throw new RuntimeException("FAIL: No details found");
482
}
483
System.out.println("++ PASS");
484
}
485
} else {
486
System.out.println("++ SKIPPED");
487
}
488
}
489
}
490
}
491
492