Community
Participate
Working Groups
Build 200411050810 The following code can be compiled with javac, but the line return m_manager.getById(getClass(), new Integer(1)); produces this compile error in Eclipse: Bound mismatch: The generic method getById(Class<T>, Integer) of type Test<C>.Manager<C> is not applicable for the arguments (Class<? extends Test<C>>, Integer) since the type ? extends Test<C> is not a valid substitute for the bounded parameter <T extends ITest<C>> public class TestCtx { } public interface ITest<C extends TestCtx> { } abstract public class Test<C extends TestCtx> implements ITest<C> { protected Manager<C> m_manager; public ITest<C> get() { return m_manager.getById(getClass(), new Integer(1)); } public static class Manager<C extends TestCtx> { public <T extends ITest<C>> T getById(Class<T> cls, Integer id) { return null; } } }
Generic method should also substitute according to their declaring class (if parameterized type). Added regression test: GenericTypeTest#test394. Fixed
Compile without an error now. Verified in 200412140800
Eclipse 3.1 report bound mismatch on Enum_.java in Retrotranslator(http://retrotranslator.sourceforge.net/), but it can be compiled by SUN JDK. Following is a simplified version to reproduce the bug. public abstract class BoundMismatch<C extends BoundMismatch<C>> { public static <T extends BoundMismatch<T>> T getDefault(Class<T> clz){ return null; } public Object getDefault(){ return getDefault(getClass()); } }
The present bug report describes another issue than the last added comment. If you still want it to be considered, then please open a separate bug for it.
Entered bug 123078 since I investigated a fix in the meantime.