Bug 108856 - [1.5][compiler] Inner inner classes have illegal names
Summary: [1.5][compiler] Inner inner classes have illegal names
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.1.2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 114266 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-09-06 13:33 EDT by Erling Ellingsen CLA
Modified: 2006-01-10 10:30 EST (History)
1 user (show)

See Also:


Attachments
Proposed fix (938 bytes, patch)
2005-09-29 16:48 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Erling Ellingsen CLA 2005-09-06 13:33:53 EDT
According to the java language spec (section 13.1), an anonymous class inside an anonymous class 
should be named Foo$n$n, not Foo$n as is done by the eclipse compiler (the class name should be the 
*immediately* enclosing class, $, number). This causes Class.getSimpleName() to throw an 
exception, which can cause all kinds of interesting problems in logging and debugging code.

<pre>
public class EclipseBug {
	public static void main(String[] s) {
		new Object() {
			{
				new Object() {
					{
						System.out.println(this.getClass().getName());
						System.out.println(this.getClass().getSimpleName());
					}
				};
			}
		};
	}
}
//</pre>


/ibs/bin$ java EclipseBug
common.EclipseBug$2
Exception in thread "main" java.lang.InternalError: Malformed class name
        at java.lang.Class.getSimpleName(Class.java:1129)
        at common.EclipseBug$2.<init>(EclipseBug.java:10)
        at common.EclipseBug$1.<init>(EclipseBug.java:7)
        at common.EclipseBug.<clinit>(EclipseBug.java:5)

Whereas compiled with javac, the result is

/Users/alf/temp$ java EclipseBug
EclipseBug$1$1

(getSimpleName() returns a blank string)
Comment 1 Olivier Thomann CLA 2005-09-06 13:57:17 EDT
This is true only if the compliance is 1.5. Below 1.5, the actual naming is fine.
Comment 2 Olivier Thomann CLA 2005-09-29 16:48:05 EDT
Created attachment 27697 [details]
Proposed fix
Comment 3 Philipe Mulet CLA 2005-10-17 09:51:36 EDT
Proposed fix looks good.
Comment 4 Philipe Mulet CLA 2005-10-17 10:27:49 EDT
Added ComplianceTest_13/_14/_15#test102.
Fixed
Comment 5 Olivier Thomann CLA 2005-10-28 18:37:47 EDT
*** Bug 114266 has been marked as a duplicate of this bug. ***
Comment 6 Olivier Thomann CLA 2006-01-09 10:36:47 EST
Verified for 3.1.2 in M20060109-0800.
Comment 7 Olivier Thomann CLA 2006-01-10 10:30:36 EST
Verified for 3.2M4 in I20051215-1506