Bug 27413 - Should we reject that code?
Summary: Should we reject that code?
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   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-11-29 11:45 EST by Olivier Thomann CLA
Modified: 2003-02-07 09:43 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-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.