|
Lines 11-17
Link Here
|
| 11 |
* |
11 |
* |
| 12 |
* Contributors: |
12 |
* Contributors: |
| 13 |
* IBM Corporation - initial API and implementation |
13 |
* IBM Corporation - initial API and implementation |
| 14 |
* |
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 |
*******************************************************************************/ |
16 |
*******************************************************************************/ |
| 16 |
package org.eclipse.jdt.core.tests.compiler.regression; |
17 |
package org.eclipse.jdt.core.tests.compiler.regression; |
| 17 |
|
18 |
|
|
Lines 1380-1386
public class JSR308SpecSnippetTests extends AbstractRegressionTest {
Link Here
|
| 1380 |
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); |
1381 |
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); |
| 1381 |
} |
1382 |
} |
| 1382 |
// Test type annotations in initializer code. |
1383 |
// Test type annotations in initializer code. |
| 1383 |
public void test033() throws Exception { // WILL NEED TO BE ADJUSTED ONCE https://bugs.eclipse.org/bugs/show_bug.cgi?id=415541 IS FIXED. |
1384 |
public void test033() throws Exception { |
| 1384 |
this.runConformTest( |
1385 |
this.runConformTest( |
| 1385 |
new String[] { |
1386 |
new String[] { |
| 1386 |
"X.java", |
1387 |
"X.java", |
|
Lines 1401-1406
public class JSR308SpecSnippetTests extends AbstractRegressionTest {
Link Here
|
| 1401 |
"}\n", |
1402 |
"}\n", |
| 1402 |
}, |
1403 |
}, |
| 1403 |
""); |
1404 |
""); |
|
|
1405 |
// javac b100 |
| 1406 |
// For the annotations in the static {...} the clinit has: |
| 1407 |
// RuntimeInvisibleTypeAnnotations: |
| 1408 |
// 0: #11(): CAST, offset=0, type_index=0 |
| 1409 |
// 1: #11(): NEW, offset=0 |
| 1410 |
// javac is skipping production of the cast so offset is 0. JDT is currently always producing the |
| 1411 |
// checkcast for an annotated cast so the offset is 7. |
| 1412 |
|
| 1413 |
// For the annotations in the initializer {...} the constructors both have: |
| 1414 |
// RuntimeInvisibleTypeAnnotations: |
| 1415 |
// 0: #11(): NEW, offset=4 |
| 1416 |
|
| 1404 |
String expectedOutput = |
1417 |
String expectedOutput = |
| 1405 |
"// Compiled from X.java (version 1.8 : 52.0, super bit)\n" + |
1418 |
"// Compiled from X.java (version 1.8 : 52.0, super bit)\n" + |
| 1406 |
"class X {\n" + |
1419 |
"class X {\n" + |
|
Lines 1417-1426
public class JSR308SpecSnippetTests extends AbstractRegressionTest {
Link Here
|
| 1417 |
" constant #10 utf8: \"<init>\"\n" + |
1430 |
" constant #10 utf8: \"<init>\"\n" + |
| 1418 |
" constant #11 utf8: \"LineNumberTable\"\n" + |
1431 |
" constant #11 utf8: \"LineNumberTable\"\n" + |
| 1419 |
" constant #12 utf8: \"LocalVariableTable\"\n" + |
1432 |
" constant #12 utf8: \"LocalVariableTable\"\n" + |
| 1420 |
" constant #13 utf8: \"this\"\n" + |
1433 |
" constant #13 utf8: \"RuntimeInvisibleTypeAnnotations\"\n" + |
| 1421 |
" constant #14 utf8: \"LX;\"\n" + |
1434 |
" constant #14 utf8: \"LNonNull;\"\n" + |
| 1422 |
" constant #15 utf8: \"RuntimeInvisibleTypeAnnotations\"\n" + |
1435 |
" constant #15 utf8: \"this\"\n" + |
| 1423 |
" constant #16 utf8: \"LNonNull;\"\n" + |
1436 |
" constant #16 utf8: \"LX;\"\n" + |
| 1424 |
" constant #17 utf8: \"(I)V\"\n" + |
1437 |
" constant #17 utf8: \"(I)V\"\n" + |
| 1425 |
" constant #18 utf8: \"x\"\n" + |
1438 |
" constant #18 utf8: \"x\"\n" + |
| 1426 |
" constant #19 utf8: \"I\"\n" + |
1439 |
" constant #19 utf8: \"I\"\n" + |
|
Lines 1430-1443
public class JSR308SpecSnippetTests extends AbstractRegressionTest {
Link Here
|
| 1430 |
" // Method descriptor #6 ()V\n" + |
1443 |
" // Method descriptor #6 ()V\n" + |
| 1431 |
" // Stack: 2, Locals: 1\n" + |
1444 |
" // Stack: 2, Locals: 1\n" + |
| 1432 |
" static {};\n" + |
1445 |
" static {};\n" + |
| 1433 |
" 0 new java.lang.Object [3]\n" + |
1446 |
" 0 new java.lang.Object [3]\n" + |
| 1434 |
" 3 dup\n" + |
1447 |
" 3 dup\n" + |
| 1435 |
" 4 invokespecial java.lang.Object() [8]\n" + |
1448 |
" 4 invokespecial java.lang.Object() [8]\n" + |
| 1436 |
" 7 astore_0\n" + |
1449 |
" 7 checkcast java.lang.Object [3]\n" + |
| 1437 |
" 8 return\n" + |
1450 |
" 10 astore_0\n" + |
|
|
1451 |
" 11 return\n" + |
| 1438 |
" Line numbers:\n" + |
1452 |
" Line numbers:\n" + |
| 1439 |
" [pc: 0, line: 6]\n" + |
1453 |
" [pc: 0, line: 6]\n" + |
| 1440 |
" [pc: 8, line: 7]\n" + |
1454 |
" [pc: 11, line: 7]\n" + |
|
|
1455 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1456 |
" #14 @NonNull(\n" + |
| 1457 |
" target type = 0x44 NEW\n" + |
| 1458 |
" offset = 0\n" + |
| 1459 |
" )\n" + |
| 1460 |
" #14 @NonNull(\n" + |
| 1461 |
" target type = 0x47 CAST\n" + |
| 1462 |
" offset = 7\n" + |
| 1463 |
" type argument index = 0\n" + |
| 1464 |
" )\n" + |
| 1441 |
" \n" + |
1465 |
" \n" + |
| 1442 |
" // Method descriptor #6 ()V\n" + |
1466 |
" // Method descriptor #6 ()V\n" + |
| 1443 |
" // Stack: 1, Locals: 1\n" + |
1467 |
" // Stack: 1, Locals: 1\n" + |
|
Lines 1454-1460
public class JSR308SpecSnippetTests extends AbstractRegressionTest {
Link Here
|
| 1454 |
" Local variable table:\n" + |
1478 |
" Local variable table:\n" + |
| 1455 |
" [pc: 0, pc: 11] local: this index: 0 type: X\n" + |
1479 |
" [pc: 0, pc: 11] local: this index: 0 type: X\n" + |
| 1456 |
" RuntimeInvisibleTypeAnnotations: \n" + |
1480 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1457 |
" #16 @NonNull(\n" + |
1481 |
" #14 @NonNull(\n" + |
| 1458 |
" target type = 0x44 NEW\n" + |
1482 |
" target type = 0x44 NEW\n" + |
| 1459 |
" offset = 4\n" + |
1483 |
" offset = 4\n" + |
| 1460 |
" )\n" + |
1484 |
" )\n" + |
|
Lines 1475-1481
public class JSR308SpecSnippetTests extends AbstractRegressionTest {
Link Here
|
| 1475 |
" [pc: 0, pc: 11] local: this index: 0 type: X\n" + |
1499 |
" [pc: 0, pc: 11] local: this index: 0 type: X\n" + |
| 1476 |
" [pc: 0, pc: 11] local: x index: 1 type: int\n" + |
1500 |
" [pc: 0, pc: 11] local: x index: 1 type: int\n" + |
| 1477 |
" RuntimeInvisibleTypeAnnotations: \n" + |
1501 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1478 |
" #16 @NonNull(\n" + |
1502 |
" #14 @NonNull(\n" + |
| 1479 |
" target type = 0x44 NEW\n" + |
1503 |
" target type = 0x44 NEW\n" + |
| 1480 |
" offset = 4\n" + |
1504 |
" offset = 4\n" + |
| 1481 |
" )\n" + |
1505 |
" )\n" + |