compiler bug with extension and generics? [message #856174] |
Wed, 25 April 2012 12:43 |
Missing name Missing name Messages: 3 Registered: June 2010 |
Junior Member |
|
|
I'm getting lines flagged as red with the following test case, but the project compiles. It fails when the following top level classes are defined:
SomeInterface.java:
public interface SomeInterface<R> {
R someMethod();
}
SomeAbstractClass.java:
public abstract class SomeAbstractClass<R> {
public abstract void someMethod2(final SomeInterface<R> cb);
}
SomeExtendingClass.java:
public class SomeExtendingClass extends SomeAbstractClass<byte[]> {
@Override
public void someMethod2(final SomeInterface<byte[]> cb) {
}
}
What happens is:
1) The class SomeExtendingClass is marked with a red line and hovering over it says:
The type SomeExtendingClass must implement the inherited abstract method SomeAbstractClass<byte[]>.someMethod2(SomeInterface)
2) The method someMethod2 is marked with a red line and hovering over it says:
Name clash: The method someMethod2(SomeInterface<byte[]>) of type SomeExtendingClass has the same erasure as someMethod2(SomeInterface) of type SomeAbstractClass<R> but does not override it
Notes:
- It doesn't seem to prevent the project from compiling, and the errors do not show up in "Markers".
- Compiling these three files from the command line with javac succeeds.
- If these three classes are placed inside an enclosing class as inner classes, rather than top-level classes, it doesn't happen, i.e. this succeeds:
public final class ErasureTest {
public interface SomeInnerInterface<R> {
R someMethod3();
}
public abstract class SomeInnerAbstractClass<T> {
public abstract void someMethod4(final SomeInnerInterface<T> cb);
}
public class SomeInnerExtendingClass extends SomeInnerAbstractClass<byte[]> {
@Override
public void someMethod4(final SomeInnerInterface<byte[]> cb) {
}
}
}
Configuration:
I'm running Eclipse Indigo SR2 (20120216-1857) on OS/X Lion with the default Mac JRE system library (1.6.0_31-b04-415-11M3635).
Before I post this as an Eclipse bug, am I missing something?
[Updated on: Wed, 25 April 2012 12:46] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03285 seconds