Community
Participate
Working Groups
Build ID: I20070625-1500 Steps To Reproduce: Build ID: I20070625-1500 Steps To Reproduce: The class below compiles with eclipse but not with javac. jdk1.5.0_13, WINXP, Eclipse 3.2.0 public class Test { public interface Loader{ public <T extends Integer, K extends String> T load(final K key); } Loader loader; /** * Gets a single data set. Tries to find it in the cache first. * * @param <K> * @param <T> * @param key * @return * @throws ComoException */ public <K extends String, T extends Integer> T get(final K key) { T data = this.loader.load(key); return null; } More information: More information:
correction: I'm working with Eclipse 3.3.0 (not 3.2.0)
Also reproduced with 3.4M3. The javac output is: java version "1.5.0_13" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b01) Java HotSpot(TM) Client VM (build 1.5.0_13-b01, mixed mode) Test.java:22: type parameters of <T>T cannot be determined; no unique maximal instance exists for type variable T with upper bounds T,java.lang.Integer T data = this.loader.load(key); ^ 1 error
javac 1.6.0_03 complains as well, javac 7 does not.
This feels like a bug in javac, which would have been corrected in more recent versions. The assignment to a type variable (T) seems to cause javac some grief when inferring from expected type (JLS 15.12.2.8).
I believe the known javac bug is http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5042462 Closing as invalid. We are already doing the right thing. Added GenericTypeTest#test1212
Tests are in GenericTypeTest#1214 and 1215 indeed.
Verified for 3.4M4 using build I20071210-1800.