Community
Participate
Working Groups
Build Identifier: 3.6 Helios 20100617-1415 This code does not compile in Eclipse, though javac has no problem with it: import java.io.Serializable; public class Test { public static void main(String[] args) { createObject(); } private static <T extends Comparable<?> & Serializable> T createObject() { return null; } } The error is on the invocation of the method: Bound mismatch: The generic method createObject() of type Test is not applicable for the arguments (). The inferred type Comparable<?> is not a valid substitute for the bounded parameter <T extends Comparable<?> & Serializable> Reproducible: Always Steps to Reproduce: 1. Create a java class with the above code
javac5 does not compile this: Test.java:6: type parameters of <T>T cannot be determined; no unique maximal ins tance exists for type variable T with upper bounds java.lang.Object,java.lang.Co mparable<?>,java.io.Serializable createObject(); ^ 1 error Nor does javac6: Test.java:6: type parameters of <T>T cannot be determined; no unique maximal ins tance exists for type variable T with upper bounds java.lang.Object,java.lang.Co mparable<?>,java.io.Serializable createObject(); ^ [total 313ms] 1 error Javac7 compiles it alright though. Will, what version of javac did you try it with ?
(In reply to comment #1) > Will, what version of javac did you try it with ? Ah, my company uses OpenJDK and this was openjdk6 which is actually a descendent of the sun jdk 7 (http://openjdk.java.net/projects/jdk6/)! Feel free to close the bug if you don't need to support openjdk6. The workaround I used was to wrap in a generic type parameterized by T which implemented the multiple interfaces.
(In reply to comment #2) > Feel free to close the bug if you don't need to support openjdk6. It may not be as simple as that, we need to get to understand why the behavior change occurred at JDK7 and see if eclipse has to react suitably. Olivier, Can you help with identifying the earliest JDK7 build where this code has started compiling ? > The workaround I used was to wrap in a generic type parameterized by T which > implemented the multiple interfaces. Thanks.
> Olivier, Can you help with identifying the earliest JDK7 build > where this code has started compiling ? Frederic, since Olivier is away, can you please help with check ? TIA.
(In reply to comment #4) > > Olivier, Can you help with identifying the earliest JDK7 build > > where this code has started compiling ? > > Frederic, since Olivier is away, can you please help > with check ? TIA. This code started to compile with build 1.7.0-ea-b32 and it still failed with build 1.7.0-ea-b27. I have no other JDK7 build versions between b27 and b32 to be more precise...
(In reply to comment #5) > (In reply to comment #4) > > > Olivier, Can you help with identifying the earliest JDK7 build > > > where this code has started compiling ? > > > > Frederic, since Olivier is away, can you please help > > with check ? TIA. > > This code started to compile with build 1.7.0-ea-b32 and it still failed with > build 1.7.0-ea-b27. I have no other JDK7 build versions between b27 and b32 to > be more precise... Sorry, I mixed the version forget my previous comment... :-S In fact this code started to compile with build 1.7.0-ea-b27 and it failed with build 1.7.0-ea-b25.
I know what is the problem here, it too late for 3.7, but I'll include a fix for a subsequent release.
Closing this bug as a duplicate of bug 341795. I'll carry over the test case from here into a junit for that bug. *** This bug has been marked as a duplicate of bug 341795 ***