Lines 1460-1463
Link Here
|
1460 |
compilerOptions15, |
1460 |
compilerOptions15, |
1461 |
null); |
1461 |
null); |
1462 |
} |
1462 |
} |
|
|
1463 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=337962 |
1464 |
public void test337962() { |
1465 |
Map compilerOptions15 = getCompilerOptions(); |
1466 |
compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); |
1467 |
compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); |
1468 |
compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); |
1469 |
compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.ENABLED); |
1470 |
this.runNegativeTest( |
1471 |
new String[] { |
1472 |
"X.java", |
1473 |
"import java.util.List;\n" + |
1474 |
"import java.util.ArrayList;\n" + |
1475 |
"class Super {\n" + |
1476 |
" protected List fList;\n" + |
1477 |
"}\n" + |
1478 |
"public class X extends Super {\n" + |
1479 |
" protected List fSubList; // raw type warning (good)\n" + |
1480 |
" {\n" + |
1481 |
" fSubList = new ArrayList();\n " + |
1482 |
" fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + |
1483 |
" super.fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + |
1484 |
" fSubList.add(null); // type safety warning (good, should not be hidden)\n" + |
1485 |
" }\n" + |
1486 |
" void foo(String s) {\n" + |
1487 |
" fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1488 |
" super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1489 |
" fSubList.add(s); // type safety warning (good, should not be hidden)\n" + |
1490 |
" }\n" + |
1491 |
" X(String s) {\n" + |
1492 |
" fSubList = new ArrayList();\n " + |
1493 |
" fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1494 |
" super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1495 |
" fSubList.add(s); // type safety warning (good, should not be hidden)\n" + |
1496 |
" }\n" + |
1497 |
"}\n" |
1498 |
}, |
1499 |
"----------\n" + |
1500 |
"1. WARNING in X.java (at line 4)\n" + |
1501 |
" protected List fList;\n" + |
1502 |
" ^^^^\n" + |
1503 |
"List is a raw type. References to generic type List<E> should be parameterized\n" + |
1504 |
"----------\n" + |
1505 |
"2. WARNING in X.java (at line 7)\n" + |
1506 |
" protected List fSubList; // raw type warning (good)\n" + |
1507 |
" ^^^^\n" + |
1508 |
"List is a raw type. References to generic type List<E> should be parameterized\n" + |
1509 |
"----------\n" + |
1510 |
"3. WARNING in X.java (at line 9)\n" + |
1511 |
" fSubList = new ArrayList();\n" + |
1512 |
" ^^^^^^^^^\n" + |
1513 |
"ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized\n" + |
1514 |
"----------\n" + |
1515 |
"4. WARNING in X.java (at line 10)\n" + |
1516 |
" fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + |
1517 |
" ^^^^^^^^^^^^^^^\n" + |
1518 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1519 |
"----------\n" + |
1520 |
"5. WARNING in X.java (at line 11)\n" + |
1521 |
" super.fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + |
1522 |
" ^^^^^^^^^^^^^^^^^^^^^\n" + |
1523 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1524 |
"----------\n" + |
1525 |
"6. WARNING in X.java (at line 12)\n" + |
1526 |
" fSubList.add(null); // type safety warning (good, should not be hidden)\n" + |
1527 |
" ^^^^^^^^^^^^^^^^^^\n" + |
1528 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1529 |
"----------\n" + |
1530 |
"7. WARNING in X.java (at line 15)\n" + |
1531 |
" fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1532 |
" ^^^^^^^^^^^^\n" + |
1533 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1534 |
"----------\n" + |
1535 |
"8. WARNING in X.java (at line 16)\n" + |
1536 |
" super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1537 |
" ^^^^^^^^^^^^^^^^^^\n" + |
1538 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1539 |
"----------\n" + |
1540 |
"9. WARNING in X.java (at line 17)\n" + |
1541 |
" fSubList.add(s); // type safety warning (good, should not be hidden)\n" + |
1542 |
" ^^^^^^^^^^^^^^^\n" + |
1543 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1544 |
"----------\n" + |
1545 |
"10. WARNING in X.java (at line 20)\n" + |
1546 |
" fSubList = new ArrayList();\n" + |
1547 |
" ^^^^^^^^^\n" + |
1548 |
"ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized\n" + |
1549 |
"----------\n" + |
1550 |
"11. WARNING in X.java (at line 21)\n" + |
1551 |
" fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1552 |
" ^^^^^^^^^^^^\n" + |
1553 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1554 |
"----------\n" + |
1555 |
"12. WARNING in X.java (at line 22)\n" + |
1556 |
" super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1557 |
" ^^^^^^^^^^^^^^^^^^\n" + |
1558 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1559 |
"----------\n" + |
1560 |
"13. WARNING in X.java (at line 23)\n" + |
1561 |
" fSubList.add(s); // type safety warning (good, should not be hidden)\n" + |
1562 |
" ^^^^^^^^^^^^^^^\n" + |
1563 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1564 |
"----------\n", |
1565 |
null, |
1566 |
false, |
1567 |
compilerOptions15, |
1568 |
null); |
1569 |
} |
1570 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=337962 |
1571 |
public void test337962b() { |
1572 |
Map compilerOptions15 = getCompilerOptions(); |
1573 |
compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); |
1574 |
compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); |
1575 |
compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); |
1576 |
compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED); |
1577 |
this.runNegativeTest( |
1578 |
new String[] { |
1579 |
"X.java", |
1580 |
"import java.util.List;\n" + |
1581 |
"import java.util.ArrayList;\n" + |
1582 |
"class Super {\n" + |
1583 |
" protected List fList;\n" + |
1584 |
"}\n" + |
1585 |
"public class X extends Super {\n" + |
1586 |
" protected List fSubList; // raw type warning (good)\n" + |
1587 |
" {\n" + |
1588 |
" fSubList = new ArrayList();\n " + |
1589 |
" fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + |
1590 |
" super.fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + |
1591 |
" fSubList.add(null); // type safety warning (good, should not be hidden)\n" + |
1592 |
" }\n" + |
1593 |
" void foo(String s) {\n" + |
1594 |
" fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1595 |
" super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1596 |
" fSubList.add(s); // type safety warning (good, should not be hidden)\n" + |
1597 |
" }\n" + |
1598 |
" X(String s) {\n" + |
1599 |
" fSubList = new ArrayList();\n " + |
1600 |
" fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1601 |
" super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + |
1602 |
" fSubList.add(s); // type safety warning (good, should not be hidden)\n" + |
1603 |
" }\n" + |
1604 |
"}\n" |
1605 |
}, |
1606 |
"----------\n" + |
1607 |
"1. WARNING in X.java (at line 4)\n" + |
1608 |
" protected List fList;\n" + |
1609 |
" ^^^^\n" + |
1610 |
"List is a raw type. References to generic type List<E> should be parameterized\n" + |
1611 |
"----------\n" + |
1612 |
"2. WARNING in X.java (at line 7)\n" + |
1613 |
" protected List fSubList; // raw type warning (good)\n" + |
1614 |
" ^^^^\n" + |
1615 |
"List is a raw type. References to generic type List<E> should be parameterized\n" + |
1616 |
"----------\n" + |
1617 |
"3. WARNING in X.java (at line 9)\n" + |
1618 |
" fSubList = new ArrayList();\n" + |
1619 |
" ^^^^^^^^^\n" + |
1620 |
"ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized\n" + |
1621 |
"----------\n" + |
1622 |
"4. WARNING in X.java (at line 12)\n" + |
1623 |
" fSubList.add(null); // type safety warning (good, should not be hidden)\n" + |
1624 |
" ^^^^^^^^^^^^^^^^^^\n" + |
1625 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1626 |
"----------\n" + |
1627 |
"5. WARNING in X.java (at line 17)\n" + |
1628 |
" fSubList.add(s); // type safety warning (good, should not be hidden)\n" + |
1629 |
" ^^^^^^^^^^^^^^^\n" + |
1630 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1631 |
"----------\n" + |
1632 |
"6. WARNING in X.java (at line 20)\n" + |
1633 |
" fSubList = new ArrayList();\n" + |
1634 |
" ^^^^^^^^^\n" + |
1635 |
"ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized\n" + |
1636 |
"----------\n" + |
1637 |
"7. WARNING in X.java (at line 23)\n" + |
1638 |
" fSubList.add(s); // type safety warning (good, should not be hidden)\n" + |
1639 |
" ^^^^^^^^^^^^^^^\n" + |
1640 |
"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + |
1641 |
"----------\n", |
1642 |
null, |
1643 |
false, |
1644 |
compilerOptions15, |
1645 |
null); |
1646 |
} |
1647 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=338011 |
1648 |
public void test338011() { |
1649 |
Map compilerOptions15 = getCompilerOptions(); |
1650 |
compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); |
1651 |
compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); |
1652 |
compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); |
1653 |
compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED); |
1654 |
this.runNegativeTest( |
1655 |
new String[] { |
1656 |
"X.java", |
1657 |
"import java.util.*;\n" + |
1658 |
"public class X extends A {\n" + |
1659 |
" public X(Map m) { // should warn about raw type m\n" + |
1660 |
" super(m);\n" + |
1661 |
" m.put(\"one\", 1); // warns about raw method invocation (good)\n" + |
1662 |
" }\n" + |
1663 |
" public X(Map<String, Integer> m, boolean b) {\n" + |
1664 |
" super(m); // shows that parametrizing the parameter type is no problem \n" + |
1665 |
" new A(m);\n" + |
1666 |
" m.put(\"one\", 1);\n" + |
1667 |
" }\n" + |
1668 |
"}\n" + |
1669 |
"class A {\n" + |
1670 |
" public A (Map m) {\n" + |
1671 |
" }\n" + |
1672 |
"}\n" |
1673 |
}, |
1674 |
"----------\n" + |
1675 |
"1. WARNING in X.java (at line 3)\n" + |
1676 |
" public X(Map m) { // should warn about raw type m\n" + |
1677 |
" ^^^\n" + |
1678 |
"Map is a raw type. References to generic type Map<K,V> should be parameterized\n" + |
1679 |
"----------\n" + |
1680 |
"2. WARNING in X.java (at line 5)\n" + |
1681 |
" m.put(\"one\", 1); // warns about raw method invocation (good)\n" + |
1682 |
" ^^^^^^^^^^^^^^^\n" + |
1683 |
"Type safety: The method put(Object, Object) belongs to the raw type Map. References to generic type Map<K,V> should be parameterized\n" + |
1684 |
"----------\n" + |
1685 |
"3. WARNING in X.java (at line 14)\n" + |
1686 |
" public A (Map m) {\n" + |
1687 |
" ^^^\n" + |
1688 |
"Map is a raw type. References to generic type Map<K,V> should be parameterized\n" + |
1689 |
"----------\n", |
1690 |
null, |
1691 |
false, |
1692 |
compilerOptions15, |
1693 |
null); |
1694 |
} |
1695 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=338011 |
1696 |
public void test338011b() { |
1697 |
Map compilerOptions15 = getCompilerOptions(); |
1698 |
compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); |
1699 |
compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); |
1700 |
compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); |
1701 |
compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.ENABLED); |
1702 |
this.runNegativeTest( |
1703 |
new String[] { |
1704 |
"X.java", |
1705 |
"import java.util.*;\n" + |
1706 |
"public class X extends A {\n" + |
1707 |
" public X(Map m) { // should warn about raw type m\n" + |
1708 |
" super(m);\n" + |
1709 |
" m.put(\"one\", 1); // warns about raw method invocation (good)\n" + |
1710 |
" }\n" + |
1711 |
" public X(Map<String, Integer> m, boolean b) {\n" + |
1712 |
" super(m); // shows that parametrizing the parameter type is no problem \n" + |
1713 |
" new A(m);\n" + |
1714 |
" m.put(\"one\", 1);\n" + |
1715 |
" }\n" + |
1716 |
"}\n" + |
1717 |
"class A {\n" + |
1718 |
" public A (Map m) {\n" + |
1719 |
" }\n" + |
1720 |
"}\n" |
1721 |
}, |
1722 |
"----------\n" + |
1723 |
"1. WARNING in X.java (at line 3)\n" + |
1724 |
" public X(Map m) { // should warn about raw type m\n" + |
1725 |
" ^^^\n" + |
1726 |
"Map is a raw type. References to generic type Map<K,V> should be parameterized\n" + |
1727 |
"----------\n" + |
1728 |
"2. WARNING in X.java (at line 5)\n" + |
1729 |
" m.put(\"one\", 1); // warns about raw method invocation (good)\n" + |
1730 |
" ^^^^^^^^^^^^^^^\n" + |
1731 |
"Type safety: The method put(Object, Object) belongs to the raw type Map. References to generic type Map<K,V> should be parameterized\n" + |
1732 |
"----------\n" + |
1733 |
"3. WARNING in X.java (at line 14)\n" + |
1734 |
" public A (Map m) {\n" + |
1735 |
" ^^^\n" + |
1736 |
"Map is a raw type. References to generic type Map<K,V> should be parameterized\n" + |
1737 |
"----------\n", |
1738 |
null, |
1739 |
false, |
1740 |
compilerOptions15, |
1741 |
null); |
1742 |
} |
1463 |
} |
1743 |
} |