Bug 53830 - compiler problem instantiating an inner class from outside
Summary: compiler problem instantiating an inner class from outside
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.0 M8   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-04 21:44 EST by Jim des Rivieres CLA
Modified: 2004-03-05 05:54 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 Jim des Rivieres CLA 2004-03-04 21:44:00 EST
Build 20040226

package org.eclipse.jdt.core.dom;
class Test {
	public class Inner {}
}
public class Main {
	public static void main(String[] args) {
		Test t = new Test();
		Test.Inner i = t.new Test.Inner(); // syntax error
	}
}

The compiler (1.4 compiler settings) reports a syntax error on the "new" token.
I don't see what the problem is. If you delete "t.", the problem says that 
you need to provide qualification that provides an enclosing instance of Test.
Comment 1 Philipe Mulet CLA 2004-03-05 05:54:32 EST
This is expected behavior, you should have written:

Test t = new Test();
Test.Inner i = t.new Inner(); 

'Inner' is resolved in the context of the qualifying expresssion type (Test).
Only references to static member types can be qualified, and then no enclosing 
instance is to be supplied: new Test.StaticInner().