Community
Participate
Working Groups
The simple program below illustrates the problem. There seems to be a problem in the class files generated by the Eclipse compiler, calling clone() on an object via a reference declared as an extension interface of an interface that specifies the public clone() method, fails at runtime with an AbstractMethodError. However compiling with JDK1.4.2 and it's ok. public class Test { public interface Copyable extends Cloneable { public Object clone() throws CloneNotSupportedException; } public interface TestIf extends Copyable { } public static class ClassA implements Copyable { public Object clone() throws CloneNotSupportedException { return super.clone(); } } public static class ClassB implements TestIf { public Object clone() throws CloneNotSupportedException { return super.clone(); } } public static void main(String[] args) throws Exception { Copyable o1 = new ClassA(); ClassB o2 = new ClassB(); TestIf o3 = o2; Object clonedObject; clonedObject = o1.clone(); clonedObject = o2.clone(); // The following line fails at runtime with AbstractMethodError when compiled with Eclipse clonedObject = o3.clone(); } }
This seems to be fixed in 3.0 stream.
Suspect this to be the same as bug 40442.
Actually, I cannot reproduce this bug using 2.1.1 either. What settings are you using ? Which exact build number are you using ?
Hmmn just got home, tried it with a 2.1.1 build 200306271545 and I don't get the problem either. I'll have to confirm the build number of the system with the problem back at work tomorrow - thought it was the same though.
Ok, the version of Eclipse with the problem /is/ the same (ie 2.1.1 build 200306271545) however the version of Java used to run the program is different (1.4.2 is ok, 1.4.0 build 1.4.0-b92 is not). Incidently I tried an older version of Eclipse 2.0.2 and that had the same problem (with Java 1.4.0).
I get the same problem with Eclipse 3.0.0 build 200308281813 when using Java 1.4.0.
Seems to occur when setting 'Compiler compliance level' to 1.4 (1.3 is ok).
Feels like a VM issue then. Did you try to compile with javac 1.4.2 and run with VM 1.4.0 ?
Also, to explain difference in between 1.3 and 1.4 mode, from 1.4 on, the compiler is no longer generating default abstract methods (on abstract classes), thus interface (abstract) methods are used as is and inducing subtle differences.
>Feels like a VM issue then. Did you try to compile with javac 1.4.2 and run >with VM 1.4.0 ? Yes, it works fine (when compiled with and without the '-source 1.4' flag).
Reproduced. Seems like we are changing the declaring class to be the receiver type in presence of an interface receiver type, where javac doesn't do so. Investigating
Jikes does agree with us (fix up declaring class of target method to match interface receiver type).
Looks at javac bug database, this appears to be a VM1.4.0 bug for which they did workaround. See: http://developer.java.sun.com/developer/bugParade/bugs/4398789.html and referenced defects. No action planned. Closing as VM bug.
*** Bug 44687 has been marked as a duplicate of this bug. ***