Summary: | Strange compile error | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Dirk Baeumer <dirk_baeumer> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | RESOLVED WORKSFORME | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 3.0 | ||
Target Milestone: | 3.0 M4 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Dirk Baeumer
2003-10-09 08:37:13 EDT
---------- 1. ERROR in d:\eclipse\workspaces\dev3.0\plugins\Crap\src\A.java (at line 13) class D extends C { ^ No enclosing instance of type A is available due to some intermediate constructor invocation ---------- The error is valid though a little cryptic. Jikes would say: The innermost enclosing instance of type "A" is "this", which is not yet initialized here. javac 1.4.2 incorrectly accepts this code. Problem is that constructor for D is trying to invoke super constructor from C, which requires an enclosing instance of type A. However, since D extends C extends A, it appears that 'this' (D) is the best candidate for such an enclosing instance. However, it is forbidden, since you are still in a constructor invocation (cannot use 'this'). Correct code should be: class D extends C { D() { A.this.super(); } also see bug 42588 |