Bug 27413

Summary: Should we reject that code?
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: 2.1 M5   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Olivier Thomann CLA 2002-11-29 11:45:54 EST
Build 1127 + head contents:

Javac and jikes both reject this code.
public class H {     
        H(Object o) {
            class A {
                private A() {}
            }
            class B extends H {
                B() {
                    super(new A() {});
                }
            }
        }
}      

We compile it.
Javac 1.4.1 reports:
H.java:8: cannot reference H before supertype constructor has been called
                    super(new A() {});
                                  ^
1 error

jikes 1.18 reports:

Found 1 semantic error compiling "D:/temp/H.java":

     8.                     super(new A() {});
                                  ^-^
*** Semantic Error: The innermost enclosing instance of type "H" is "this",
which is not yet initialized here.
Comment 1 Philipe Mulet CLA 2002-12-02 17:37:47 EST
I believe we would use H.this, instead of this... need to investigate.
Comment 2 Philipe Mulet CLA 2003-01-08 11:59:20 EST
Actually, we accept this code since we do not eagerly require an enclosing 
instance for local types, until actually needed.

On the following example though, we are getting an internal failure which we 
shouldn't:
public class X {

	public static void main(String[] arguments) {
		new X(null).foo();
		System.out.println("DONE");
	}
	X(Object o){
	}
	void foo(){
		class A { 
			private A() {
			}
		}
		class B extends X {
			B() {
				super(new A(){
					void foo() {
						System.out.println(X.this);
					}
				});
			}
		}
	}
}
Comment 3 Philipe Mulet CLA 2003-01-10 05:57:46 EST
Both issues fixed. We will now reject original code.
Comment 4 David Audel CLA 2003-02-07 09:43:00 EST
Verified.