Summary: | NPE when methods from the outermost enclosing class is invoked in a anonymous class | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Olivier Thomann <Olivier_Thomann> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | RESOLVED WONTFIX | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 2.0 | ||
Target Milestone: | 2.0 M6 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Olivier Thomann
2002-05-02 10:02:45 EDT
It turns out that the anonymous constructor being called: new LightweightSystem(Canvas){} would result in validate being called during the construction. I suppose the anonymous constructor "new LightweightSystem(this)" get's turned into: new LightweightSystem(Canvas canvas, FigureCanvas enclosingRef){ super(canvas); //super's constructor indirectly results in reference to field set below this.enclosingRef = enclosingRef; } And THEN, the first line calling the super(canvas) constructor eventually results in an access to enclosingRef before it is set. This is causing the NullPointerException. Is there any way to set the enclosingRefence before calling super()? Anyway, I've worked around this already. I suppose this is WAD. Indeed any super constructor call MUST (vm spec) be invoked before assigning this$N fields used for innerclass emulation. This results in this issue, if the super constructor will dynamically invoke code on the originating subclass which requires to reach into its enclosing type. Javac has the same issue. This is a limitation of Java, not from our compiler. Closing Closing |