### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v retrieving revision 1.187 diff -u -r1.187 SourceTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 21 Jan 2011 07:16:33 -0000 1.187 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 15 Mar 2011 09:13:10 -0000 @@ -1395,7 +1395,7 @@ method.tagBits |= TagBits.HasParameterAnnotations; } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 - boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0; + boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && !method.isConstructor() && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0; TypeBinding parameterType; if (deferRawTypeCheck) { arg.type.bits |= ASTNode.IgnoreRawTypeCheck; #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java,v retrieving revision 1.8 diff -u -r1.8 GenericsRegressionTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 15 Mar 2011 05:44:19 -0000 1.8 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java 15 Mar 2011 09:13:23 -0000 @@ -1460,4 +1460,284 @@ compilerOptions15, null); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=337962 +public void test337962() { + Map compilerOptions15 = getCompilerOptions(); + compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.ENABLED); + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.List;\n" + + "import java.util.ArrayList;\n" + + "class Super {\n" + + " protected List fList;\n" + + "}\n" + + "public class X extends Super {\n" + + " protected List fSubList; // raw type warning (good)\n" + + " {\n" + + " fSubList = new ArrayList();\n " + + " fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + + " super.fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + + " fSubList.add(null); // type safety warning (good, should not be hidden)\n" + + " }\n" + + " void foo(String s) {\n" + + " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + + " }\n" + + " X(String s) {\n" + + " fSubList = new ArrayList();\n " + + " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 4)\n" + + " protected List fList;\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 7)\n" + + " protected List fSubList; // raw type warning (good)\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 9)\n" + + " fSubList = new ArrayList();\n" + + " ^^^^^^^^^\n" + + "ArrayList is a raw type. References to generic type ArrayList should be parameterized\n" + + "----------\n" + + "4. WARNING in X.java (at line 10)\n" + + " fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n" + + "5. WARNING in X.java (at line 11)\n" + + " super.fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n" + + "6. WARNING in X.java (at line 12)\n" + + " fSubList.add(null); // type safety warning (good, should not be hidden)\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n" + + "7. WARNING in X.java (at line 15)\n" + + " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " ^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n" + + "8. WARNING in X.java (at line 16)\n" + + " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n" + + "9. WARNING in X.java (at line 17)\n" + + " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n" + + "10. WARNING in X.java (at line 20)\n" + + " fSubList = new ArrayList();\n" + + " ^^^^^^^^^\n" + + "ArrayList is a raw type. References to generic type ArrayList should be parameterized\n" + + "----------\n" + + "11. WARNING in X.java (at line 21)\n" + + " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " ^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n" + + "12. WARNING in X.java (at line 22)\n" + + " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n" + + "13. WARNING in X.java (at line 23)\n" + + " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n", + null, + false, + compilerOptions15, + null); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=337962 +public void test337962b() { + Map compilerOptions15 = getCompilerOptions(); + compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.List;\n" + + "import java.util.ArrayList;\n" + + "class Super {\n" + + " protected List fList;\n" + + "}\n" + + "public class X extends Super {\n" + + " protected List fSubList; // raw type warning (good)\n" + + " {\n" + + " fSubList = new ArrayList();\n " + + " fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + + " super.fList.add(null); // type safety warning (TODO: bad, should be hidden)\n" + + " fSubList.add(null); // type safety warning (good, should not be hidden)\n" + + " }\n" + + " void foo(String s) {\n" + + " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + + " }\n" + + " X(String s) {\n" + + " fSubList = new ArrayList();\n " + + " fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " super.fList.add(s); // type safety warning (TODO: bad, should be hidden)\n" + + " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 4)\n" + + " protected List fList;\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 7)\n" + + " protected List fSubList; // raw type warning (good)\n" + + " ^^^^\n" + + "List is a raw type. References to generic type List should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 9)\n" + + " fSubList = new ArrayList();\n" + + " ^^^^^^^^^\n" + + "ArrayList is a raw type. References to generic type ArrayList should be parameterized\n" + + "----------\n" + + "4. WARNING in X.java (at line 12)\n" + + " fSubList.add(null); // type safety warning (good, should not be hidden)\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n" + + "5. WARNING in X.java (at line 17)\n" + + " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n" + + "6. WARNING in X.java (at line 20)\n" + + " fSubList = new ArrayList();\n" + + " ^^^^^^^^^\n" + + "ArrayList is a raw type. References to generic type ArrayList should be parameterized\n" + + "----------\n" + + "7. WARNING in X.java (at line 23)\n" + + " fSubList.add(s); // type safety warning (good, should not be hidden)\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type safety: The method add(Object) belongs to the raw type List. References to generic type List should be parameterized\n" + + "----------\n", + null, + false, + compilerOptions15, + null); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=338011 +public void test338011() { + Map compilerOptions15 = getCompilerOptions(); + compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.*;\n" + + "public class X extends A {\n" + + " public X(Map m) { // should warn about raw type m\n" + + " super(m);\n" + + " m.put(\"one\", 1); // warns about raw method invocation (good)\n" + + " }\n" + + " public X(Map m, boolean b) {\n" + + " super(m); // shows that parametrizing the parameter type is no problem \n" + + " new A(m);\n" + + " m.put(\"one\", 1);\n" + + " }\n" + + "}\n" + + "class A {\n" + + " public A (Map m) {\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " public X(Map m) { // should warn about raw type m\n" + + " ^^^\n" + + "Map is a raw type. References to generic type Map should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " m.put(\"one\", 1); // warns about raw method invocation (good)\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type safety: The method put(Object, Object) belongs to the raw type Map. References to generic type Map should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 14)\n" + + " public A (Map m) {\n" + + " ^^^\n" + + "Map is a raw type. References to generic type Map should be parameterized\n" + + "----------\n", + null, + false, + compilerOptions15, + null); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=338011 +public void test338011b() { + Map compilerOptions15 = getCompilerOptions(); + compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + compilerOptions15.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.ENABLED); + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.*;\n" + + "public class X extends A {\n" + + " public X(Map m) { // should warn about raw type m\n" + + " super(m);\n" + + " m.put(\"one\", 1); // warns about raw method invocation (good)\n" + + " }\n" + + " public X(Map m, boolean b) {\n" + + " super(m); // shows that parametrizing the parameter type is no problem \n" + + " new A(m);\n" + + " m.put(\"one\", 1);\n" + + " }\n" + + "}\n" + + "class A {\n" + + " public A (Map m) {\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " public X(Map m) { // should warn about raw type m\n" + + " ^^^\n" + + "Map is a raw type. References to generic type Map should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " m.put(\"one\", 1); // warns about raw method invocation (good)\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type safety: The method put(Object, Object) belongs to the raw type Map. References to generic type Map should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 14)\n" + + " public A (Map m) {\n" + + " ^^^\n" + + "Map is a raw type. References to generic type Map should be parameterized\n" + + "----------\n", + null, + false, + compilerOptions15, + null); +} } \ No newline at end of file