Community
Participate
Working Groups
Incorrectly, a class TestImpl<T>, implementing an abstract method g(T[]) in the superclass AbstractTest<T>, is reported to not implement AbstractTest<T>.g(Object[]). Notice that the compiler are looking for the wrong signature. The error message goes away if Project > Clean... is choosen on the menubar. But as soon as the file is saved again, the error message comes back. Below I include example code to replicate this bug. The files compile without warningfs or errors with Sun's JDK. (Occasionally, I have also noticed that editing another file also bring back the error message, but I have not figured out how to replicate this fault.) I have also filed another bug probably related to this one. --- AbstractTest.java ------------------------------------------------ public abstract class AbstractTest<T> { public void doTest(T[] a) { g(a); } protected abstract void g(T[] a); } --- TestImpl.java ----------------------------------------------------- import java.util.Arrays; // As soon as I save this file, Eclipse complains that "The type TestImpl<T> // must implement the inherited abstract method AbstractTest<T>.g(Object[])". // I can remove this error by choosing Project > Clean... from the menubar, // but it comes back as soons as I save this file again. public class TestImpl<T> extends AbstractTest<T> { protected void g(T[] a) { System.out.println(Arrays.toString(a)); } } --- Main.java -------------------------------------------------------- public class Main { public static void main(String[] args) { AbstractTest<Integer> test=new TestImpl<Integer>(); Integer[] integers=new Integer[10]; for(int i=0; i<10; ++i) integers[i]=i; test.doTest(integers); } }
See also bug 81721.
This is a problem with how we write out array types of Type Variables. This case works fine if the 2 types are in the same source file: public abstract class AbstractTest<T> { abstract void array(T[] a); abstract void type(T a); } class Test<T> extends AbstractTest<T> { void array(T[] a) {} void type(T a) {} } But put Test in its own file & save it (picking AbstractTest up as a binary type), and it reports that the method array(T[]) does not override AbstractTest.array(Object[]). The binaryType for AbstractTest is seeing array(Object[]) and not array(T[]). The method's generic signature should be '([TT;)V' but its not set, so we pick it up as '([Ljava/lang/Object;)V'
Indeed, we did not record the method as requiring a generic signature, due to array type. Same issue for field&method return types. Added GenericTypeTest#test455
*** Bug 82497 has been marked as a duplicate of this bug. ***
*** Bug 82002 has been marked as a duplicate of this bug. ***
*** Bug 79145 has been marked as a duplicate of this bug. ***
Verified in I20040214