Community
Participate
Working Groups
Noticed while working on AspectJ bug 95344, /////////////////////////////// with the following code interface Main$1 {void hello();} public class Main{ public static void main(String [] args){ Main$1 anon = new Main$1() {public void hello(){System.out.println("hello world!");}}; anon.hello(); } } ////////////////////////////////////////////////// javac produces the files: Main$1.class Main$2.class Main.class and when Main is ran it says: hello world! jdt in Eclipse 3.1RC1 produces the files: Main$1.class Main.class and when Main is ran it says: Exception in thread "main" java.lang.ClassCircularityError: Main$1 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 Main.main(Main.java:5)
and now when I try running it it says Exception in thread "main" java.lang.InstantiationError: Main$1 at Main.main(Main.java:5) weird. Also: having compiled the file in javac, the file Main$2.class contains the string "hello world", having compiled the file in Eclipse, none of the classfiles contain the string "hello world".
quite clear whats going on, JDT is trying to put both the inner class and the interface in the file "Main$1.class"
would also be nice if jdt gave a compile time error on this: //////////////////////////////////////////// interface Main$A {void hello();} public class Main{ public static class A {void hello(){System.out.println("hello world");}} public static void main(String [] args){ Main.A a = new Main.A(); a.hello(); } } //////////////////////////////////////////// like javac does, rather than giving a confusing runtime java.lang.InstantiationError at line 6
The problem comes from the fact that when we compute the anonymous name we don't check existing top level or member types.
One solution would be to compute the constant pool name through a factory for all type bindings, not just the local type bindings.
is there any schedule for fixing this in 3.2? Thks, A.
Let's try for 3.2m4.
*** Bug 188167 has been marked as a duplicate of this bug. ***
Created attachment 71215 [details] Proposed patch This should do the trick
Philippe - did u see the patch ?
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.