Community
Participate
Working Groups
Build ID: I20061214-1445 Java Version: 6.0 Eclipse 3.3 M4 introduced a bug in the compiler, which results in an AbstractMethodError at runtime. However, the affected code worked before, and the compiler doesn't complain anything at compile time. The following code reproduces the error: package bugs; public class AbstractMethodErrorBug { public static interface IListEntry { } public static interface IExtendedListEntry extends IListEntry { } public static interface IList { IListEntry getEntry(int index); } public static interface IExtendedList extends IList { IExtendedListEntry getEntry(int index); } public static class ExtendedList implements IExtendedList { public IExtendedListEntry getEntry(int index) { return null; } } private IList list = new ExtendedList(); public AbstractMethodErrorBug() { } public void testAbstractMethodErrorBug() { list.getEntry(0); // causes an AbstractMethodError System.out.println("Bug has been fixed :-)"); } public static void main(String[] args) { new AbstractMethodErrorBug().testAbstractMethodErrorBug(); } }
The bug has been introduced between 3.3M3 and 3.3M4.
I got a similar problem with my projects. I assume that it is caused by the same issue. There is my test class to reproduce the error: public class Test { public interface IProperty { public String getValue(); } public interface IPropertyContainer { public IProperty getProperty(); } public static class EntityProperty implements IProperty { public String getValue() { return "test"; } } public interface IEntity extends IPropertyContainer { public EntityProperty getProperty(); } public static abstract class AbstractEntity implements IEntity { public EntityProperty getProperty() { return new EntityProperty(); } } public static class Entity extends AbstractEntity { } public static void main( String[] args ) { IEntity entity = new Entity(); System.out.println("value="+entity.getProperty().getValue()); IPropertyContainer container = entity; System.out.println("value="+container.getProperty().getValue()); } }
v_722 compiles it fine and v_723 fails. This narrows down when the problem was introduced.
Will investigate.
Released InnerEmulationTest#133 and 134 (inactive) in HEAD. Considering test133 test case, we miss a bridge method in X$Y.class, which was properly generated until v_723.
Released InnerEmulationTest#133 and 134 (active) in R3_2_maintenance.
This is a regression introduced by the fix for bug 162073. In fact, we must delay the elimination from the inherited methods of the interface methods that are implemented, so as to enable the bridge methods generation. The more recent fix for bug 161541 eliminates duplicates later in the process (to fulfill other needs), which happens to fix bug 162073 as well, modulo a few changes in error messages. I will revert the change for bug 162073 and clarify the semantics of isInterfaceMethodImplemented, fix the error messages and see where we get.
Erratum: bug 162073 is *not* fixed if I remove the change. Need to be more cautious here. There is a tension between the needs of method verification (namely catch truly incompatible return types) and of bridge methods generation (need a bridge method if the return type is compatible but different).
Created attachment 56701 [details] Fix plus test cases activation This fix does the following: - it reverts to v_722 for the construction of the inheritedMethods collection (in the method verifier); - while verifying the inherited methods in MethodVerifier15#checkInheritedMethods, it suppresses overriden methods from implemented/inherited interfaces before delegating the ultimate checks to MethodVerifier#checkInheritedMethods. Currently under test.
Created attachment 56796 [details] Fix + test cases - improved This fix builds upon the ideas of the first one, and especially gets rid of the initial fix for bug 162073, but: - eliminates overridden methods later, and only does so for a specific check (does not keep the results for further use); - uses a better criterion to eliminate the overridden methods.
Released for 3.3 M5.
Created attachment 56896 [details] Smaller fix only addresses regression Reopening bug 162073, and simply reverting its changes.
Verified for 3.3 M5 using warm-up build I20070205-0009
*** Bug 173477 has been marked as a duplicate of this bug. ***
Works fine again in 3.3 M5. Thank you very much!
*** Bug 176528 has been marked as a duplicate of this bug. ***