Community
Participate
Working Groups
public class BaseObject { public <T extends BaseObject> Constructor<T> ctor() {return null;} static <T extends BaseObject> T f1() throws Exception{ return new BaseObject().<T>ctor().newInstance(new Object[0]); } static <T extends BaseObject> T f2() throws Exception { return f1(); } } Eclipse allows f2() line to return without error. javac 1.5.0_02 returns this error C:\dev\142\workspace\zreduction>\dev\tools\win32\jdk\jdk1.5.0_02\bin\javac BaseO bject.java BaseObject.java:17: type parameters of <T>T cannot be determined; no unique maximal instance exists for type variable T with upper bounds T,BaseObject return f1(); It's fixed if you replace the line with return BaseObject.<T>f1(); Not sure if it's an eclipse or a javac bug, but it is a difference.
Simpler testcase: public class X { <T extends X> T f1() throws Exception{ return null; } <U extends X> U f2() throws Exception { return f1(); } } Inference should realize that <U>f1() is the proper substitute for generic method. Note that when explicitly qualifying it works well as well. Closing as javac bug. Adding regression test: GenericTypeTest#test765
*** Bug 158519 has been marked as a duplicate of this bug. ***
>Verified reproduced in JDK 1.6.0_21 >Verified fixed in JDK 1.6.0_22 (and 1.6.0_27) http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302954
> A more systematic test on each release reveals 1.6.0_22 = broken (bug with same exception says fixed) 1.6.0_23 = broken 1.6.0_24 = broken 1.6.0_25 = OK 1.6.0_26 = OK 1.6.0_27 = OK