|
Lines 14-19
Link Here
|
| 14 |
* Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for |
14 |
* Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for |
| 15 |
* Bug 415541 - [1.8][compiler] Type annotations in the body of static initializer get dropped |
15 |
* Bug 415541 - [1.8][compiler] Type annotations in the body of static initializer get dropped |
| 16 |
* Bug 415543 - [1.8][compiler] Incorrect bound index in RuntimeInvisibleTypeAnnotations attribute |
16 |
* Bug 415543 - [1.8][compiler] Incorrect bound index in RuntimeInvisibleTypeAnnotations attribute |
|
|
17 |
* Bug 415397 - [1.8][compiler] Type Annotations on wildcard type argument dropped |
| 17 |
*******************************************************************************/ |
18 |
*******************************************************************************/ |
| 18 |
package org.eclipse.jdt.core.tests.compiler.regression; |
19 |
package org.eclipse.jdt.core.tests.compiler.regression; |
| 19 |
|
20 |
|
|
Lines 440-494
public class JSR308SpecSnippetTests extends AbstractRegressionTest {
Link Here
|
| 440 |
" )\n"; |
441 |
" )\n"; |
| 441 |
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); |
442 |
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); |
| 442 |
} |
443 |
} |
| 443 |
public void test011() throws Exception { // WILL FAIL WHEN https://bugs.eclipse.org/bugs/show_bug.cgi?id=415397 IS FIXED. |
444 |
|
|
|
445 |
public void test011() throws Exception { |
| 444 |
this.runConformTest( |
446 |
this.runConformTest( |
| 445 |
new String[] { |
447 |
new String[] { |
| 446 |
"X.java", |
448 |
"X.java", |
| 447 |
"import java.lang.annotation.*;\n" + |
449 |
"import java.lang.annotation.*;\n" + |
| 448 |
"import java.util.List;\n" + |
450 |
"import java.util.*;\n" + |
|
|
451 |
"import java.io.*;\n" + |
| 449 |
"import static java.lang.annotation.ElementType.*; \n" + |
452 |
"import static java.lang.annotation.ElementType.*; \n" + |
| 450 |
"@Target(TYPE_USE)\n" + |
453 |
"@Target(TYPE_USE)\n" + |
| 451 |
"@interface Immutable {}\n" + |
454 |
"@interface Immutable { int value() default 0; }\n" + |
| 452 |
"class X {\n" + |
455 |
"class X {\n" + |
| 453 |
" List<@Immutable ? extends Comparable<X>> x;\n" + |
456 |
" List<@Immutable ? extends Comparable<X>> a;\n" + |
|
|
457 |
" List<? extends @Immutable Comparable<X>> b;\n" + |
| 458 |
" List<@Immutable(1) ? extends @Immutable(2) Comparable<X>> c;\n" + |
| 459 |
" Map<@Immutable(1) ? extends Comparable<X>,@Immutable(2) ? extends @Immutable(3) Serializable> d;\n" + |
| 454 |
"}\n", |
460 |
"}\n", |
| 455 |
}, |
461 |
}, |
| 456 |
""); |
462 |
""); |
|
|
463 |
// javac b100 |
| 464 |
// Field a: |
| 465 |
// RuntimeInvisibleTypeAnnotations: |
| 466 |
// 0: #9(): FIELD, location=[TYPE_ARGUMENT(0)] |
| 467 |
// Field b: |
| 468 |
// RuntimeInvisibleTypeAnnotations: |
| 469 |
// 0: #9(): FIELD, location=[TYPE_ARGUMENT(0), WILDCARD] |
| 470 |
// Field c: |
| 471 |
// RuntimeInvisibleTypeAnnotations: |
| 472 |
// 0: #9(#12=I#13): FIELD, location=[TYPE_ARGUMENT(0)] |
| 473 |
// 1: #9(#12=I#14): FIELD, location=[TYPE_ARGUMENT(0), WILDCARD] |
| 474 |
// Field d: |
| 475 |
// RuntimeInvisibleTypeAnnotations: |
| 476 |
// 0: #9(#12=I#13): FIELD, location=[TYPE_ARGUMENT(0)] |
| 477 |
// 1: #9(#12=I#14): FIELD, location=[TYPE_ARGUMENT(1)] |
| 478 |
// 2: #9(#12=I#18): FIELD, location=[TYPE_ARGUMENT(1), WILDCARD] |
| 457 |
String expectedOutput = |
479 |
String expectedOutput = |
|
|
480 |
"// Compiled from X.java (version 1.8 : 52.0, super bit)\n" + |
| 458 |
"class X {\n" + |
481 |
"class X {\n" + |
| 459 |
" Constant pool:\n" + |
482 |
" Constant pool:\n" + |
| 460 |
" constant #1 class: #2 X\n" + |
483 |
" constant #1 class: #2 X\n" + |
| 461 |
" constant #2 utf8: \"X\"\n" + |
484 |
" constant #2 utf8: \"X\"\n" + |
| 462 |
" constant #3 class: #4 java/lang/Object\n" + |
485 |
" constant #3 class: #4 java/lang/Object\n" + |
| 463 |
" constant #4 utf8: \"java/lang/Object\"\n" + |
486 |
" constant #4 utf8: \"java/lang/Object\"\n" + |
| 464 |
" constant #5 utf8: \"x\"\n" + |
487 |
" constant #5 utf8: \"a\"\n" + |
| 465 |
" constant #6 utf8: \"Ljava/util/List;\"\n" + |
488 |
" constant #6 utf8: \"Ljava/util/List;\"\n" + |
| 466 |
" constant #7 utf8: \"Signature\"\n" + |
489 |
" constant #7 utf8: \"Signature\"\n" + |
| 467 |
" constant #8 utf8: \"Ljava/util/List<+Ljava/lang/Comparable<LX;>;>;\"\n" + |
490 |
" constant #8 utf8: \"Ljava/util/List<+Ljava/lang/Comparable<LX;>;>;\"\n" + |
| 468 |
" constant #9 utf8: \"<init>\"\n" + |
491 |
" constant #9 utf8: \"RuntimeInvisibleTypeAnnotations\"\n" + |
| 469 |
" constant #10 utf8: \"()V\"\n" + |
492 |
" constant #10 utf8: \"LImmutable;\"\n" + |
| 470 |
" constant #11 utf8: \"Code\"\n" + |
493 |
" constant #11 utf8: \"b\"\n" + |
| 471 |
" constant #12 method_ref: #3.#13 java/lang/Object.<init> ()V\n" + |
494 |
" constant #12 utf8: \"c\"\n" + |
| 472 |
" constant #13 name_and_type: #9.#10 <init> ()V\n" + |
495 |
" constant #13 utf8: \"value\"\n" + |
| 473 |
" constant #14 utf8: \"LineNumberTable\"\n" + |
496 |
" constant #14 integer: 1\n" + |
| 474 |
" constant #15 utf8: \"LocalVariableTable\"\n" + |
497 |
" constant #15 integer: 2\n" + |
| 475 |
" constant #16 utf8: \"this\"\n" + |
498 |
" constant #16 utf8: \"d\"\n" + |
| 476 |
" constant #17 utf8: \"LX;\"\n" + |
499 |
" constant #17 utf8: \"Ljava/util/Map;\"\n" + |
| 477 |
" constant #18 utf8: \"SourceFile\"\n" + |
500 |
" constant #18 utf8: \"Ljava/util/Map<+Ljava/lang/Comparable<LX;>;+Ljava/io/Serializable;>;\"\n" + |
| 478 |
" constant #19 utf8: \"X.java\"\n" + |
501 |
" constant #19 integer: 3\n" + |
|
|
502 |
" constant #20 utf8: \"<init>\"\n" + |
| 503 |
" constant #21 utf8: \"()V\"\n" + |
| 504 |
" constant #22 utf8: \"Code\"\n" + |
| 505 |
" constant #23 method_ref: #3.#24 java/lang/Object.<init> ()V\n" + |
| 506 |
" constant #24 name_and_type: #20.#21 <init> ()V\n" + |
| 507 |
" constant #25 utf8: \"LineNumberTable\"\n" + |
| 508 |
" constant #26 utf8: \"LocalVariableTable\"\n" + |
| 509 |
" constant #27 utf8: \"this\"\n" + |
| 510 |
" constant #28 utf8: \"LX;\"\n" + |
| 511 |
" constant #29 utf8: \"SourceFile\"\n" + |
| 512 |
" constant #30 utf8: \"X.java\"\n" + |
| 513 |
" \n" + |
| 514 |
" // Field descriptor #6 Ljava/util/List;\n" + |
| 515 |
" // Signature: Ljava/util/List<+Ljava/lang/Comparable<LX;>;>;\n" + |
| 516 |
" java.util.List a;\n" + |
| 517 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 518 |
" #10 @Immutable(\n" + |
| 519 |
" target type = 0x13 FIELD\n" + |
| 520 |
" location = [TYPE_ARGUMENT(0)]\n" + |
| 521 |
" )\n" + |
| 522 |
" \n" + |
| 523 |
" // Field descriptor #6 Ljava/util/List;\n" + |
| 524 |
" // Signature: Ljava/util/List<+Ljava/lang/Comparable<LX;>;>;\n" + |
| 525 |
" java.util.List b;\n" + |
| 526 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 527 |
" #10 @Immutable(\n" + |
| 528 |
" target type = 0x13 FIELD\n" + |
| 529 |
" location = [TYPE_ARGUMENT(0), WILDCARD]\n" + |
| 530 |
" )\n" + |
| 479 |
" \n" + |
531 |
" \n" + |
| 480 |
" // Field descriptor #6 Ljava/util/List;\n" + |
532 |
" // Field descriptor #6 Ljava/util/List;\n" + |
| 481 |
" // Signature: Ljava/util/List<+Ljava/lang/Comparable<LX;>;>;\n" + |
533 |
" // Signature: Ljava/util/List<+Ljava/lang/Comparable<LX;>;>;\n" + |
| 482 |
" java.util.List x;\n" + |
534 |
" java.util.List c;\n" + |
|
|
535 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 536 |
" #10 @Immutable(\n" + |
| 537 |
" #13 value=(int) 1 (constant type)\n" + |
| 538 |
" target type = 0x13 FIELD\n" + |
| 539 |
" location = [TYPE_ARGUMENT(0)]\n" + |
| 540 |
" )\n" + |
| 541 |
" #10 @Immutable(\n" + |
| 542 |
" #13 value=(int) 2 (constant type)\n" + |
| 543 |
" target type = 0x13 FIELD\n" + |
| 544 |
" location = [TYPE_ARGUMENT(0), WILDCARD]\n" + |
| 545 |
" )\n" + |
| 546 |
" \n" + |
| 547 |
" // Field descriptor #17 Ljava/util/Map;\n" + |
| 548 |
" // Signature: Ljava/util/Map<+Ljava/lang/Comparable<LX;>;+Ljava/io/Serializable;>;\n" + |
| 549 |
" java.util.Map d;\n" + |
| 550 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 551 |
" #10 @Immutable(\n" + |
| 552 |
" #13 value=(int) 1 (constant type)\n" + |
| 553 |
" target type = 0x13 FIELD\n" + |
| 554 |
" location = [TYPE_ARGUMENT(0)]\n" + |
| 555 |
" )\n" + |
| 556 |
" #10 @Immutable(\n" + |
| 557 |
" #13 value=(int) 2 (constant type)\n" + |
| 558 |
" target type = 0x13 FIELD\n" + |
| 559 |
" location = [TYPE_ARGUMENT(1)]\n" + |
| 560 |
" )\n" + |
| 561 |
" #10 @Immutable(\n" + |
| 562 |
" #13 value=(int) 3 (constant type)\n" + |
| 563 |
" target type = 0x13 FIELD\n" + |
| 564 |
" location = [TYPE_ARGUMENT(1), WILDCARD]\n" + |
| 565 |
" )\n" + |
| 483 |
" \n" + |
566 |
" \n" + |
| 484 |
" // Method descriptor #10 ()V\n" + |
567 |
" // Method descriptor #21 ()V\n" + |
| 485 |
" // Stack: 1, Locals: 1\n" + |
568 |
" // Stack: 1, Locals: 1\n" + |
| 486 |
" X();\n" + |
569 |
" X();\n" + |
| 487 |
" 0 aload_0 [this]\n" + |
570 |
" 0 aload_0 [this]\n" + |
| 488 |
" 1 invokespecial java.lang.Object() [12]\n" + |
571 |
" 1 invokespecial java.lang.Object() [23]\n" + |
| 489 |
" 4 return\n" + |
572 |
" 4 return\n" + |
| 490 |
" Line numbers:\n" + |
573 |
" Line numbers:\n" + |
| 491 |
" [pc: 0, line: 6]\n" + |
574 |
" [pc: 0, line: 7]\n" + |
| 492 |
" Local variable table:\n" + |
575 |
" Local variable table:\n" + |
| 493 |
" [pc: 0, pc: 5] local: this index: 0 type: X\n" + |
576 |
" [pc: 0, pc: 5] local: this index: 0 type: X\n" + |
| 494 |
"}"; |
577 |
"}"; |
|
Lines 1164-1170
public class JSR308SpecSnippetTests extends AbstractRegressionTest {
Link Here
|
| 1164 |
" )\n"; |
1247 |
" )\n"; |
| 1165 |
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); |
1248 |
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); |
| 1166 |
} |
1249 |
} |
| 1167 |
public void test028() throws Exception { // // WILL FAIL WHEN https://bugs.eclipse.org/bugs/show_bug.cgi?id=415397 IS FIXED. |
1250 |
public void test028() throws Exception { |
| 1168 |
this.runConformTest( |
1251 |
this.runConformTest( |
| 1169 |
new String[] { |
1252 |
new String[] { |
| 1170 |
"X.java", |
1253 |
"X.java", |
|
Lines 1179-1193
public class JSR308SpecSnippetTests extends AbstractRegressionTest {
Link Here
|
| 1179 |
"}\n", |
1262 |
"}\n", |
| 1180 |
}, |
1263 |
}, |
| 1181 |
""); |
1264 |
""); |
|
|
1265 |
// javac b100 |
| 1266 |
// On the type declaration: |
| 1267 |
// RuntimeInvisibleTypeAnnotations: |
| 1268 |
// 0: #9(): CLASS_TYPE_PARAMETER, param_index=0 |
| 1269 |
// On the method: |
| 1270 |
// RuntimeInvisibleTypeAnnotations: |
| 1271 |
// 0: #9(): METHOD_TYPE_PARAMETER, param_index=0 |
| 1272 |
// On the field: |
| 1273 |
// RuntimeInvisibleTypeAnnotations: |
| 1274 |
// 0: #9(): FIELD, location=[TYPE_ARGUMENT(0)] |
| 1182 |
String expectedOutput = |
1275 |
String expectedOutput = |
|
|
1276 |
"// Compiled from X.java (version 1.8 : 52.0, super bit)\n" + |
| 1277 |
"// Signature: <T:Ljava/lang/Object;>Ljava/lang/Object;\n" + |
| 1278 |
"class X {\n" + |
| 1279 |
" Constant pool:\n" + |
| 1280 |
" constant #1 class: #2 X\n" + |
| 1281 |
" constant #2 utf8: \"X\"\n" + |
| 1282 |
" constant #3 class: #4 java/lang/Object\n" + |
| 1283 |
" constant #4 utf8: \"java/lang/Object\"\n" + |
| 1284 |
" constant #5 utf8: \"l\"\n" + |
| 1285 |
" constant #6 utf8: \"Ljava/util/List;\"\n" + |
| 1286 |
" constant #7 utf8: \"Signature\"\n" + |
| 1287 |
" constant #8 utf8: \"Ljava/util/List<*>;\"\n" + |
| 1288 |
" constant #9 utf8: \"RuntimeInvisibleTypeAnnotations\"\n" + |
| 1289 |
" constant #10 utf8: \"LNonNull;\"\n" + |
| 1290 |
" constant #11 utf8: \"<init>\"\n" + |
| 1291 |
" constant #12 utf8: \"()V\"\n" + |
| 1292 |
" constant #13 utf8: \"Code\"\n" + |
| 1293 |
" constant #14 method_ref: #3.#15 java/lang/Object.<init> ()V\n" + |
| 1294 |
" constant #15 name_and_type: #11.#12 <init> ()V\n" + |
| 1295 |
" constant #16 utf8: \"LineNumberTable\"\n" + |
| 1296 |
" constant #17 utf8: \"LocalVariableTable\"\n" + |
| 1297 |
" constant #18 utf8: \"this\"\n" + |
| 1298 |
" constant #19 utf8: \"LX;\"\n" + |
| 1299 |
" constant #20 utf8: \"LocalVariableTypeTable\"\n" + |
| 1300 |
" constant #21 utf8: \"LX<TT;>;\"\n" + |
| 1301 |
" constant #22 utf8: \"foo\"\n" + |
| 1302 |
" constant #23 utf8: \"<K:Ljava/lang/Object;>()V\"\n" + |
| 1303 |
" constant #24 utf8: \"SourceFile\"\n" + |
| 1304 |
" constant #25 utf8: \"X.java\"\n" + |
| 1305 |
" constant #26 utf8: \"<T:Ljava/lang/Object;>Ljava/lang/Object;\"\n" + |
| 1306 |
" \n" + |
| 1307 |
" // Field descriptor #6 Ljava/util/List;\n" + |
| 1308 |
" // Signature: Ljava/util/List<*>;\n" + |
| 1309 |
" java.util.List l;\n" + |
| 1183 |
" RuntimeInvisibleTypeAnnotations: \n" + |
1310 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1184 |
" #23 @NonNull(\n" + |
1311 |
" #10 @NonNull(\n" + |
|
|
1312 |
" target type = 0x13 FIELD\n" + |
| 1313 |
" location = [TYPE_ARGUMENT(0)]\n" + |
| 1314 |
" )\n" + |
| 1315 |
" \n" + |
| 1316 |
" // Method descriptor #12 ()V\n" + |
| 1317 |
" // Stack: 1, Locals: 1\n" + |
| 1318 |
" X();\n" + |
| 1319 |
" 0 aload_0 [this]\n" + |
| 1320 |
" 1 invokespecial java.lang.Object() [14]\n" + |
| 1321 |
" 4 return\n" + |
| 1322 |
" Line numbers:\n" + |
| 1323 |
" [pc: 0, line: 6]\n" + |
| 1324 |
" Local variable table:\n" + |
| 1325 |
" [pc: 0, pc: 5] local: this index: 0 type: X\n" + |
| 1326 |
" Local variable type table:\n" + |
| 1327 |
" [pc: 0, pc: 5] local: this index: 0 type: X<T>\n" + |
| 1328 |
" \n" + |
| 1329 |
" // Method descriptor #12 ()V\n" + |
| 1330 |
" // Signature: <K:Ljava/lang/Object;>()V\n" + |
| 1331 |
" // Stack: 0, Locals: 1\n" + |
| 1332 |
" void foo();\n" + |
| 1333 |
" 0 return\n" + |
| 1334 |
" Line numbers:\n" + |
| 1335 |
" [pc: 0, line: 7]\n" + |
| 1336 |
" Local variable table:\n" + |
| 1337 |
" [pc: 0, pc: 1] local: this index: 0 type: X\n" + |
| 1338 |
" Local variable type table:\n" + |
| 1339 |
" [pc: 0, pc: 1] local: this index: 0 type: X<T>\n" + |
| 1340 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1341 |
" #10 @NonNull(\n" + |
| 1185 |
" target type = 0x1 METHOD_TYPE_PARAMETER\n" + |
1342 |
" target type = 0x1 METHOD_TYPE_PARAMETER\n" + |
| 1186 |
" type parameter index = 0\n" + |
1343 |
" type parameter index = 0\n" + |
| 1187 |
" )\n" + |
1344 |
" )\n" + |
| 1188 |
"\n" + |
1345 |
"\n" + |
| 1189 |
" RuntimeInvisibleTypeAnnotations: \n" + |
1346 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1190 |
" #23 @NonNull(\n" + |
1347 |
" #10 @NonNull(\n" + |
| 1191 |
" target type = 0x0 CLASS_TYPE_PARAMETER\n" + |
1348 |
" target type = 0x0 CLASS_TYPE_PARAMETER\n" + |
| 1192 |
" type parameter index = 0\n" + |
1349 |
" type parameter index = 0\n" + |
| 1193 |
" )\n" + |
1350 |
" )\n" + |