Bug 163600 - [compiler] Internal references to static inner classes fail in presence of assert keyword
Summary: [compiler] Internal references to static inner classes fail in presence of as...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC All
: P3 normal with 1 vote (vote)
Target Milestone: 3.2.2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-06 16:41 EST by Eddie Galvez CLA
Modified: 2007-01-16 06:42 EST (History)
2 users (show)

See Also:


Attachments
Test case (1.15 KB, text/plain)
2006-11-06 16:42 EST, Eddie Galvez CLA
no flags Details
Project with test case, from Eclipse 3.2.1, windows. (3.51 KB, application/x-zip-compressed)
2006-11-07 11:39 EST, Eddie Galvez CLA
no flags Details
Proposed fix (5.21 KB, patch)
2006-11-07 14:40 EST, Olivier Thomann CLA
no flags Details | Diff
Proposed fix (4.16 KB, patch)
2006-11-08 19:45 EST, Olivier Thomann CLA
no flags Details | Diff
Regression tests for 3.2 maintenance branch (4.63 KB, patch)
2006-11-08 19:46 EST, 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 Eddie Galvez CLA 2006-11-06 16:41:47 EST
The attached small test case source file in Eclipse 3.2 compiles improperly; here are the project compiler properties:

Compiler compliance level: 1.4
Do not use default settings:
  Class compatibility: 1.4
  Source compatibility: 1.4

The rest is default.

If you run the test, notice that the references to the inner static class end up becoming references to the outer class. Stepping through with the debugger shows this as well; be it by stepping through the frames or by assignment in the same frame.

The test case shows it has to do with asserts being present in the inner class. If the asserts can (although I cannot say they are) be optimized out, nothing goes wrong, but any assert that must be evaluated at runtime will cause the failure. Try the various cases by uncommenting the snippets inside of Bar.myMethod to see others.

We've seen this on Windows XP, and Linux. Since Eclipse 3.2 for sure, and I believe this wasn't showing on Eclipse 3.1.
Comment 1 Eddie Galvez CLA 2006-11-06 16:42:48 EST
Created attachment 53334 [details]
Test case
Comment 2 Olivier Thomann CLA 2006-11-07 09:39:04 EST
Could you please provide your output?
I could not see anything wrong so far.
Comment 3 Eddie Galvez CLA 2006-11-07 10:08:11 EST
Here's what I just did:

 New Java Project, default options everywhere (my ws had Java JDK 1.5.0_6 as its default).
 Imported Chicken.java, moved to package.
 Run as Java Application:

Expecting class Foo
Got the class class org.innocuous.Chicken$Foo
Expecting class Bar
Got the class class org.innocuous.Chicken


Look at the code. It should not have gotten Chicken in the second test case.
Comment 4 Olivier Thomann CLA 2006-11-07 11:18:04 EST
I get:
Expecting class Foo
Got the class class org.innocuous.Chicken$Foo
Expecting class Bar
Got the class class org.innocuous.Chicken$Bar

using HEAD.
I'll check with 3.2.0.

Could you please zip your project and attach it to this bug report? Thanks.
Comment 5 Eddie Galvez CLA 2006-11-07 11:39:07 EST
Created attachment 53385 [details]
Project with test case, from Eclipse 3.2.1, windows.
Comment 6 Olivier Thomann CLA 2006-11-07 13:29:37 EST
Reproduced. I am investigating.
Comment 7 Olivier Thomann CLA 2006-11-07 14:16:32 EST
This is a regression introduced with fix for bug 157389.
This should be backported to 3.2.2.
I am working on a fix. Thanks for the bug report and the time you spent to provide steps to reproduce.
Comment 8 Olivier Thomann CLA 2006-11-07 14:40:44 EST
Created attachment 53405 [details]
Proposed fix

This patch adds all class literal synthetic fields to the outermost enclosing type and it makes a consistent usage of the source type on which the synthetic field is added.
We were wrongly sharing the same synthetic field for org.innocuous.Chicken.class and org.innocuous.Chicken$Bar.class.
Comment 9 Philipe Mulet CLA 2006-11-07 16:44:50 EST
+1 for 3.2.2
Comment 10 Olivier Thomann CLA 2006-11-07 23:07:08 EST
Released for 3.3M4.
Comment 11 Olivier Thomann CLA 2006-11-08 19:45:46 EST
Created attachment 53523 [details]
Proposed fix

Proposed fix for 3.2 maintenance stream.
Comment 12 Olivier Thomann CLA 2006-11-08 19:46:03 EST
Created attachment 53524 [details]
Regression tests for 3.2 maintenance branch
Comment 13 Olivier Thomann CLA 2006-11-08 20:31:46 EST
Released for 3.2.2.
Comment 14 Maxime Daniel CLA 2007-01-16 06:06:30 EST
Verified for 3.2.2 using build M20070112-1200.
Comment 15 Maxime Daniel CLA 2007-01-16 06:42:04 EST
(Was only is status whiteboard: frederic_fusier@fr.ibm.com  	2006-12-13 03:25:18  	Status Whiteboard  	  	Verified for 3.3 M4 using build I20061212-0010.)