### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java,v retrieving revision 1.65 diff -u -r1.65 JavadocBugsTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 19 Aug 2009 14:57:15 -0000 1.65 +++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 11 Sep 2009 18:32:31 -0000 @@ -5994,7 +5994,7 @@ * @test Ensure that no warning are raised when ambiguous parameterized methods are present in javadoc comments * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=165794" */ -public void testBug165794() { +public void _testBug165794() { String[] testFiles = new String[] { "X.java", "/**\n" + Index: src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java,v retrieving revision 1.187 diff -u -r1.187 MethodVerifyTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 17 Aug 2009 15:51:04 -0000 1.187 +++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 11 Sep 2009 18:32:31 -0000 @@ -3223,8 +3223,7 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X1.java", "import java.util.*;\n" + @@ -3232,13 +3231,31 @@ " public Object putAll(Map a) { return null; }\n" + "}\n" }, - "" + "----------\n" + + "1. WARNING in X1.java (at line 2)\n" + + " public class X1 extends LinkedHashMap {\n" + + " ^^\n" + + "The serializable class X1 does not declare a static final serialVersionUID field of type long\n" + + "----------\n" + + "2. ERROR in X1.java (at line 3)\n" + + " public Object putAll(Map a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method putAll(Map) of type X1 has the same erasure as putAll(Map) of type HashMap but does not override it\n" + + "----------\n" ); +/* javac 7 +X.java:4: name clash: putAll(Map) in X1 and putAll(Map) in HashMap have the same erasure, yet neither overrides the other + public Object putAll(Map a) { return null; } + ^ + where K,V are type-variables: + K extends Object declared in class HashMap + V extends Object declared in class HashMap +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048a() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X2.java", "public class X2 extends Y {\n" + @@ -3251,8 +3268,21 @@ " public void foo(I a);\n" + "}\n" }, - "" + "----------\n" + + "1. ERROR in X2.java (at line 2)\n" + + " public Object foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X2 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n" ); +/* javac 7 +X.java:2: name clash: foo(I) in X2 and foo(I) in Y have the same erasure, yet neither overrides the other + public Object foo(I z) { return null; } + ^ + where T is a type-variable: + T extends Object declared in class Y +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048b() { @@ -3275,13 +3305,19 @@ " ^^^^^^^^^^^^^^^^\n" + "Name clash: The method foo(I) of type X3 has the same erasure as foo(I) of type Y but does not override it\n" + "----------\n" - // name clash: foo(I) in X and foo(I) in Y have the same erasure, yet neither overrides the other ); +/* javac 7 +X.java:2: name clash: foo(I) in X3 and foo(I) in Y have the same erasure, yet neither overrides the other + public void foo(I z) {} + ^ + where T is a type-variable: + T extends Object declared in class Y +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048c() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X4.java", "public class X4 extends Y {\n" + @@ -3294,13 +3330,25 @@ " public Object foo(I a);\n" + "}\n" }, - "" + "----------\n" + + "1. ERROR in X4.java (at line 2)\n" + + " public String foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X4 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n" ); +/* javac 7 +X.java:2: name clash: foo(I) in X4 and foo(I) in Y have the same erasure, yet neither overrides the other + public String foo(I z) { return null; } + ^ + where T is a type-variable: + T extends Object declared in class Y +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048d() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X5.java", "public class X5 extends Y {\n" + @@ -3313,13 +3361,26 @@ " public String foo(I a);\n" + "}\n" }, - "" + "----------\n" + + "1. ERROR in X5.java (at line 2)\n" + + " public Object foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X5 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n" ); +/* javac 7 +X.java:2: name clash: foo(I) in X5 and foo(I) in Y have the + same erasure, yet neither overrides the other + public Object foo(I z) { return null; } + ^ + where T is a type-variable: + T extends Object declared in class Y +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048e() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X6.java", "public class X6 extends Y {\n" + @@ -3332,13 +3393,25 @@ " public Object foo(I a);\n" + "}\n" }, - "" + "----------\n" + + "1. ERROR in X6.java (at line 2)\n" + + " public void foo(I z) {}\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X6 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n" ); +/* javac 7 +X.java:2: name clash: foo(I) in X6 and foo(I) in Y have the same erasure, yet neither overrides the other + public void foo(I z) {} + ^ + where T is a type-variable: + T extends Object declared in class Y +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048f() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X7.java", "public class X7 extends Y {\n" + @@ -3351,8 +3424,21 @@ " public T foo(I a);\n" + "}\n" }, - "" + "----------\n" + + "1. ERROR in X7.java (at line 2)\n" + + " public String foo(I z) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(I) of type X7 has the same erasure as foo(I) of type Y but does not override it\n" + + "----------\n" ); +/* javac 7 +X.java:2: name clash: foo(I) in X7 and foo(I) in Y have the same erasure, yet neither overrides the other + public String foo(I z) { return null; } + ^ + where T is a type-variable: + T extends Object declared in class Y +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900 public void test048g() { @@ -3375,8 +3461,15 @@ " ^^^^^^^^^^^^^^^^\n" + "Name clash: The method foo(I) of type X8 has the same erasure as foo(I) of type Y but does not override it\n" + "----------\n" - // name clash: foo(I) in X7 and foo(I) in Y have the same erasure, yet neither overrides the other ); +/* javac 7 +X.java:2: name clash: foo(I) in X8 and foo(I) in Y have the same erasure, yet neither overrides the other + public Object foo(I z) { return null; } + ^ + where T is a type-variable: + T extends Object declared in class Y +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88094 @@ -3439,60 +3532,104 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754 public void test050() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X.java", "public class X {\n" + - " public static S foo() { System.out.print(\"A\"); return null; }\n" + - " public static N foo() { System.out.print(\"B\"); return null; }\n" + - " public static void main(String[] args) {\n" + - " X.foo();\n" + - " X.foo();\n" + - " new X().foo();\n" + - " }\n" + + " public static S foo() { System.out.print(\"A\"); return null; }\n" + + " public static N foo() { System.out.print(\"B\"); return null; }\n" + + " public static void main(String[] args) {\n" + + " X.foo();\n" + + " X.foo();\n" + + " new X().foo();\n" + + " }\n" + "}\n" + "class A {}\n" + - "class B {}\n" + "class B {}" }, - "ABB" - ); + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public static S foo() { System.out.print(\"A\"); return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " public static N foo() { System.out.print(\"B\"); return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " X.foo();\n" + + " ^^^\n" + + "Bound mismatch: The generic method foo() of type X is not applicable for the arguments (). The inferred type B is not a valid substitute for the bounded parameter \n" + + "----------\n" + + "4. ERROR in X.java (at line 7)\n" + + " new X().foo();\n" + + " ^^^\n" + + "Bound mismatch: The generic method foo() of type X is not applicable for the arguments (). The inferred type B is not a valid substitute for the bounded parameter \n" + + "----------\n" + ); +/* javac 7 +X.java:3: name clash: foo() and foo() have the same erasure + public static N foo() { System.out.print("B"); return null; } + ^ + where N,S are type-variables: + N extends B declared in method foo() + S extends A declared in method foo() +X.java:6: method foo in class X cannot be applied to given types + X.foo(); + ^ + required: no arguments + found: no arguments +X.java:7: method foo in class X cannot be applied to given types + new X().foo(); + ^ + required: no arguments + found: no arguments +3 errors + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754 public void test050a() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() this.runNegativeTest( new String[] { "X.java", "public class X {\n" + - " public static void foo() { System.out.print(\"A\"); }\n" + - " public static N foo() { System.out.print(\"B\"); return null; }\n" + - " static void test () {\n" + - " X.foo();\n" + - " foo();\n" + - " }\n" + + " public static void foo() { System.out.print(\"A\"); }\n" + + " public static N foo() { System.out.print(\"B\"); return null; }\n" + + " static void test () {\n" + + " X.foo();\n" + + " foo();\n" + + " }\n" + "}\n" + "class A {}\n" + - "class B {}\n" + "class B {}" }, - "----------\n" + - "1. ERROR in X.java (at line 5)\r\n" + - " X.foo();\r\n" + - " ^^^\n" + - "The method foo() is ambiguous for the type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 6)\r\n" + - " foo();\r\n" + - " ^^^\n" + - "The method foo() is ambiguous for the type X\n" + + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public static void foo() { System.out.print(\"A\"); }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " public static N foo() { System.out.print(\"B\"); return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + "----------\n" - // both references are ambiguous ); +/* javac 7 +X.java:3: name clash: foo() and foo() have the same erasure + public static N foo() { System.out.print("B"); return null; } + ^ + where N,S are type-variables: + N extends B declared in method foo() + S extends A declared in method foo() +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation public void test050b() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() this.runNegativeTest( new String[] { "X.java", @@ -3502,8 +3639,8 @@ " Z foo(Object o) { return null; } // duplicate\n" + " }\n" + " class C2 {\n" + - " T foo(Object o) { return null; } // ok\n" + - " T foo(Object o) { return null; } // ok\n" + + " T foo(Object o) { return null; } // duplicate\n" + + " T foo(Object o) { return null; } // duplicate\n" + " }\n" + " class C3 {\n" + " A foo(Object o) { return null; } // duplicate\n" + @@ -3514,49 +3651,73 @@ " T foo(Object o) { return null; } // duplicate\n" + " }\n" + "}\n" + - "class A {}" + - "class Y {}" + + "class A {}\n" + + "class Y {}\n" + "class Z {}" }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " Y foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C1\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " Z foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C1\n" + - "----------\n" + - "3. ERROR in X.java (at line 11)\n" + - " A foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C3\n" + - "----------\n" + - "4. ERROR in X.java (at line 12)\n" + - " A foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C3\n" + - "----------\n" + - "5. ERROR in X.java (at line 15)\n" + - " Y foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C4\n" + - "----------\n" + - "6. ERROR in X.java (at line 16)\n" + - " T foo(Object o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^^^\n" + - "Duplicate method foo(Object) in type X.C4\n" + - "----------\n" - // foo(java.lang.Object) is already defined in X.C1 - // foo(java.lang.Object) is already defined in X.C3 - // foo(java.lang.Object) is already defined in X.C4 + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " Y foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C1\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " Z foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C1\n" + + "----------\n" + + "3. ERROR in X.java (at line 7)\n" + + " T foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n" + + "4. ERROR in X.java (at line 8)\n" + + " T foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n" + + "5. ERROR in X.java (at line 11)\n" + + " A foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C3\n" + + "----------\n" + + "6. ERROR in X.java (at line 12)\n" + + " A foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C3\n" + + "----------\n" + + "7. ERROR in X.java (at line 15)\n" + + " Y foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C4\n" + + "----------\n" + + "8. ERROR in X.java (at line 16)\n" + + " T foo(Object o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C4\n" + + "----------\n" ); +/* javac 7 +X.java:4: foo(Object) is already defined in X.C1 + Z foo(Object o) { return null; } // duplicate + ^ +X.java:8: name clash: foo(Object) and foo(Object) have the same erasure + T foo(Object o) { return null; } // duplicate + ^ + where T#1,T#2 are type-variables: + T#1 extends Z declared in method foo(Object) + T#2 extends Y declared in method foo(Object) +X.java:12: foo(Object) is already defined in X.C3 + A foo(Object o) { return null; } // duplicate + ^ +X.java:16: foo(Object) is already defined in X.C4 + T foo(Object o) { return null; } // duplicate + ^ +4 errors + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation public void test050c() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() this.runNegativeTest( new String[] { "X.java", @@ -3570,28 +3731,48 @@ " T foo(A o) { return null; } // ok\n" + " }\n" + "}\n" + - "class A {}" + - "class Y {}" + + "class A {}\n" + + "class Y {}\n" + "class Z {}" }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " A foo(A o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X.C5\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " A foo(A o) { return null; } // duplicate\n" + - " ^^^^^^^^^^^\n" + - "Method foo(A) has the same erasure foo(A) as another method in type X.C5\n" + - "----------\n" - // name clash: foo(A) and foo(A) have the same erasure - ); + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " A foo(A o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C5\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " A foo(A o) { return null; } // duplicate\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C5\n" + + "----------\n" + + "3. ERROR in X.java (at line 7)\n" + + " T foo(A o) { return null; } // ok\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C6\n" + + "----------\n" + + "4. ERROR in X.java (at line 8)\n" + + " T foo(A o) { return null; } // ok\n" + + " ^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X.C6\n" + + "----------\n" + ); +/* javac 7 +X.java:4: name clash: foo(A) and foo(A) have the same erasure + A foo(A o) { return null; } // duplicate + ^ +X.java:8: name clash: foo(A) and foo(A) have the same erasure + T foo(A o) { return null; } // ok + ^ + where T#1,T#2 are type-variables: + T#1 extends Z declared in method foo(A) + T#2 extends Y declared in method foo(A) +2 errors + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation public void test050d() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X.java", "public class X {\n" + @@ -3600,18 +3781,37 @@ " T foo(Object o) { return null; } // ok\n" + " }\n" + "}\n" + - "class A {}" + - "class Y {}" + + "class A {}\n" + + "class Y {}\n" + "class Z {}" }, - "" + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C7\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C7\n" + + "----------\n" ); +/* javac 7 +X.java:4: name clash: foo(Object) and foo(Object) have the same erasure + T foo(Object o) { return null; } // ok + ^ + where T#1,T#2,U are type-variables: + T#1 extends Z declared in method foo(Object) + T#2 extends Y declared in method foo(Object) + U extends Object declared in method foo(Object) +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 public void test050e() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X.java", "public class X {\n" + @@ -3625,8 +3825,56 @@ "class A {}\n" + "class B {}\n" }, - "" - ); + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " N a(A s) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Object a(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " void b(A s) {}\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " B b(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n" + + "5. ERROR in X.java (at line 6)\n" + + " void c(A s) {}\n" + + " ^^^^^^^^^^^^^^\n" + + "Method c(A) has the same erasure c(A) as another method in type X\n" + + "----------\n" + + "6. ERROR in X.java (at line 7)\n" + + " B c(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method c(A) has the same erasure c(A) as another method in type X\n" + + "----------\n" + ); +/* javac 7 +X.java:3: name clash: a(A) and a(A) have the same erasure + Object a(A n) { return null; } + ^ + where N#1,N#2 are type-variables: + N#1 extends Object declared in method a(A) + N#2 extends B declared in method a(A) +X.java:5: name clash: b(A) and b(A) have the same erasure + B b(A n) { return null; } + ^ + where N#1,N#2 are type-variables: + N#1 extends B declared in method b(A) + N#2 extends B declared in method b(A) +X.java:7: name clash: c(A) and c(A) have the same erasure + B c(A n) { return null; } + ^ +3 errors + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 public void test050f() { @@ -3651,8 +3899,16 @@ " ^^^^^^^^^^^^^^\n" + "Method a(A) has the same erasure a(A) as another method in type X\n" + "----------\n" - // name clash: a(A) and a(A) have the same erasure ); +/* javac 7 +X.java:3: name clash: a(A) and a(A) have the same erasure + B a(A n) { return null; } + ^ + where N#1,N#2 are type-variables: + N#1 extends Object declared in method a(A) + N#2 extends B declared in method a(A) +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 public void test050g() { @@ -3677,8 +3933,16 @@ " ^^^^^^^^^^^^^^\n" + "Method b(A) has the same erasure b(A) as another method in type X\n" + "----------\n" - // name clash: b(A) and b(A) have the same erasure ); +/* javac 7 +X.java:3: name clash: b(A) and b(A) have the same erasure + B b(A n) { return null; } + ^ + where N#1,N#2 are type-variables: + N#1 extends B declared in method b(A) + N#2 extends B declared in method b(A) +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 public void test050h() { @@ -3703,14 +3967,18 @@ " ^^^^^^^^^^^^^^\n" + "Method c(A) has the same erasure c(A) as another method in type X\n" + "----------\n" - // name clash: c(A) and c(A) have the same erasure ); +/* javac 7 +X.java:3: name clash: c(A) and c(A) have the same erasure + B c(A n) { return null; } + ^ +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 public void test050i() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X.java", "public class X {\n" + @@ -3722,8 +3990,43 @@ "class A {}\n" + "class B {}\n" }, - "" - ); + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " N a(A s) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Duplicate method a(A) in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Object a(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Duplicate method a(A) in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " N b(A s) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " Object b(A n) { return null; }\n" + + " ^^^^^^^^^^^^^^\n" + + "Method b(A) has the same erasure b(A) as another method in type X\n" + + "----------\n" + ); +/* javac 7 +X.java:3: name clash: a(A) and a(A) have the same erasure + Object a(A n) { return null; } + ^ + where N#1,N#2 are type-variables: + N#1 extends Object declared in method a(A) + N#2 extends B declared in method a(A) +X.java:5: name clash: b(A) and b(A) have the same erasure + Object b(A n) { return null; } + ^ + where N#1,N#2 are type-variables: + N#1 extends Object declared in method b(A) + N#2 extends B declared in method b(A) +2 errors + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 public void test050j() { @@ -3760,9 +4063,22 @@ " ^^^^^^^^^^^^^^\n" + "Method b(A) has the same erasure b(A) as another method in type X\n" + "----------\n" - // name clash: a(A) and a(A) have the same erasure - // name clash: b(A) and b(A) have the same erasure ); +/* javac 7 +X.java:3: name clash: a(A) and a(A) have the same erasure + B a(A n) { return null; } + ^ + where N#1,N#2 are type-variables: + N#1 extends Object declared in method a(A) + N#2 extends B declared in method a(A) +X.java:5: name clash: b(A) and b(A) have the same erasure + B b(A n) { return null; } + ^ + where N#1,N#2 are type-variables: + N#1 extends Object declared in method b(A) + N#2 extends B declared in method b(A) +2 errors + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 public void test050k() { @@ -3799,9 +4115,20 @@ " ^^^^^^^^^^^^^^\n" + "Duplicate method b(A) in type X\n" + "----------\n" - // a(A) is already defined in X - // b(A) is already defined in X ); +/* javac 7 +X.java:3: a(A) is already defined in X + B a(A n) { return null; } + ^ + where N is a type-variable: + N extends B declared in method a(A) +X.java:5: b(A) is already defined in X + B b(A n) { return null; } + ^ + where N is a type-variable: + N extends B declared in method b(A) +2 errors + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 public void test050l() { @@ -3838,9 +4165,16 @@ " ^^^^^^^^^^^^^^\n" + "Duplicate method b(A) in type X\n" + "----------\n" - // a(A) is already defined in X - // b(A) is already defined in X ); +/* javac 7 +X.java:3: a(A) is already defined in X + B a(A n) { return null; } + ^ +X.java:5: b(A) is already defined in X + B b(A n) { return null; } + ^ +2 errors + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470 @@ -3861,8 +4195,15 @@ " ^\n" + "The type X must implement the inherited abstract method I.foo(T)\n" + "----------\n" - // X is not abstract and does not override abstract method foo(T) in I ); +/* javac 7 +X.java:1: X is not abstract and does not override abstract method foo(T) in I +class X implements I { +^ + where T is a type-variable: + T extends Object declared in method foo(T) +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470 public void test051a() { @@ -3886,13 +4227,17 @@ " ^^^^^^^^^^^^^^^^^\n" + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + "----------\n" - // name clash: foo(A) and foo(A) have the same erasure ); +/* javac 7 +X.java:3: name clash: foo(A) and foo(A) have the same erasure + void foo(A a) {} + ^ +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470 public void test051b() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X.java", "public class X {\n" + @@ -3901,8 +4246,24 @@ "}\n" + "class A {}\n", }, - "" + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(A a) {}\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Object foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" ); +/* javac 7 +X.java:3: name clash: foo(A) and foo(A) have the same erasure + Object foo(A a) { return null; } + ^ +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=91728 @@ -4037,12 +4398,16 @@ " ^^^^^^\n" + "Method a(T) has the same erasure a(Object) as another method in type X\n" + "----------\n" - // a(X) is already defined in X ); +/* javac 7 +X.java:3: a(Object) is already defined in X + T a(T x) { return null; } + ^ +1 error + */ } // more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897 public void test054a() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() this.runNegativeTest( new String[] { "X.java", @@ -4053,29 +4418,82 @@ " T aa(T x) { return null; }\n" + " String a(X x) { return null; }\n" + // dup " T a(T x) { return null; }\n" + - " String z(X x) { return null; }\n" + " Object z(X x) { return null; }\n" + "}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 6)\n" + - " String a(X x) { return null; }\n" + - " ^^^^^^\n" + - "Method a(X) has the same erasure a(X) as another method in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " T a(T x) { return null; }\n" + - " ^^^^^^\n" + - "Method a(T) has the same erasure a(X) as another method in type X\n" + - "----------\n" - // a(X) is already defined in X - ); + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " String aaa(X x) { return null; }\n" + + " ^^^^^^^^\n" + + "Method aaa(X) has the same erasure aaa(X) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " T aaa(T x) { return null; }\n" + + " ^^^^^^^^\n" + + "Method aaa(T) has the same erasure aaa(X) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " String aa(X x) { return null; }\n" + + " ^^^^^^^\n" + + "Method aa(X) has the same erasure aa(X) as another method in type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " T aa(T x) { return null; }\n" + + " ^^^^^^^\n" + + "Method aa(T) has the same erasure aa(X) as another method in type X\n" + + "----------\n" + + "5. ERROR in X.java (at line 6)\n" + + " String a(X x) { return null; }\n" + + " ^^^^^^\n" + + "Method a(X) has the same erasure a(X) as another method in type X\n" + + "----------\n" + + "6. ERROR in X.java (at line 7)\n" + + " T a(T x) { return null; }\n" + + " ^^^^^^\n" + + "Method a(T) has the same erasure a(X) as another method in type X\n" + + "----------\n" + + "7. ERROR in X.java (at line 8)\n" + + " String z(X x) { return null; }\n" + + " ^^^^^^\n" + + "Duplicate method z(X) in type X\n" + + "----------\n" + + "8. ERROR in X.java (at line 9)\n" + + " Object z(X x) { return null; }\n" + + " ^^^^^^\n" + + "Duplicate method z(X) in type X\n" + + "----------\n" + ); +/* javac 7 +X.java:3: name clash: aaa(T) and aaa(X) have the same erasure + T aaa(T x) { return null; } + ^ + where T,T1,T2 are type-variables: + T extends X declared in method aaa(T) + T1 extends Object declared in method aaa(X) + T2 extends Object declared in method aaa(X) +X.java:5: name clash: aa(T#1) and aa(X) have the same erasure + T aa(T x) { return null; } + ^ + where T#1,T#2 are type-variables: + T#1 extends X declared in method aa(T#1) + T#2 extends Object declared in method aa(X) +X.java:7: a(X) is already defined in X + T a(T x) { return null; } + ^ +X.java:9: name clash: z(X) and z(X) have the same erasure + Object z(X x) { return null; } + ^ + where T#1,S,T#3 are type-variables: + T#1 extends Object declared in method z(X) + S extends Object declared in method z(X) + T#3 extends Object declared in method z(X) +4 errors + */ } // more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897 public void test054b() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X.java", "public class X {\n" + @@ -4083,8 +4501,27 @@ " String foo(X s) { return null; }\n" + "}\n" }, - "" + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Object foo(X t) { return null; }\n" + + " ^^^^^^^^^^^\n" + + "Duplicate method foo(X) in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " String foo(X s) { return null; }\n" + + " ^^^^^^^^^^^\n" + + "Duplicate method foo(X) in type X\n" + + "----------\n" ); +/* javac 7 +X.java:3: name clash: foo(X) and foo(X) have the same erasure + String foo(X s) { return null; } + ^ + where S,T are type-variables: + S extends Object declared in method foo(X) + T extends Object declared in class X +1 error + */ } // more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897 public void test054c() { @@ -4107,13 +4544,19 @@ " ^^^^^^\n" + "Duplicate method dupT() in type X\n" + "----------\n" - // dupT() is already defined in X ); +/* javac 7 +X.java:3: dupT() is already defined in X + > Object dupT() {return null;} + ^ + where T1 is a type-variable: + T1 extends X declared in method dupT() +1 error + */ } // more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897 public void test054d() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "X.java", "public class X {\n" + @@ -4124,8 +4567,43 @@ "}\n" + "class A {}\n", }, - "" - ); + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " T a(A t) {return null;}\n" + + " ^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " String a(A o) {return null;}\n" + + " ^^^^^^^^^^^^^^\n" + + "Method a(A) has the same erasure a(A) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " T aa(A t) {return null;}\n" + + " ^^^^^^^^^^\n" + + "Method aa(A) has the same erasure aa(A) as another method in type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " String aa(A o) {return null;}\n" + + " ^^^^^^^^^^^^^^^\n" + + "Method aa(A) has the same erasure aa(A) as another method in type X\n" + + "----------\n" + ); +/* javac 7 +X.java:3: name clash: a(A) and a(A) have the same erasure + + String a(A o) {return null;} + ^ + where T#1,T#2 are type-variables: + T#1 extends Object declared in method a(A) + T#2 extends Object declared in method a(A) +X.java:5: name clash: aa(A) and aa(A) have the same erasure + String aa(A o) {return null;} + ^ + where T is a type-variable: + T extends Object declared in method aa(A) +2 errors + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=95933 @@ -4233,46 +4711,69 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898 public void test058a() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() this.runNegativeTest( new String[] { "X.java", "public class X {\n" + - " void test() {\n" + - " new X().foo(\"X\");\n" + - " new X().foo2(\"X\");\n" + - " }\n" + + " void test() {\n" + + " new X().foo(\"X\");\n" + + " new X().foo2(\"X\");\n" + + " }\n" + " T foo(T t) {return null;}\n" + " void foo(A a) {}\n" + " T foo2(T t) {return null;}\n" + " void foo2(A a) {}\n" + "}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 3)\r\n" + - " new X().foo(\"X\");\r\n" + - " ^^^\n" + - "The method foo(String) is ambiguous for the type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\r\n" + - " new X().foo2(\"X\");\r\n" + - " ^^^^\n" + - "The method foo2(String) is ambiguous for the type X\n" + - "----------\n" - // both references are ambiguous - ); + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " T foo(T t) {return null;}\n" + + " ^^^^^^^^\n" + + "Method foo(T) has the same erasure foo(Object) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " void foo(A a) {}\n" + + " ^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(Object) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 8)\n" + + " T foo2(T t) {return null;}\n" + + " ^^^^^^^^^\n" + + "Method foo2(T) has the same erasure foo2(Object) as another method in type X\n" + + "----------\n" + + "4. ERROR in X.java (at line 9)\n" + + " void foo2(A a) {}\n" + + " ^^^^^^^^^\n" + + "Method foo2(A) has the same erasure foo2(Object) as another method in type X\n" + + "----------\n" + ); +/* javac 7 +X.java:7: name clash: foo(A) and foo(T) have the same erasure + void foo(A a) {} + ^ + where A,T are type-variables: + A extends Object declared in class X + T extends Object declared in method foo(T) +X.java:9: name clash: foo2(A) and foo2(T#3) have the same erasure + void foo2(A a) {} + ^ + where T#1,A,T#3 are type-variables: + T#1 extends Object declared in method foo2(A) + A extends Object declared in class X + T#3 extends Object declared in method foo2(T#3) +2 errors + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898 public void test058b() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() this.runNegativeTest( new String[] { "X.java", "public class X extends Y {\n" + - " void test() {\n" + - " new X().foo(\"X\");\n" + - " new X().foo2(\"X\");\n" + - " }\n" + + " void test() {\n" + + " new X().foo(\"X\");\n" + + " new X().foo2(\"X\");\n" + + " }\n" + " T foo(T t) {return null;}\n" + " T foo2(T t) {return null;}\n" + "}\n" + @@ -4282,18 +4783,56 @@ "}" }, "----------\n" + - "1. ERROR in X.java (at line 3)\r\n" + - " new X().foo(\"X\");\r\n" + - " ^^^\n" + - "The method foo(String) is ambiguous for the type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\r\n" + - " new X().foo2(\"X\");\r\n" + - " ^^^^\n" + - "The method foo2(String) is ambiguous for the type X\n" + - "----------\n" - // both references are ambiguous - ); + "1. ERROR in X.java (at line 3)\n" + + " new X().foo(\"X\");\n" + + " ^^^\n" + + "The method foo(String) is ambiguous for the type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " new X().foo2(\"X\");\n" + + " ^^^^\n" + + "The method foo2(String) is ambiguous for the type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " T foo(T t) {return null;}\n" + + " ^^^^^^^^\n" + + "Name clash: The method foo(T) of type X has the same erasure as foo(A) of type Y but does not override it\n" + + "----------\n" + + "4. ERROR in X.java (at line 7)\n" + + " T foo2(T t) {return null;}\n" + + " ^^^^^^^^^\n" + + "Name clash: The method foo2(T) of type X has the same erasure as foo2(A) of type Y but does not override it\n" + + "----------\n" + ); +/* javac 7 +X.java:3: reference to foo is ambiguous, both method foo(A) in Y and method foo(T) in X match + new X().foo("X"); + ^ + where A,T are type-variables: + A extends Object declared in class Y + T extends Object declared in method foo(T) +X.java:4: reference to foo2 is ambiguous, both method foo2(A) in Y and method foo2(T#3) in X match + new X().foo2("X"); + ^ + where T#1,A,T#3 are type-variables: + T#1 extends Object declared in method foo2(A) + A extends Object declared in class Y + T#3 extends Object declared in method foo2(T#3) +X.java:6: name clash: foo(T) in X and foo(A) in Y have the same erasure, yet neither overrides the other + T foo(T t) {return null;} + ^ + where T,A are type-variables: + T extends Object declared in method foo(T) + A extends Object declared in class Y +X.java:7: name clash: foo2(T#1) in X and foo2(A) in Y have the same erasure, yet neither overrides the other + T foo2(T t) {return null;} + ^ + where T#1,T#2,A are type-variables: + T#1 extends Object declared in method foo2(T#1) + T#2 extends Object declared in method foo2(A) + A extends Object declared in class Y +4 errors + */ } public void test059() { @@ -6228,7 +6767,6 @@ // name conflict public void test101() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() this.runNegativeTest( new String[] { "X.java", @@ -6250,16 +6788,26 @@ " }\n" + "}" }, - "----------\n" + - "1. ERROR in X.java (at line 11)\n" + - " Integer getX(List l) {\n" + - " ^^^^^^^^^^^^^^^^^^^^^\n" + - "Duplicate method getX(List) in type Y\n" + - "----------\n" + - "2. ERROR in X.java (at line 14)\n" + - " String getX(List l) {\n" + - " ^^^^^^^^^^^^^^^^^^^^^\n" + - "Duplicate method getX(List) in type Y\n" + + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " Integer getX(List l) {\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Method getX(List) has the same erasure getX(List) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " String getX(List l) {\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Method getX(List) has the same erasure getX(List) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 11)\n" + + " Integer getX(List l) {\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Duplicate method getX(List) in type Y\n" + + "----------\n" + + "4. ERROR in X.java (at line 14)\n" + + " String getX(List l) {\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Duplicate method getX(List) in type Y\n" + "----------\n" ); } @@ -7313,8 +7861,7 @@ } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=202830 public void test120a() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187() - this.runConformTest( + this.runNegativeTest( new String[] { "Bar.java", "class Foo {\n" + @@ -7323,7 +7870,17 @@ "}\n" + "public class Bar extends Foo {}" }, - "" + "----------\n" + + "1. ERROR in Bar.java (at line 2)\n" + + " int getThing(V v) { return 1; }\n" + + " ^^^^^^^^^^^^^\n" + + "Method getThing(V) has the same erasure getThing(Object) as another method in type Foo\n" + + "----------\n" + + "2. ERROR in Bar.java (at line 3)\n" + + " boolean getThing(E e) { return true; }\n" + + " ^^^^^^^^^^^^^\n" + + "Method getThing(E) has the same erasure getThing(Object) as another method in type Foo\n" + + "----------\n" ); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=173477 @@ -9013,7 +9570,7 @@ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=251091 public void test177() { - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) { // see test187() + if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_6) { // see test187() this.runNegativeTest( new String[] { "X.java", @@ -9058,21 +9615,6 @@ "Name clash: The method foo(Collection) of type X has the same erasure as foo(Collection) of type A but does not override it\n" + "----------\n" ); - } else if (new CompilerOptions(getCompilerOptions()).sourceLevel == ClassFileConstants.JDK1_6) { - this.runConformTest( - new String[] { - "X.java", - "import java.util.*;\n" + - "interface I { I foo(Collection c); }\n" + - "class A extends LinkedHashMap {\n" + - " public A foo(Collection c) { return this; }\n" + - "}\n" + - "class X extends A implements I {\n" + - " @Override public X foo(Collection c) { return this; }\n" + - "}" - }, - "" - ); } else { this.runNegativeTest( new String[] { @@ -9086,31 +9628,41 @@ " @Override public X foo(Collection c) { return this; }\n" + "}" }, - "----------\n" + - "1. WARNING in X.java (at line 3)\n" + - " class A extends LinkedHashMap {\n" + - " ^\n" + - "The serializable class A does not declare a static final serialVersionUID field of type long\n" + - "----------\n" + - "2. WARNING in X.java (at line 3)\n" + - " class A extends LinkedHashMap {\n" + - " ^^^^^^^^^^^^^\n" + - "LinkedHashMap is a raw type. References to generic type LinkedHashMap should be parameterized\n" + - "----------\n" + - "3. WARNING in X.java (at line 4)\n" + - " public A foo(Collection c) { return this; }\n" + - " ^^^^^^^^^^\n" + - "Collection is a raw type. References to generic type Collection should be parameterized\n" + - "----------\n" + - "4. WARNING in X.java (at line 6)\n" + - " class X extends A implements I {\n" + - " ^\n" + - "The serializable class X does not declare a static final serialVersionUID field of type long\n" + - "----------\n" + - "5. ERROR in X.java (at line 7)\n" + - " @Override public X foo(Collection c) { return this; }\n" + - " ^^^^^^^^^^^^^^^^^^^^\n" + - "The method foo(Collection) of type X must override a superclass method\n" + + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " class A extends LinkedHashMap {\n" + + " ^\n" + + "The serializable class A does not declare a static final serialVersionUID field of type long\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " class A extends LinkedHashMap {\n" + + " ^^^^^^^^^^^^^\n" + + "LinkedHashMap is a raw type. References to generic type LinkedHashMap should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 4)\n" + + " public A foo(Collection c) { return this; }\n" + + " ^^^^^^^^^^\n" + + "Collection is a raw type. References to generic type Collection should be parameterized\n" + + "----------\n" + + "4. ERROR in X.java (at line 6)\n" + + " class X extends A implements I {\n" + + " ^\n" + + "Name clash: The method foo(Collection) of type I has the same erasure as foo(Collection) of type A but does not override it\n" + + "----------\n" + + "5. WARNING in X.java (at line 6)\n" + + " class X extends A implements I {\n" + + " ^\n" + + "The serializable class X does not declare a static final serialVersionUID field of type long\n" + + "----------\n" + + "6. ERROR in X.java (at line 7)\n" + + " @Override public X foo(Collection c) { return this; }\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method foo(Collection) of type X has the same erasure as foo(Collection) of type A but does not override it\n" + + "----------\n" + + "7. ERROR in X.java (at line 7)\n" + + " @Override public X foo(Collection c) { return this; }\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "The method foo(Collection) of type X must override a superclass method\n" + "----------\n" ); } @@ -9583,7 +10135,7 @@ " int f(List l) {return 0;}\n" + "}\n" + "class Y extends X {\n" + - " double f(List l) {return 0;}\n" + + " double f(List l) {return 0;}\n" +// name clash in 7 "}\n" + "interface I {\n" + " double f(List l);\n" + @@ -9591,32 +10143,30 @@ "abstract class Z extends X implements I {}\n" + "class XX {\n" + " int f(List l) {return 0;}\n" + - "double f(List l) {return 0;}\n" + + "double f(List l) {return 0;}\n" +// name clash in 1.5 & 7 "}" }, - new CompilerOptions(getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_7 - ? "" - : "----------\n" + - "1. ERROR in X.java (at line 6)\n" + - " double f(List l) {return 0;}\n" + - " ^^^^^^^^^^^^^^^^^^\n" + - "Name clash: The method f(List) of type Y has the same erasure as f(List) of type X but does not override it\n" + - "----------\n" + - "2. ERROR in X.java (at line 11)\n" + - " abstract class Z extends X implements I {}\n" + - " ^\n" + - "Name clash: The method f(List) of type X has the same erasure as f(List) of type I but does not override it\n" + - "----------\n" + - "3. ERROR in X.java (at line 13)\n" + - " int f(List l) {return 0;}\n" + - " ^^^^^^^^^^^^^^^^^\n" + - "Method f(List) has the same erasure f(List) as another method in type XX\n" + - "----------\n" + - "4. ERROR in X.java (at line 14)\n" + - " double f(List l) {return 0;}\n" + - " ^^^^^^^^^^^^^^^^^^\n" + - "Method f(List) has the same erasure f(List) as another method in type XX\n" + - "----------\n" + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " double f(List l) {return 0;}\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method f(List) of type Y has the same erasure as f(List) of type X but does not override it\n" + + "----------\n" + + "2. ERROR in X.java (at line 11)\n" + + " abstract class Z extends X implements I {}\n" + + " ^\n" + + "Name clash: The method f(List) of type X has the same erasure as f(List) of type I but does not override it\n" + + "----------\n" + + "3. ERROR in X.java (at line 13)\n" + + " int f(List l) {return 0;}\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method f(List) has the same erasure f(List) as another method in type XX\n" + + "----------\n" + + "4. ERROR in X.java (at line 14)\n" + + " double f(List l) {return 0;}\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Method f(List) has the same erasure f(List) as another method in type XX\n" + + "----------\n" ); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=279836 @@ -10036,4 +10586,39 @@ JavacTestOptions.SKIP ); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=285088 +public void test200() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.Collection;\n" + + "class X {\n" + + " int foo(Collection bar) { return 0; }\n" + + " double foo(Collection bar) {return 0; }\n" + + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " int foo(Collection bar) { return 0; }\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method foo(Collection) has the same erasure foo(Collection) as another method in type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " int foo(Collection bar) { return 0; }\n" + + " ^^^^^^^^^^\n" + + "Collection is a raw type. References to generic type Collection should be parameterized\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " double foo(Collection bar) {return 0; }\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method foo(Collection) has the same erasure foo(Collection) as another method in type X\n" + + "----------\n" + ); +/* javac 7 +X.java:4: foo(Collection) is already defined in X + double foo(Collection bar) {return 0; } + ^ +1 error + */ +} } Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v retrieving revision 1.799 diff -u -r1.799 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 18 Aug 2009 02:37:27 -0000 1.799 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 11 Sep 2009 18:32:31 -0000 @@ -17606,8 +17606,7 @@ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=87956 public void test0561() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; - this.runConformTest( + this.runNegativeTest( new String[] { "X.java", "public class X {\n" + @@ -17617,9 +17616,35 @@ "}\n" + "class A {}\n", }, - "" + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(A a) {}\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Object foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " void test(A a) { foo(a); }\n" + + " ^^^\n" + + "The method foo(A) in the type X is not applicable for the arguments (A)\n" + + "----------\n" ); - this.runConformTest( +/* javac 7 +X.java:3: name clash: foo(A) and foo(A) have the same erasure + Object foo(A a) { return null; } + ^ +X.java:4: method foo in class X cannot be applied to given types + void test(A a) { foo(a); } + ^ + required: A + found: A +2 errors + */ + this.runNegativeTest( new String[] { "X.java", "public class X {\n" + @@ -17629,7 +17654,33 @@ "}\n" + "class A {}\n", }, - "" + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Number foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Integer foo(A a) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Method foo(A) has the same erasure foo(A) as another method in type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " void test(A a) { foo(a); }\n" + + " ^^^\n" + + "The method foo(A) in the type X is not applicable for the arguments (A)\n" + + "----------\n" +/* javac 7 +X.java:3: name clash: foo(A) and foo(A) have the same erasure + Integer foo(A a) { return null; } + ^ +X.java:4: method foo in class X cannot be applied to given types + void test(A a) { foo(a); } + ^ + required: A + found: A +2 errors + */ ); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=87550 @@ -17940,7 +17991,6 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation public void test0574() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; this.runNegativeTest( new String[] { "X.java", @@ -17957,22 +18007,37 @@ " }\n" + "}\n" }, - "----------\n" + - "1. WARNING in X.java (at line 6)\n" + - " T foo(Object o) { return null; } // ok\n" + - " ^^^^^^^\n" + - "The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + - "----------\n" + - "2. WARNING in X.java (at line 7)\n" + - " T foo(Object o) { return null; } // ok\n" + - " ^^^^^^\n" + - "The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + - "----------\n" + - "3. ERROR in X.java (at line 10)\n" + - " new X().new C2().foo((List) null);\n" + - " ^^^\n" + - "The method foo(Object) is ambiguous for the type X.C2\n" + - "----------\n"); + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^\n" + + "The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n" + + "3. WARNING in X.java (at line 7)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^\n" + + "The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "4. ERROR in X.java (at line 7)\n" + + " T foo(Object o) { return null; } // ok\n" + + " ^^^^^^^^^^^^^\n" + + "Duplicate method foo(Object) in type X.C2\n" + + "----------\n" + ); +/* +X.java:6: name clash: foo(Object) and foo(Object) have the same erasure + T foo(Object o) { return null; } // ok + ^ + where T#1,T#2 are type-variables: + T#1 extends String declared in method foo(Object) + T#2 extends Integer declared in method foo(Object) +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=84496 - variation with field ref public void test0575() { @@ -22338,54 +22403,56 @@ } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219 public void test0706() { - if (this.complianceLevel < ClassFileConstants.JDK1_7) { - this.runConformTest( - new String[] { - "X.java", - "public class X {\n" + - " void foo() {\n" + - " BB bb = new BB();\n" + - " bb.test();\n" + - " ((AA) bb).test();\n" + - " }\n" + - "}\n" + - "class AA { AA test() {return null;} }\n" + - "class BB extends AA { BB test() {return null;} }\n" + - "class CC {}\n", - }, - ""); - return; - } this.runNegativeTest( - new String[] { - "X.java", - "public class X {\n" + - " void foo() {\n" + - " BB bb = new BB();\n" + - " bb.test();\n" + - " ((AA) bb).test();\n" + - " }\n" + - "}\n" + - "class AA { AA test() {return null;} }\n" + - "class BB extends AA { BB test() {return null;} }\n" + - "class CC {}\n", - }, - "----------\n" + - "1. ERROR in X.java (at line 4)\r\n" + - " bb.test();\r\n" + - " ^^^^\n" + - "The method test() is ambiguous for the type BB\n" + - "----------\n" + - "2. ERROR in X.java (at line 9)\n" + - " class BB extends AA { BB test() {return null;} }\n" + - " ^^^^^^\n" + - "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + - "----------\n"); + new String[] { + "X.java", + "public class X {\n" + + " void foo() {\n" + + " BB bb = new BB();\n" + + " bb.test();\n" + + " ((AA) bb).test();\n" + + " }\n" + + "}\n" + + "class AA { AA test() {return null;} }\n" + + "class BB extends AA { BB test() {return null;} }\n" + + "class CC {}\n", + }, + (this.complianceLevel < ClassFileConstants.JDK1_7) + ? "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " class BB extends AA { BB test() {return null;} }\n" + + " ^^^^^^\n" + + "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + + "----------\n" + : "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "2. ERROR in X.java (at line 9)\n" + + " class BB extends AA { BB test() {return null;} }\n" + + " ^^^^^^\n" + + "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + + "----------\n" + ); +/* +X.java:4: reference to test is ambiguous, both method test() in AA and method test() in BB match + bb.test(); + ^ + where U is a type-variable: + U extends Object declared in method test() +X.java:9: name clash: test() in BB and test() in AA have the same erasure, yet neither overrides the other +class BB extends AA { BB test() {return null;} } + ^ + where U is a type-variable: + U extends Object declared in method test() +2 errors + */ } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219 public void test0706a() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; this.runNegativeTest( new String[] { "X.java", @@ -22400,30 +22467,50 @@ "class BB extends AA { BB test() {return null;} }\n" + "class CC {}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " AA res1 = bb.test();\n" + - " ^^^^\n" + - "The method test() is ambiguous for the type BB\n" + - "----------\n" + - "2. WARNING in X.java (at line 5)\n" + - " AA res3 = bb.test();\n" + - " ^^\n" + - "AA is a raw type. References to generic type AA should be parameterized\n" + - "----------\n" + - "3. ERROR in X.java (at line 5)\n" + - " AA res3 = bb.test();\n" + - " ^^^^\n" + - "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " AA res1 = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " AA res3 = bb.test();\n" + + " ^^\n" + + "AA is a raw type. References to generic type AA should be parameterized\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " AA res3 = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "4. ERROR in X.java (at line 9)\n" + + " class BB extends AA { BB test() {return null;} }\n" + + " ^^^^^^\n" + + "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + "----------\n" - // 4: reference to test is ambiguous, both method test() in AA and method test() in BB match - // 5: reference to test is ambiguous, both method test() in AA and method test() in BB match ); +/* +X.java:4: reference to test is ambiguous, both method test() in AA and method test() in BB match + AA res1 = bb.test(); + ^ + where U is a type-variable: + U extends Object declared in method test() +X.java:5: reference to test is ambiguous, both method test() in AA and method test() in BB match + AA res3 = bb.test(); + ^ + where U is a type-variable: + U extends Object declared in method test() +X.java:9: name clash: test() in BB and test() in AA have the same erasure, yet neither overrides the other +class BB extends AA { BB test() {return null;} } + ^ + where U is a type-variable: + U extends Object declared in method test() +3 errors + */ } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219 public void test0706b() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; this.runNegativeTest( new String[] { "X.java", @@ -22438,22 +22525,51 @@ "class BB extends AA { BB test() {return null;} }\n" + "class CC {}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " AA res = bb.test();\n" + - " ^^^^\n" + - "The method test() is ambiguous for the type BB\n" + - "----------\n" + - "2. ERROR in X.java (at line 5)\n" + - " BB res2 = bb.test();\n" + - " ^^^^\n" + - "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " AA res = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " BB res2 = bb.test();\n" + + " ^^^^\n" + + "The method test() is ambiguous for the type BB\n" + + "----------\n" + + "3. ERROR in X.java (at line 9)\n" + + " class BB extends AA { BB test() {return null;} }\n" + + " ^^^^^^\n" + + "Name clash: The method test() of type BB has the same erasure as test() of type AA but does not override it\n" + "----------\n" - // 4: reference to test is ambiguous, both method test() in AA and method test() in BB match - // 4: incompatible types on the assignment - // 5: reference to test is ambiguous, both method test() in AA and method test() in BB match - // 5: incompatible types on the assignment ); +/* +X.java:4: reference to test is ambiguous, both method test() in AA and method test() in BB match + AA res = bb.test(); + ^ + where U is a type-variable: + U extends Object declared in method test() +X.java:4: incompatible types + AA res = bb.test(); + ^ + required: AA + found: AA +X.java:5: reference to test is ambiguous, both method test() in AA and method test() in BB match + BB res2 = bb.test(); + ^ + where U is a type-variable: + U extends Object declared in method test() +X.java:5: incompatible types + BB res2 = bb.test(); + ^ + required: BB + found: AA +X.java:9: name clash: test() in BB and test() in AA have the same erasure, yet neither overrides the other +class BB extends AA { BB test() {return null;} } + ^ + where U is a type-variable: + U extends Object declared in method test() +5 errors + */ this.runNegativeTest( new String[] { "X.java", @@ -22479,8 +22595,20 @@ " ^^^^^^^^^\n" + "Type mismatch: cannot convert from AA to BB\n" + "----------\n" - // incompatible types on both assignments ); +/* +X.java:4: incompatible types + AA res = bb.test(); + ^ + required: AA + found: AA +X.java:5: incompatible types + BB res2 = bb.test(); + ^ + required: BB + found: AA +2 errors + */ } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=98079 public void test0707() { @@ -23610,28 +23738,24 @@ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=100007 public void test0748() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; this.runNegativeTest( new String[] { "X.java", - "public class X {\n" + - " static interface Factory {\n" + - " public U create(Class cl);\n" + - " }\n" + - " \n" + - " static class BytesFactory implements Factory {\n" + - " public byte[] create(Class cl) {\n" + - " return null;\n" + - " }\n" + - " }\n" + + "interface Factory {\n" + + " U create(Class cl);\n" + + "}\n" + + "abstract class X implements Factory {\n" + + " public byte[] create(Class cl) { return null; }\n" + "}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 6)\r\n" + - " static class BytesFactory implements Factory {\r\n" + - " ^^^^^^^^^^^^\n" + - "The type X.BytesFactory must implement the inherited abstract method X.Factory.create(Class)\n" + - "----------\n"); + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " public byte[] create(Class cl) { return null; }\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Name clash: The method create(Class) of type X has the same erasure as create(Class) of type Factory but does not override it\n" + + "----------\n" + ); +// javac 7 reports the name clash when X subclasses another class or is a concrete type } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=100149 public void test0749() { @@ -40021,7 +40145,6 @@ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=204534 public void test1181() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; this.runNegativeTest( new String[] { "X.java", @@ -40029,55 +40152,117 @@ " public static , R extends S & T> R max(T arg1, S arg2) {\n" + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + " }\n" + - "\n" + " public static , S, R extends S & Comparable> R max(T arg1, S arg2) {\n" + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + " }\n" + - "\n" + " public static , S, R extends Comparable> R max(T arg1, S arg2) {\n" + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + " }\n" + - "\n" + - " public static void main(String[] args) {\n" + - " }\n" + + " public static void main(String[] args) {}\n" + "}\n", // ================= }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " public static , R extends S & T> R max(T arg1, S arg2) {\n" + - " ^\n" + - "Cannot specify any additional bound T when first bound is a type parameter\n" + - "----------\n" + - "2. ERROR in X.java (at line 2)\n" + - " public static , R extends S & T> R max(T arg1, S arg2) {\n" + - " ^^^^^^^^^^^^^^^^^^^\n" + - "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + - "----------\n" + - "3. WARNING in X.java (at line 3)\n" + - " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked cast from Object to R\n" + - "----------\n" + - "4. ERROR in X.java (at line 6)\n" + - " public static , S, R extends S & Comparable> R max(T arg1, S arg2) {\n" + - " ^^^^^^^^^^\n" + - "Cannot specify any additional bound Comparable when first bound is a type parameter\n" + - "----------\n" + - "5. ERROR in X.java (at line 6)\n" + - " public static , S, R extends S & Comparable> R max(T arg1, S arg2) {\n" + - " ^^^^^^^^^^^^^^^^^^^\n" + - "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + - "----------\n" + - "6. WARNING in X.java (at line 7)\n" + - " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked cast from Object to R\n" + - "----------\n" + - "7. WARNING in X.java (at line 11)\n" + - " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked cast from Object to R\n" + - "----------\n"); + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public static , R extends S & T> R max(T arg1, S arg2) {\n" + + " ^\n" + + "Cannot specify any additional bound T when first bound is a type parameter\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " public static , R extends S & T> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 3)\n" + + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from Object to R\n" + + "----------\n" + + "4. ERROR in X.java (at line 5)\n" + + " public static , S, R extends S & Comparable> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^\n" + + "Cannot specify any additional bound Comparable when first bound is a type parameter\n" + + "----------\n" + + "5. ERROR in X.java (at line 5)\n" + + " public static , S, R extends S & Comparable> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + + "----------\n" + + "6. WARNING in X.java (at line 6)\n" + + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from Object to R\n" + + "----------\n" + + "7. ERROR in X.java (at line 8)\n" + + " public static , S, R extends Comparable> R max(T arg1, S arg2) {\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Method max(T, S) has the same erasure max(Comparable, Object) as another method in type X\n" + + "----------\n" + + "8. WARNING in X.java (at line 9)\n" + + " return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked cast from Object to R\n" + + "----------\n" + ); +/* +X.java:2: a type variable may not be followed by other bounds + public static , R extends S & T> R max(T arg1, S arg2) { + ^ +X.java:5: a type variable may not be followed by other bounds + public static , S, R extends S & Comparable> +R max(T arg1, S arg2) { + ^ +X.java:5: name clash: max(T#1,S#2) and max(T#5,S#4) have the same erasure + public static , S, R extends S & Comparable> +R max(T arg1, S arg2) { + + ^ + where T#1,S#2,R#3,S#4,T#5,R#6 are type-variables: + T#1 extends Comparable declared in method max(T#1,S#2) + S#2 extends Object declared in method max(T#1,S#2) + R#3 extends S#2 declared in method max(T#1,S#2) + S#4 extends Object declared in method max(T#5,S#4) + T#5 extends Comparable declared in method max(T#5,S#4) + R#6 extends S#4 declared in method max(T#5,S#4) +X.java:8: name clash: max(T#1,S#2) and max(T#5,S#4) have the same erasure + public static , S, R extends Comparable> R max(T arg1, S arg2) { + ^ + where T#1,S#2,R#3,S#4,T#5,R#6 are type-variables: + T#1 extends Comparable declared in method max(T#1,S#2) + S#2 extends Object declared in method max(T#1,S#2) + R#3 extends Comparable declared in method max(T#1,S#2) + S#4 extends Object declared in method max(T#5,S#4) + T#5 extends Comparable declared in method max(T#5,S#4) + R#6 extends S#4 declared in method max(T#5,S#4) +X.java:3: warning: [unchecked] unchecked cast + return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2); + ^ + required: R + found: Object + where R,S,T are type-variables: + R extends S declared in method max(T,S) + S extends Object declared in method max(T,S) + T extends Comparable declared in method max(T,S) +X.java:6: warning: [unchecked] unchecked cast + return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2); + ^ + required: R + found: Object + where R,T,S are type-variables: + R extends S declared in method max(T,S) + T extends Comparable declared in method max(T,S) + S extends Object declared in method max(T,S) +X.java:9: warning: [unchecked] unchecked cast + return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2); + ^ + required: R + found: Object + where R,T,S are type-variables: + R extends Comparable declared in method max(T,S) + T extends Comparable declared in method max(T,S) + S extends Object declared in method max(T,S) +4 errors +3 warnings + */ } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=204536 public void test1182() { Index: src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java,v retrieving revision 1.66 diff -u -r1.66 AmbiguousMethodTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 28 Apr 2009 17:17:37 -0000 1.66 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 11 Sep 2009 18:32:29 -0000 @@ -11,8 +11,6 @@ package org.eclipse.jdt.core.tests.compiler.regression; import junit.framework.*; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; -import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public class AmbiguousMethodTest extends AbstractComparableTest { @@ -231,7 +229,6 @@ } public void test005() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; this.runNegativeTest( new String[] { "X.java", @@ -245,17 +242,30 @@ "class A {}\n" + "class B {}\n" }, - "----------\n" + - "1. ERROR in X.java (at line 5)\n" + - " new X().foo();\n" + - " ^^^\n" + - "The method foo() is ambiguous for the type X\n" + + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo() { }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " N foo() { return null; }\n" + + " ^^^^^\n" + + "Duplicate method foo() in type X\n" + "----------\n" ); +/* javac 7 +X.java:3: name clash: foo() and foo() have the same erasure + N foo() { return null; } + ^ + where N,S are type-variables: + N extends B declared in method foo() + S extends A declared in method foo() +1 error + */ } public void test006() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; this.runNegativeTest( new String[] { "X.java", @@ -273,17 +283,60 @@ "}\n" }, "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " new Y().foo(\"X\");\n" + - " ^^^\n" + - "The method foo(Object) is ambiguous for the type Y\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " new Y().foo2(\"X\");\n" + - " ^^^^\n" + - "The method foo2(Object) is ambiguous for the type Y\n" + + "1. ERROR in X.java (at line 3)\n" + + " new Y().foo(\"X\");\n" + + " ^^^\n" + + "The method foo(Object) is ambiguous for the type Y\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " new Y().foo2(\"X\");\n" + + " ^^^^\n" + + "The method foo2(Object) is ambiguous for the type Y\n" + + "----------\n" + + "3. ERROR in X.java (at line 10)\n" + + " void foo(T2 t) {}\n" + + " ^^^^^^^^^\n" + + "Name clash: The method foo(T2) of type Y has the same erasure as foo(U1) of type X but does not override it\n" + + "----------\n" + + "4. ERROR in X.java (at line 11)\n" + + " void foo2(T2 t) {}\n" + + " ^^^^^^^^^^\n" + + "Name clash: The method foo2(T2) of type Y has the same erasure as foo2(U2) of type X but does not override it\n" + "----------\n" ); +/* javac 7 +X.java:3: reference to foo is ambiguous, both method foo(U1) in X and method + foo(T2) in Y match + new Y().foo("X"); + ^ + where U1,T2 are type-variables: + U1 extends Object declared in method foo(U1) + T2 extends Object declared in class Y +X.java:4: reference to foo2 is ambiguous, both method foo2(U2) in X and meth +od foo2(T2) in Y match + new Y().foo2("X"); + ^ + where U2,U3,T2 are type-variables: + U2 extends Object declared in method foo2(U2) + U3 extends Object declared in method foo2(T2) + T2 extends Object declared in class Y +X.java:10: name clash: foo(T2) in Y and foo(U1) in X have the same erasure, +yet neither overrides the other + void foo(T2 t) {} + ^ + where T2,U1 are type-variables: + T2 extends Object declared in class Y + U1 extends Object declared in method foo(U1) +X.java:11: name clash: foo2(T2) in Y and foo2(U2) in X have the same era +sure, yet neither overrides the other + void foo2(T2 t) {} + ^ + where U3,T2,U2 are type-variables: + U3 extends Object declared in method foo2(T2) + T2 extends Object declared in class Y + U2 extends Object declared in method foo2(U2) +4 errors + */ } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=129056 public void test007() { @@ -396,18 +449,14 @@ " }\n" + "}" }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " static Object createParser(L1 l) { return null; }\n" + - " ^^^^^^^^^^^^^^^^^^\n" + - "Method createParser(L1) has the same erasure createParser(X.Listener) as another method in type X\n" + - "----------\n" + - "2. ERROR in X.java (at line 5)\n" + - " static Object createParser(L2 l) { return null; }\n" + - " ^^^^^^^^^^^^^^^^^^\n" + - "Method createParser(L2) has the same erasure createParser(X.ErrorListener) as another method in type X\n" + + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " createParser(new A());\n" + + " ^^^^^^^^^^^^\n" + + "The method createParser(A) is ambiguous for the type X\n" + "----------\n" ); +// javac 7 randomly picks which ever method is second } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=121024 public void test010b() { @@ -480,8 +529,7 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090 public void test011a() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; - this.runConformTest( + this.runNegativeTest( new String[] { "Combined.java", "public class Combined {\n" + @@ -495,13 +543,31 @@ "class ExOne extends Exception {static final long serialVersionUID = 1;}\n" + "class ExTwo extends Exception {static final long serialVersionUID = 2;}" }, - "" + "----------\n" + + "1. ERROR in Combined.java (at line 2)\n" + + " > void pickOne(T value) throws ExOne {}\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method pickOne(T) has the same erasure pickOne(Comparable) as another method in type Combined\n" + + "----------\n" + + "2. ERROR in Combined.java (at line 3)\n" + + " T pickOne(Comparable value) throws ExTwo { return null;}\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method pickOne(Comparable) has the same erasure pickOne(Comparable) as another method in type Combined\n" + + "----------\n" ); +/* javac 7 +X.java:3: name clash: pickOne(Comparable) and pickOne(T#2) have the same erasure + T pickOne(Comparable value) throws ExTwo { return null;} + ^ + where T#1,T#2 are type-variables: + T#1 extends Object declared in method pickOne(Comparable) + T#2 extends Comparable declared in method pickOne(T#2) +1 error + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090 public void test011b() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; this.runNegativeTest( new String[] { "Test1.java", @@ -513,18 +579,45 @@ "class ExOne extends Exception {static final long serialVersionUID = 1;}\n" + "class ExTwo extends Exception {static final long serialVersionUID = 2;}" }, - "----------\n" + - "1. WARNING in Test1.java (at line 4)\n" + - " void pickOne2(Test1 c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Type safety: Unchecked invocation pickOne(Comparable) of the generic method pickOne(T) of type Test1\n" + - "----------\n" + - "2. WARNING in Test1.java (at line 4)\n" + - " void pickOne2(Test1 c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + - " ^^^^^^^^^^\n" + - "Comparable is a raw type. References to generic type Comparable should be parameterized\n" + + "----------\n" + + "1. ERROR in Test1.java (at line 2)\n" + + " > void pickOne(T value) throws ExOne {}\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method pickOne(T) has the same erasure pickOne(Comparable) as another method in type Test1\n" + + "----------\n" + + "2. ERROR in Test1.java (at line 3)\n" + + " T pickOne(Comparable value) throws ExTwo { return null;}\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Method pickOne(Comparable) has the same erasure pickOne(Comparable) as another method in type Test1\n" + + "----------\n" + + "3. WARNING in Test1.java (at line 4)\n" + + " void pickOne2(Test1 c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation pickOne(Comparable) of the generic method pickOne(T) of type Test1\n" + + "----------\n" + + "4. WARNING in Test1.java (at line 4)\n" + + " void pickOne2(Test1 c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + + " ^^^^^^^^^^\n" + + "Comparable is a raw type. References to generic type Comparable should be parameterized\n" + "----------\n" ); +/* javac 7 +X.java:3: name clash: pickOne(Comparable) and pickOne(T#2) have the same erasure + T pickOne(Comparable value) throws ExTwo { return null;} + ^ + where T#1,T#2 are type-variables: + T#1 extends Object declared in method pickOne(Comparable) + T#2 extends Comparable declared in method pickOne(T#2) +X.java:4: warning: [unchecked] unchecked method invocation: method pickOne in class Test1 is applied to given types + void pickOne2(Test1 c) throws ExOne { c.pickOne((Comparable) "test"); } + ^ + required: T + found: Comparable + where T is a type-variable: + T extends Comparable declared in method pickOne(T) +1 error +1 warning + */ } public void test012() { this.runConformTest( @@ -1465,8 +1558,7 @@ // variant: having both methods in the same class should not change anything public void test021() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; - this.runConformTest( + this.runNegativeTest( new String[] { "Y.java", "class X {\n" + @@ -1488,77 +1580,173 @@ " }\n" + "}" }, - "true"); + "----------\n" + + "1. WARNING in Y.java (at line 3)\n" + + " public class Y extends X {\n" + + " ^^^^^^\n" + + "The type parameter V should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "2. WARNING in Y.java (at line 4)\n" + + " public static Y make(Class clazz) {\n" + + " ^^^^^^\n" + + "The type parameter W should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "3. ERROR in Y.java (at line 4)\n" + + " public static Y make(Class clazz) {\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Method make(Class) has the same erasure make(Class) as another method in type Y\n" + + "----------\n" + + "4. ERROR in Y.java (at line 8)\n" + + " public static X make(Class clazz) {\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Method make(Class) has the same erasure make(Class) as another method in type Y\n" + + "----------\n" + + "5. WARNING in Y.java (at line 13)\n" + + " Y.make(getClazz());\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Type safety: Unchecked invocation make(Class) of the generic method make(Class) of type Y\n" + + "----------\n" + + "6. WARNING in Y.java (at line 13)\n" + + " Y.make(getClazz());\n" + + " ^^^^^^^^^^\n" + + "Type safety: The expression of type Class needs unchecked conversion to conform to Class\n" + + "----------\n" + + "7. WARNING in Y.java (at line 15)\n" + + " public static Class getClazz() {\n" + + " ^^^^^\n" + + "Class is a raw type. References to generic type Class should be parameterized\n" + + "----------\n" + ); +/* javac 7 +X.java:8: name clash: make(Class) and make(Class) have the same erasure + public static X make(Class clazz) { + ^ + where U,W are type-variables: + U extends Object declared in method make(Class) + W extends String declared in method make(Class) +X.java:13: warning: [unchecked] unchecked conversion + Y.make(getClazz()); + ^ + required: Class + found: Class + where W#1,W#2 are type-variables: + W#1 extends String declared in method make(Class) + W#2 extends String declared in method make(Class) +X.java:13: warning: [unchecked] unchecked method invocation: method make in class Y is applied to given types + Y.make(getClazz()); + ^ + required: Class + found: Class + where W is a type-variable: + W extends String declared in method make(Class) +1 error +2 warnings + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=147647 // variant: using instances triggers raw methods, which are ambiguous public void test022() { // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950 - if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; this.runNegativeTest( - new String[] { - "X.java", - "public class X {\n" + - "}\n" + - "class Y extends X {\n" + - " public Y make(Class clazz) {\n" + - " return new Y();\n" + - " }\n" + - " public X make(Class clazz) {\n" + - " return new X();\n" + - " }\n" + - " public static void main(String[] args) throws Exception {\n" + - " Y y = new Y();\n" + - " y.make(String.class);\n" + - " y.make(getClazz());\n" + - " y.make(getClazz().newInstance().getClass());\n" + - " }\n" + - " public static Class getClazz() {\n" + - " return String.class;\n" + - " }\n" + - "}" - }, - "----------\n" + - "1. WARNING in X.java (at line 3)\n" + - " class Y extends X {\n" + - " ^^^^^^\n" + - "The type parameter V should not be bounded by the final type String. Final types cannot be further extended\n" + - "----------\n" + - "2. WARNING in X.java (at line 4)\n" + - " public Y make(Class clazz) {\n" + - " ^^^^^^\n" + - "The type parameter W should not be bounded by the final type String. Final types cannot be further extended\n" + - "----------\n" + - "3. WARNING in X.java (at line 11)\n" + - " Y y = new Y();\n" + - " ^\n" + - "Y is a raw type. References to generic type Y should be parameterized\n" + - "----------\n" + - "4. WARNING in X.java (at line 11)\n" + - " Y y = new Y();\n" + - " ^\n" + - "Y is a raw type. References to generic type Y should be parameterized\n" + - "----------\n" + - "5. ERROR in X.java (at line 12)\n" + - " y.make(String.class);\n" + - " ^^^^\n" + - "The method make(Class) is ambiguous for the type Y\n" + - "----------\n" + - "6. ERROR in X.java (at line 13)\n" + - " y.make(getClazz());\n" + - " ^^^^\n" + - "The method make(Class) is ambiguous for the type Y\n" + - "----------\n" + - "7. ERROR in X.java (at line 14)\n" + - " y.make(getClazz().newInstance().getClass());\n" + - " ^^^^\n" + - "The method make(Class) is ambiguous for the type Y\n" + - "----------\n" + - "8. WARNING in X.java (at line 16)\n" + - " public static Class getClazz() {\n" + - " ^^^^^\n" + - "Class is a raw type. References to generic type Class should be parameterized\n" + - "----------\n"); + new String[] { + "X.java", + "public class X {\n" + + "}\n" + + "class Y extends X {\n" + + " public Y make(Class clazz) {\n" + + " return new Y();\n" + + " }\n" + + " public X make(Class clazz) {\n" + + " return new X();\n" + + " }\n" + + " public static void main(String[] args) throws Exception {\n" + + " Y y = new Y();\n" + + " y.make(String.class);\n" + + " y.make(getClazz());\n" + + " y.make(getClazz().newInstance().getClass());\n" + + " }\n" + + " public static Class getClazz() {\n" + + " return String.class;\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " class Y extends X {\n" + + " ^^^^^^\n" + + "The type parameter V should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " public Y make(Class clazz) {\n" + + " ^^^^^^\n" + + "The type parameter W should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " public Y make(Class clazz) {\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Method make(Class) has the same erasure make(Class) as another method in type Y\n" + + "----------\n" + + "4. ERROR in X.java (at line 7)\n" + + " public X make(Class clazz) {\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Method make(Class) has the same erasure make(Class) as another method in type Y\n" + + "----------\n" + + "5. WARNING in X.java (at line 11)\n" + + " Y y = new Y();\n" + + " ^\n" + + "Y is a raw type. References to generic type Y should be parameterized\n" + + "----------\n" + + "6. WARNING in X.java (at line 11)\n" + + " Y y = new Y();\n" + + " ^\n" + + "Y is a raw type. References to generic type Y should be parameterized\n" + + "----------\n" + + "7. WARNING in X.java (at line 12)\n" + + " y.make(String.class);\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The method make(Class) belongs to the raw type Y. References to generic type Y should be parameterized\n" + + "----------\n" + + "8. WARNING in X.java (at line 13)\n" + + " y.make(getClazz());\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The method make(Class) belongs to the raw type Y. References to generic type Y should be parameterized\n" + + "----------\n" + + "9. WARNING in X.java (at line 14)\n" + + " y.make(getClazz().newInstance().getClass());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Type safety: The method make(Class) belongs to the raw type Y. References to generic type Y should be parameterized\n" + + "----------\n" + + "10. WARNING in X.java (at line 16)\n" + + " public static Class getClazz() {\n" + + " ^^^^^\n" + + "Class is a raw type. References to generic type Class should be parameterized\n" + + "----------\n" + ); +/* javac 7 +X.java:7: name clash: make(Class) and make(Class) have the same erasure + public X make(Class clazz) { + ^ + where U,W are type-variables: + U extends Object declared in method make(Class) + W extends String declared in method make(Class) +X.java:12: warning: [unchecked] unchecked call to make(Class) as a member of the raw type Y + y.make(String.class); + ^ + where W is a type-variable: + W extends String declared in method make(Class) +X.java:13: warning: [unchecked] unchecked call to make(Class) as a member of the raw type Y + y.make(getClazz()); + ^ + where W is a type-variable: + W extends String declared in method make(Class) +X.java:14: warning: [unchecked] unchecked call to make(Class) as a member of the raw type Y + y.make(getClazz().newInstance().getClass()); + ^ + where W is a type-variable: + W extends String declared in method make(Class) +1 error +3 warnings + */ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=159711 public void test023() {