### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.379 diff -u -r1.379 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 19 Nov 2010 14:22:00 -0000 1.379 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 2 Dec 2010 05:48:24 -0000 @@ -2842,13 +2842,21 @@ int oneParamsLength = oneParams.length; int twoParamsLength = twoParams.length; if (oneParamsLength == twoParamsLength) { + /* Below 1.5, discard any generics we have left in for the method verifier's benefit, (so it + can detect method overriding properly in the presence of generic super types.) This is so + as to allow us to determine whether we have been handed an acceptable method in 1.4 terms + without all the 1.5ism below kicking in and spoiling the party. + See https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 + */ + boolean applyErasure = environment().globalOptions.sourceLevel < ClassFileConstants.JDK1_5; next : for (int i = 0; i < oneParamsLength; i++) { - TypeBinding oneParam = oneParams[i]; - TypeBinding twoParam = twoParams[i]; + TypeBinding oneParam = applyErasure ? oneParams[i].erasure() : oneParams[i]; + TypeBinding twoParam = applyErasure ? twoParams[i].erasure() : twoParams[i]; if (oneParam == twoParam || oneParam.isCompatibleWith(twoParam)) { if (two.declaringClass.isRawType()) continue next; - TypeBinding originalTwoParam = two.original().parameters[i].leafComponentType(); + TypeBinding leafComponentType = two.original().parameters[i].leafComponentType(); + TypeBinding originalTwoParam = applyErasure ? leafComponentType.erasure() : leafComponentType; switch (originalTwoParam.kind()) { case Binding.TYPE_PARAMETER : if (((TypeVariableBinding) originalTwoParam).hasOnlyRawBounds()) #P org.eclipse.jdt.core.tests.compiler 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.220 diff -u -r1.220 MethodVerifyTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 1 Dec 2010 23:36:47 -0000 1.220 +++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 2 Dec 2010 05:48:27 -0000 @@ -11533,8 +11533,8 @@ false, compilerOptions14); } -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 -public void _test331446() { +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 +public void test331446() { Map compilerOptions15 = getCompilerOptions(); compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5); compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); @@ -11573,9 +11573,6 @@ null); Map compilerOptions14 = getCompilerOptions(); -// compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); -// compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); -// compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2); compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); @@ -11606,20 +11603,38 @@ compilerOptions14, null); } -public void test1415Mix() { +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 +public void test331446a() { Map compilerOptions15 = getCompilerOptions(); - compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5); - compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); - compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_4); + compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); + compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4); this.runConformTest( new String[] { - "Abstract.java", - "abstract class Generic {\n" + - " abstract void foo(T t);\n" + - "}\n" + - "public abstract class Abstract extends Generic {\n" + - "}" - }, + "Test.java", + "import java.util.Comparator;\n" + + "import java.util.List;\n" + + "\n" + + "public class Test {\n" + + " public static void assertEquals(String message,\n" + + " Comparator comparator, List expected, List actual) {\n" + + " if (expected.size() != actual.size()) {\n" + + " //failNotEquals(message, expected, actual);\n" + + " }\n" + + " for (int i = 0, l = expected.size(); i < l; i++) {\n" + + " assertEquals(message, comparator, expected.get(i), actual.get(i));\n" + + " }\n" + + " }\n" + + " public static void assertEquals(String message,\n" + + " Comparator comparator, Object expected, Object actual) {\n" + + " if (comparator.compare(expected, actual) == 0) {\n" + + " return;\n" + + " }\n" + + " //failNotEquals(message, expected, actual);\n" + + " }\n" + + "}\n" + + "" + }, "", null, true, @@ -11632,64 +11647,34 @@ compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE); - this.runNegativeTest( - new String[] { - "Concrete.java", - "public class Concrete extends Abstract {\n" + - "}", - }, - "----------\n" + - "1. ERROR in Concrete.java (at line 1)\n" + - " public class Concrete extends Abstract {\n" + - " ^^^^^^^^\n" + - "The type Concrete must implement the inherited abstract method Generic.foo(String)\n" + - "----------\n", - null, - false, - compilerOptions14); -} -public void test1415Mix2() { - Map compilerOptions15 = getCompilerOptions(); - compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5); - compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); - compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); this.runConformTest( new String[] { - "Abstract.java", - "abstract class Generic {\n" + - " abstract void foo(T t);\n" + - "}\n" + - "public abstract class Abstract extends Generic {\n" + - "}" - }, + "X.java", + "import java.util.ArrayList;\n" + + "import java.util.Comparator;\n" + + "\n" + + "public class X {\n" + + " public static void testAmbiguity() {\n" + + " Comparator comparator = new Comparator() {\n" + + " \n" + + " public int compare(Object o1, Object o2) {\n" + + " return 0;\n" + + " }\n" + + " };\n" + + " Test.assertEquals(\"Test\", comparator, new ArrayList(), new ArrayList());\n" + + " }\n" + + "}\n" + + "", + }, "", null, - true, + false, null, - compilerOptions15, + compilerOptions14, null); - - Map compilerOptions14 = getCompilerOptions(); - compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2); - compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); - compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); - compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE); - this.runConformTest( - new String[] { - "Concrete.java", - "public class Concrete extends Abstract {\n" + - " void foo(String s) {}\n" + - "}", - }, - "", - null, - false, - null, - compilerOptions14, - null); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 (all 1.4) -public void test331446a() { +public void test331446b() { Map compilerOptions14 = getCompilerOptions(); compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_4); compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); @@ -11727,7 +11712,7 @@ null); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 (1.4/1.5 mix) -public void _test331446b() { +public void test331446c() { Map compilerOptions15 = getCompilerOptions(); compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5); compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); @@ -11770,7 +11755,7 @@ null); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 (all 1.5) -public void test331446c() { +public void test331446d() { Map compilerOptions15 = getCompilerOptions(); compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5); compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); @@ -11806,4 +11791,88 @@ compilerOptions15, null); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 +public void test1415Mix() { + Map compilerOptions15 = getCompilerOptions(); + compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + this.runConformTest( + new String[] { + "Abstract.java", + "abstract class Generic {\n" + + " abstract void foo(T t);\n" + + "}\n" + + "public abstract class Abstract extends Generic {\n" + + "}" + }, + "", + null, + true, + null, + compilerOptions15, + null); + + Map compilerOptions14 = getCompilerOptions(); + compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2); + compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); + compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); + compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE); + this.runNegativeTest( + new String[] { + "Concrete.java", + "public class Concrete extends Abstract {\n" + + "}", + }, + "----------\n" + + "1. ERROR in Concrete.java (at line 1)\n" + + " public class Concrete extends Abstract {\n" + + " ^^^^^^^^\n" + + "The type Concrete must implement the inherited abstract method Generic.foo(String)\n" + + "----------\n", + null, + false, + compilerOptions14); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 +public void test1415Mix2() { + Map compilerOptions15 = getCompilerOptions(); + compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); + compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + this.runConformTest( + new String[] { + "Abstract.java", + "abstract class Generic {\n" + + " abstract void foo(T t);\n" + + "}\n" + + "public abstract class Abstract extends Generic {\n" + + "}" + }, + "", + null, + true, + null, + compilerOptions15, + null); + + Map compilerOptions14 = getCompilerOptions(); + compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2); + compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); + compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); + compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE); + this.runConformTest( + new String[] { + "Concrete.java", + "public class Concrete extends Abstract {\n" + + " void foo(String s) {}\n" + + "}", + }, + "", + null, + false, + null, + compilerOptions14, + null); +} } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java,v retrieving revision 1.163 diff -u -r1.163 ReconcilerTests.java --- src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 1 Dec 2010 22:00:43 -0000 1.163 +++ src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 2 Dec 2010 05:48:30 -0000 @@ -5227,7 +5227,7 @@ deleteProject(project14); } } -public void _testGenericAPIUsageFromA14Project9() throws CoreException { +public void testGenericAPIUsageFromA14Project9() throws CoreException { IJavaProject project14 = null; IJavaProject project15 = null; try {