|
Lines 13-18
Link Here
|
| 13 |
* IBM Corporation - initial API and implementation |
13 |
* IBM Corporation - initial API and implementation |
| 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 |
*******************************************************************************/ |
17 |
*******************************************************************************/ |
| 17 |
package org.eclipse.jdt.core.tests.compiler.regression; |
18 |
package org.eclipse.jdt.core.tests.compiler.regression; |
| 18 |
|
19 |
|
|
Lines 1506-1509
public class JSR308SpecSnippetTests extends AbstractRegressionTest {
Link Here
|
| 1506 |
"}"; |
1507 |
"}"; |
| 1507 |
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); |
1508 |
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); |
| 1508 |
} |
1509 |
} |
|
|
1510 |
|
| 1511 |
// Bug 415543 - Incorrect bound index in RuntimeInvisibleTypeAnnotations attribute |
| 1512 |
public void test034() throws Exception { |
| 1513 |
this.runConformTest( |
| 1514 |
new String[] { |
| 1515 |
"X.java", |
| 1516 |
"import java.lang.annotation.*;\n" + |
| 1517 |
"import static java.lang.annotation.ElementType.*; \n" + |
| 1518 |
"@Target({TYPE_USE}) @interface NonNull { }\n" + |
| 1519 |
"\n" + |
| 1520 |
"class X <T extends @NonNull Comparable> {\n" + |
| 1521 |
" \n" + |
| 1522 |
"}\n", |
| 1523 |
}, |
| 1524 |
""); |
| 1525 |
// javac b100 |
| 1526 |
// RuntimeInvisibleTypeAnnotations: |
| 1527 |
// 0: #13(): CLASS_TYPE_PARAMETER_BOUND, param_index=0, bound_index=1 |
| 1528 |
// bound_index is 1 because the bound is an interface, not a class |
| 1529 |
String expectedOutput = |
| 1530 |
"// Compiled from X.java (version 1.8 : 52.0, super bit)\n" + |
| 1531 |
"// Signature: <T::Ljava/lang/Comparable;>Ljava/lang/Object;\n" + |
| 1532 |
"class X {\n" + |
| 1533 |
" Constant pool:\n" + |
| 1534 |
" constant #1 class: #2 X\n" + |
| 1535 |
" constant #2 utf8: \"X\"\n" + |
| 1536 |
" constant #3 class: #4 java/lang/Object\n" + |
| 1537 |
" constant #4 utf8: \"java/lang/Object\"\n" + |
| 1538 |
" constant #5 utf8: \"<init>\"\n" + |
| 1539 |
" constant #6 utf8: \"()V\"\n" + |
| 1540 |
" constant #7 utf8: \"Code\"\n" + |
| 1541 |
" constant #8 method_ref: #3.#9 java/lang/Object.<init> ()V\n" + |
| 1542 |
" constant #9 name_and_type: #5.#6 <init> ()V\n" + |
| 1543 |
" constant #10 utf8: \"LineNumberTable\"\n" + |
| 1544 |
" constant #11 utf8: \"LocalVariableTable\"\n" + |
| 1545 |
" constant #12 utf8: \"this\"\n" + |
| 1546 |
" constant #13 utf8: \"LX;\"\n" + |
| 1547 |
" constant #14 utf8: \"LocalVariableTypeTable\"\n" + |
| 1548 |
" constant #15 utf8: \"LX<TT;>;\"\n" + |
| 1549 |
" constant #16 utf8: \"SourceFile\"\n" + |
| 1550 |
" constant #17 utf8: \"X.java\"\n" + |
| 1551 |
" constant #18 utf8: \"Signature\"\n" + |
| 1552 |
" constant #19 utf8: \"<T::Ljava/lang/Comparable;>Ljava/lang/Object;\"\n" + |
| 1553 |
" constant #20 utf8: \"RuntimeInvisibleTypeAnnotations\"\n" + |
| 1554 |
" constant #21 utf8: \"LNonNull;\"\n" + |
| 1555 |
" \n" + |
| 1556 |
" // Method descriptor #6 ()V\n" + |
| 1557 |
" // Stack: 1, Locals: 1\n" + |
| 1558 |
" X();\n" + |
| 1559 |
" 0 aload_0 [this]\n" + |
| 1560 |
" 1 invokespecial java.lang.Object() [8]\n" + |
| 1561 |
" 4 return\n" + |
| 1562 |
" Line numbers:\n" + |
| 1563 |
" [pc: 0, line: 5]\n" + |
| 1564 |
" Local variable table:\n" + |
| 1565 |
" [pc: 0, pc: 5] local: this index: 0 type: X\n" + |
| 1566 |
" Local variable type table:\n" + |
| 1567 |
" [pc: 0, pc: 5] local: this index: 0 type: X<T>\n" + |
| 1568 |
"\n" + |
| 1569 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1570 |
" #21 @NonNull(\n" + |
| 1571 |
" target type = 0x11 CLASS_TYPE_PARAMETER_BOUND\n" + |
| 1572 |
" type parameter index = 0 type parameter bound index = 1\n" + |
| 1573 |
" )\n" + |
| 1574 |
"}"; |
| 1575 |
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); |
| 1576 |
} |
| 1577 |
|
| 1578 |
// Bug 415543 - Incorrect bound index in RuntimeInvisibleTypeAnnotations attribute |
| 1579 |
public void test034b() throws Exception { |
| 1580 |
this.runConformTest( |
| 1581 |
new String[] { |
| 1582 |
"X.java", |
| 1583 |
"import java.lang.annotation.*;\n" + |
| 1584 |
"import java.io.*;\n" + |
| 1585 |
"import static java.lang.annotation.ElementType.*; \n" + |
| 1586 |
"@Target({TYPE_USE}) @interface NonNull { }\n" + |
| 1587 |
"\n" + |
| 1588 |
"class X <T extends Comparable & @NonNull Serializable> {\n" + |
| 1589 |
" <T extends @NonNull Comparable> void one(T t) {}\n" + |
| 1590 |
" <T extends Comparable & @NonNull Serializable> void two(T t) {}\n" + |
| 1591 |
" <T extends @NonNull Comparable & @NonNull Serializable> void three(T t) {}\n" + |
| 1592 |
" <T extends Object & @NonNull Serializable> void four(T t) {}\n" + |
| 1593 |
" <T extends Object & @NonNull Serializable & @NonNull Runnable> void five(T t) {}\n" + |
| 1594 |
"}\n", |
| 1595 |
}, |
| 1596 |
""); |
| 1597 |
String expectedOutput = |
| 1598 |
"// Compiled from X.java (version 1.8 : 52.0, super bit)\n" + |
| 1599 |
"// Signature: <T::Ljava/lang/Comparable;:Ljava/io/Serializable;>Ljava/lang/Object;\n" + |
| 1600 |
"class X {\n" + |
| 1601 |
" Constant pool:\n" + |
| 1602 |
" constant #1 class: #2 X\n" + |
| 1603 |
" constant #2 utf8: \"X\"\n" + |
| 1604 |
" constant #3 class: #4 java/lang/Object\n" + |
| 1605 |
" constant #4 utf8: \"java/lang/Object\"\n" + |
| 1606 |
" constant #5 utf8: \"<init>\"\n" + |
| 1607 |
" constant #6 utf8: \"()V\"\n" + |
| 1608 |
" constant #7 utf8: \"Code\"\n" + |
| 1609 |
" constant #8 method_ref: #3.#9 java/lang/Object.<init> ()V\n" + |
| 1610 |
" constant #9 name_and_type: #5.#6 <init> ()V\n" + |
| 1611 |
" constant #10 utf8: \"LineNumberTable\"\n" + |
| 1612 |
" constant #11 utf8: \"LocalVariableTable\"\n" + |
| 1613 |
" constant #12 utf8: \"this\"\n" + |
| 1614 |
" constant #13 utf8: \"LX;\"\n" + |
| 1615 |
" constant #14 utf8: \"LocalVariableTypeTable\"\n" + |
| 1616 |
" constant #15 utf8: \"LX<TT;>;\"\n" + |
| 1617 |
" constant #16 utf8: \"one\"\n" + |
| 1618 |
" constant #17 utf8: \"(Ljava/lang/Comparable;)V\"\n" + |
| 1619 |
" constant #18 utf8: \"Signature\"\n" + |
| 1620 |
" constant #19 utf8: \"<T::Ljava/lang/Comparable;>(TT;)V\"\n" + |
| 1621 |
" constant #20 utf8: \"t\"\n" + |
| 1622 |
" constant #21 utf8: \"Ljava/lang/Comparable;\"\n" + |
| 1623 |
" constant #22 utf8: \"TT;\"\n" + |
| 1624 |
" constant #23 utf8: \"RuntimeInvisibleTypeAnnotations\"\n" + |
| 1625 |
" constant #24 utf8: \"LNonNull;\"\n" + |
| 1626 |
" constant #25 utf8: \"two\"\n" + |
| 1627 |
" constant #26 utf8: \"<T::Ljava/lang/Comparable;:Ljava/io/Serializable;>(TT;)V\"\n" + |
| 1628 |
" constant #27 utf8: \"three\"\n" + |
| 1629 |
" constant #28 utf8: \"four\"\n" + |
| 1630 |
" constant #29 utf8: \"(Ljava/lang/Object;)V\"\n" + |
| 1631 |
" constant #30 utf8: \"<T:Ljava/lang/Object;:Ljava/io/Serializable;>(TT;)V\"\n" + |
| 1632 |
" constant #31 utf8: \"Ljava/lang/Object;\"\n" + |
| 1633 |
" constant #32 utf8: \"five\"\n" + |
| 1634 |
" constant #33 utf8: \"<T:Ljava/lang/Object;:Ljava/io/Serializable;:Ljava/lang/Runnable;>(TT;)V\"\n" + |
| 1635 |
" constant #34 utf8: \"SourceFile\"\n" + |
| 1636 |
" constant #35 utf8: \"X.java\"\n" + |
| 1637 |
" constant #36 utf8: \"<T::Ljava/lang/Comparable;:Ljava/io/Serializable;>Ljava/lang/Object;\"\n" + |
| 1638 |
" \n" + |
| 1639 |
" // Method descriptor #6 ()V\n" + |
| 1640 |
" // Stack: 1, Locals: 1\n" + |
| 1641 |
" X();\n" + |
| 1642 |
" 0 aload_0 [this]\n" + |
| 1643 |
" 1 invokespecial java.lang.Object() [8]\n" + |
| 1644 |
" 4 return\n" + |
| 1645 |
" Line numbers:\n" + |
| 1646 |
" [pc: 0, line: 6]\n" + |
| 1647 |
" Local variable table:\n" + |
| 1648 |
" [pc: 0, pc: 5] local: this index: 0 type: X\n" + |
| 1649 |
" Local variable type table:\n" + |
| 1650 |
" [pc: 0, pc: 5] local: this index: 0 type: X<T>\n" + |
| 1651 |
" \n" + |
| 1652 |
" // Method descriptor #17 (Ljava/lang/Comparable;)V\n" + |
| 1653 |
" // Signature: <T::Ljava/lang/Comparable;>(TT;)V\n" + |
| 1654 |
" // Stack: 0, Locals: 2\n" + |
| 1655 |
" void one(java.lang.Comparable t);\n" + |
| 1656 |
" 0 return\n" + |
| 1657 |
" Line numbers:\n" + |
| 1658 |
" [pc: 0, line: 7]\n" + |
| 1659 |
" Local variable table:\n" + |
| 1660 |
" [pc: 0, pc: 1] local: this index: 0 type: X\n" + |
| 1661 |
" [pc: 0, pc: 1] local: t index: 1 type: java.lang.Comparable\n" + |
| 1662 |
" Local variable type table:\n" + |
| 1663 |
" [pc: 0, pc: 1] local: this index: 0 type: X<T>\n" + |
| 1664 |
" [pc: 0, pc: 1] local: t index: 1 type: T\n" + |
| 1665 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1666 |
" #24 @NonNull(\n" + |
| 1667 |
" target type = 0x12 METHOD_TYPE_PARAMETER_BOUND\n" + |
| 1668 |
" type parameter index = 0 type parameter bound index = 1\n" + |
| 1669 |
" )\n" + |
| 1670 |
" \n" + |
| 1671 |
" // Method descriptor #17 (Ljava/lang/Comparable;)V\n" + |
| 1672 |
" // Signature: <T::Ljava/lang/Comparable;:Ljava/io/Serializable;>(TT;)V\n" + |
| 1673 |
" // Stack: 0, Locals: 2\n" + |
| 1674 |
" void two(java.lang.Comparable t);\n" + |
| 1675 |
" 0 return\n" + |
| 1676 |
" Line numbers:\n" + |
| 1677 |
" [pc: 0, line: 8]\n" + |
| 1678 |
" Local variable table:\n" + |
| 1679 |
" [pc: 0, pc: 1] local: this index: 0 type: X\n" + |
| 1680 |
" [pc: 0, pc: 1] local: t index: 1 type: java.lang.Comparable\n" + |
| 1681 |
" Local variable type table:\n" + |
| 1682 |
" [pc: 0, pc: 1] local: this index: 0 type: X<T>\n" + |
| 1683 |
" [pc: 0, pc: 1] local: t index: 1 type: T\n" + |
| 1684 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1685 |
" #24 @NonNull(\n" + |
| 1686 |
" target type = 0x12 METHOD_TYPE_PARAMETER_BOUND\n" + |
| 1687 |
" type parameter index = 0 type parameter bound index = 2\n" + |
| 1688 |
" )\n" + |
| 1689 |
" \n" + |
| 1690 |
" // Method descriptor #17 (Ljava/lang/Comparable;)V\n" + |
| 1691 |
" // Signature: <T::Ljava/lang/Comparable;:Ljava/io/Serializable;>(TT;)V\n" + |
| 1692 |
" // Stack: 0, Locals: 2\n" + |
| 1693 |
" void three(java.lang.Comparable t);\n" + |
| 1694 |
" 0 return\n" + |
| 1695 |
" Line numbers:\n" + |
| 1696 |
" [pc: 0, line: 9]\n" + |
| 1697 |
" Local variable table:\n" + |
| 1698 |
" [pc: 0, pc: 1] local: this index: 0 type: X\n" + |
| 1699 |
" [pc: 0, pc: 1] local: t index: 1 type: java.lang.Comparable\n" + |
| 1700 |
" Local variable type table:\n" + |
| 1701 |
" [pc: 0, pc: 1] local: this index: 0 type: X<T>\n" + |
| 1702 |
" [pc: 0, pc: 1] local: t index: 1 type: T\n" + |
| 1703 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1704 |
" #24 @NonNull(\n" + |
| 1705 |
" target type = 0x12 METHOD_TYPE_PARAMETER_BOUND\n" + |
| 1706 |
" type parameter index = 0 type parameter bound index = 1\n" + |
| 1707 |
" )\n" + |
| 1708 |
" #24 @NonNull(\n" + |
| 1709 |
" target type = 0x12 METHOD_TYPE_PARAMETER_BOUND\n" + |
| 1710 |
" type parameter index = 0 type parameter bound index = 2\n" + |
| 1711 |
" )\n" + |
| 1712 |
" \n" + |
| 1713 |
" // Method descriptor #29 (Ljava/lang/Object;)V\n" + |
| 1714 |
" // Signature: <T:Ljava/lang/Object;:Ljava/io/Serializable;>(TT;)V\n" + |
| 1715 |
" // Stack: 0, Locals: 2\n" + |
| 1716 |
" void four(java.lang.Object t);\n" + |
| 1717 |
" 0 return\n" + |
| 1718 |
" Line numbers:\n" + |
| 1719 |
" [pc: 0, line: 10]\n" + |
| 1720 |
" Local variable table:\n" + |
| 1721 |
" [pc: 0, pc: 1] local: this index: 0 type: X\n" + |
| 1722 |
" [pc: 0, pc: 1] local: t index: 1 type: java.lang.Object\n" + |
| 1723 |
" Local variable type table:\n" + |
| 1724 |
" [pc: 0, pc: 1] local: this index: 0 type: X<T>\n" + |
| 1725 |
" [pc: 0, pc: 1] local: t index: 1 type: T\n" + |
| 1726 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1727 |
" #24 @NonNull(\n" + |
| 1728 |
" target type = 0x12 METHOD_TYPE_PARAMETER_BOUND\n" + |
| 1729 |
" type parameter index = 0 type parameter bound index = 1\n" + |
| 1730 |
" )\n" + |
| 1731 |
" \n" + |
| 1732 |
" // Method descriptor #29 (Ljava/lang/Object;)V\n" + |
| 1733 |
" // Signature: <T:Ljava/lang/Object;:Ljava/io/Serializable;:Ljava/lang/Runnable;>(TT;)V\n" + |
| 1734 |
" // Stack: 0, Locals: 2\n" + |
| 1735 |
" void five(java.lang.Object t);\n" + |
| 1736 |
" 0 return\n" + |
| 1737 |
" Line numbers:\n" + |
| 1738 |
" [pc: 0, line: 11]\n" + |
| 1739 |
" Local variable table:\n" + |
| 1740 |
" [pc: 0, pc: 1] local: this index: 0 type: X\n" + |
| 1741 |
" [pc: 0, pc: 1] local: t index: 1 type: java.lang.Object\n" + |
| 1742 |
" Local variable type table:\n" + |
| 1743 |
" [pc: 0, pc: 1] local: this index: 0 type: X<T>\n" + |
| 1744 |
" [pc: 0, pc: 1] local: t index: 1 type: T\n" + |
| 1745 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1746 |
" #24 @NonNull(\n" + |
| 1747 |
" target type = 0x12 METHOD_TYPE_PARAMETER_BOUND\n" + |
| 1748 |
" type parameter index = 0 type parameter bound index = 1\n" + |
| 1749 |
" )\n" + |
| 1750 |
" #24 @NonNull(\n" + |
| 1751 |
" target type = 0x12 METHOD_TYPE_PARAMETER_BOUND\n" + |
| 1752 |
" type parameter index = 0 type parameter bound index = 2\n" + |
| 1753 |
" )\n" + |
| 1754 |
"\n" + |
| 1755 |
" RuntimeInvisibleTypeAnnotations: \n" + |
| 1756 |
" #24 @NonNull(\n" + |
| 1757 |
" target type = 0x11 CLASS_TYPE_PARAMETER_BOUND\n" + |
| 1758 |
" type parameter index = 0 type parameter bound index = 2\n" + |
| 1759 |
" )\n" + |
| 1760 |
"}"; |
| 1761 |
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput, ClassFileBytesDisassembler.SYSTEM); |
| 1762 |
} |
| 1509 |
} |
1763 |
} |