Bug 9838 - Wrong diagnosis compiling inner classes
Summary: Wrong diagnosis compiling inner classes
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-02-14 12:57 EST by Olivier Thomann CLA
Modified: 2003-02-11 06:36 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 2002-02-14 12:57:10 EST
v228,

[public class Outer {
	class Inner extends Outer {
	}
	public static void main(String[] args) {
		class Local extends Inner {
		}
	}
}]

Compiling this class with javac 1.3.1 or 1.4 reports:
Outer.java:5: no enclosing instance of type Outer is in scope
                class Local extends Inner {
                ^
1 error

We compile it fine and generate three .class files.
Need to investigate which one is the correct behavior.
See also 
http://www-124.ibm.com/developerworks/bugs/?func=detailbug&bug_id=372&group_id=1
0
Comment 1 Philipe Mulet CLA 2002-02-15 06:09:40 EST
Our behavior seems appropriate given the local class doesn't need any enclosing 
information (until it uses anything from the enclosing scopes).

Inner-emulation is supposed to be lazily requesting access to enclosing 
elements, and Javac is simply asking too much by default, I had already noticed 
it was always requesting the enclosing instance by default.

Will not change unless this is escaladated due to a JCK compliance issue.
Comment 2 Philipe Mulet CLA 2003-02-04 10:24:47 EST
Closing, got fixed along with various innerclass adjustments.

-> No enclosing instance of type Outer is accessible to invoke the super 
constructor. Must define a constructor and explicitly qualify its super 
constructor invocation with an instance of Outer (e.g. x.super() where x is an 
instance of Outer).
Comment 3 Philipe Mulet CLA 2003-02-11 06:35:16 EST
Should remove later resolution
Comment 4 Philipe Mulet CLA 2003-02-11 06:36:11 EST
Closing