Bug 43429 - AbstractMethodError calling clone() at runtime when using Eclipse compiler
Summary: AbstractMethodError calling clone() at runtime when using Eclipse compiler
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 44687 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-09-22 10:36 EDT by Stephen Summerfield CLA
Modified: 2003-10-15 05:59 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Summerfield CLA 2003-09-22 10:36:55 EDT
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();
	}
}
Comment 1 Olivier Thomann CLA 2003-09-22 10:42:16 EDT
This seems to be fixed in 3.0 stream.
Comment 2 Philipe Mulet CLA 2003-09-22 12:17:12 EDT
Suspect this to be the same as bug 40442.
Comment 3 Philipe Mulet CLA 2003-09-22 12:40:11 EDT
Actually, I cannot reproduce this bug using 2.1.1 either.

What settings are you using ? Which exact build number are you using ? 
Comment 4 Stephen Summerfield CLA 2003-09-22 14:56:08 EDT
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.
Comment 5 Stephen Summerfield CLA 2003-09-23 06:05:29 EDT
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).
Comment 6 Stephen Summerfield CLA 2003-09-23 06:13:37 EDT
I get the same problem with Eclipse 3.0.0 build 200308281813 when using Java 
1.4.0.
Comment 7 Stephen Summerfield CLA 2003-09-23 06:17:52 EDT
Seems to occur when setting 'Compiler compliance level' to 1.4 (1.3 is ok).
Comment 8 Philipe Mulet CLA 2003-09-23 06:32:11 EDT
Feels like a VM issue then. Did you try to compile with javac 1.4.2 and run 
with VM 1.4.0 ?
Comment 9 Philipe Mulet CLA 2003-09-23 06:33:53 EDT
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.

Comment 10 Stephen Summerfield CLA 2003-09-23 08:11:49 EDT
>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).
Comment 11 Philipe Mulet CLA 2003-09-23 09:48:00 EDT
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
Comment 12 Philipe Mulet CLA 2003-09-23 10:10:19 EDT
Jikes does agree with us (fix up declaring class of target method to match 
interface receiver type).

Comment 13 Philipe Mulet CLA 2003-09-23 10:24:57 EDT
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.
Comment 14 Philipe Mulet CLA 2003-10-15 05:59:42 EDT
*** Bug 44687 has been marked as a duplicate of this bug. ***