Bug 77349 - [compiler] ClassFormatError when accessing clone() or finalize() methods from an interface
Summary: [compiler] ClassFormatError when accessing clone() or finalize() methods from...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-31 14:09 EST by Olivier Thomann CLA
Modified: 2005-03-30 18:53 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2004-10-31 14:09:42 EST
Compiling the following code and running it result in a ClassFormatError.

Exception in thread "main" java.lang.ClassFormatError: Method access$0 in class
I has illegal modifiers: 0x1008
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

interface I extends Cloneable {
    class Inner {
        Object bar(I i) {
            try {
                return i.clone();
            } catch (CloneNotSupportedException e) {
                return null;
            }
        }
    }
}

public class X implements I {
	public static void main(String[] args) {
	}
}

Compiled with javac 1.5.0, this returns:
X.java:5: cannot find symbol
symbol  : method clone()
location: interface I
                return i.clone();
                        ^
1 error

jikes 1.22 reports:

Found 1 semantic error compiling "C:/tests_sources/X.java":

     5.                 return i.clone();
                               ^-------^
*** Semantic Error: The method "java.lang.Object clone() throws
java.lang.CloneNotSupportedException;" only has protected access in
"java.lang.Object"
, so it is not accessible from an interface.
Comment 1 Olivier Thomann CLA 2005-02-11 14:44:27 EST
Extracting the Inner class outside of the interface I works fine. We do report
an error.
We should never end up adding a synthetic method on an interface.
Comment 2 Kent Johnson CLA 2005-03-14 17:45:50 EST
Since 1.4 only public methods from Object are visible to an interface

Added test099 to Compliance_1_3/4/5
Comment 3 Olivier Thomann CLA 2005-03-30 18:53:37 EST
Verified in 20050330-0500