### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v retrieving revision 1.109 diff -u -r1.109 MethodVerifier15.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 19 Feb 2010 10:14:13 -0000 1.109 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 22 Feb 2010 09:40:39 -0000 @@ -130,8 +130,11 @@ problemReporter().unsafeReturnTypeOverride(concreteMethod, originalInherited, this.type); // check whether bridge method is already defined above for interface methods + // skip generation of bridge method for current class & method if an equivalent + // bridge will be/would have been generated in the context of the super class since + // the bridge itself will be inherited. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=298362 if (originalInherited.declaringClass.isInterface()) { - if ((concreteMethod.declaringClass == this.type.superclass && this.type.superclass.isParameterizedType()) + if ((concreteMethod.declaringClass == this.type.superclass && this.type.superclass.isParameterizedType() && !areMethodsCompatible(concreteMethod, originalInherited)) || this.type.superclass.erasure().findSuperTypeOriginatingFrom(originalInherited.declaringClass) == null) this.type.addSyntheticBridgeMethod(originalInherited, concreteMethod.original()); } #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.196 diff -u -r1.196 MethodVerifyTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 11 Nov 2009 05:38:49 -0000 1.196 +++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 22 Feb 2010 09:40:47 -0000 @@ -10731,4 +10731,101 @@ "Name clash: The method put(K, V) of type OverrideBug has the same erasure as put(K, V) of type Map but does not override it\n" + "----------\n"); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=298362 +public void test205() { + this.runConformTest( + new String[] { + "Tester.java", + "import java.lang.reflect.Method;\n" + + "\n" + + "public class Tester {\n" + + "\n" + + " public static interface Converter {\n" + + " T convert(String input);\n" + + " }\n" + + "\n" + + " public static abstract class EnumConverter> implements Converter> {\n" + + " public final T convert(String input) {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "\n" + + " public static class SomeEnumConverter extends EnumConverter {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) throws Exception {\n" + + " Method m = SomeEnumConverter.class.getMethod(\"convert\", String.class);\n" + + " System.out.println(m.getGenericReturnType());\n" + + " }\n" + + "\n" + + "}\n" + + }, + "T"); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=298362 (variation) +public void test206() { + this.runConformTest( + new String[] { + "Tester.java", + "import java.lang.reflect.Method;\n" + + "\n" + + "public class Tester {\n" + + "\n" + + " public static interface Converter {\n" + + " T convert(String input);\n" + + " }\n" + + "\n" + + " public static abstract class EnumConverter> implements Converter {\n" + + " public final T convert(String input) {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "\n" + + " public static class SomeEnumConverter extends EnumConverter {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) throws Exception {\n" + + " Method m = SomeEnumConverter.class.getMethod(\"convert\", String.class);\n" + + " System.out.println(m.getGenericReturnType());\n" + + " }\n" + + "\n" + + "}\n" + + }, + "T"); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=298362 (variation) +// Note that this test prints "T" with javac5 and "class java.lang.Object with javac 6,7 +public void test207() { + this.runConformTest( + new String[] { + "Tester.java", + "import java.lang.reflect.Method;\n" + + "\n" + + "public class Tester {\n" + + "\n" + + " public static interface Converter {\n" + + " T convert(String input);\n" + + " }\n" + + "\n" + + " public static abstract class EnumConverter, K> implements Converter {\n" + + " public final T convert(K input) {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "\n" + + " public static class SomeEnumConverter extends EnumConverter {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) throws Exception {\n" + + " Method m = SomeEnumConverter.class.getMethod(\"convert\", String.class);\n" + + " System.out.println(m.getGenericReturnType());\n" + + " }\n" + + "\n" + + "}\n" + + }, + "class java.lang.Object"); +} }