Another test case distilled from classpath's TreeMap. GCJ reports: EnclosingCall.java:12: Can't reference `this' before the superclass constructor has been called. ... but we don't need to access this to call foo() - only this$0. Release: trunk How-To-Repeat: public class EnclosingCall { int foo() { return 5; } class Inner { Inner() { this(foo()); } Inner (int i) { } } }
From: Dara Hazeghi <dhazeghi@yahoo.com> To: gcc-gnats@gcc.gnu.org Cc: Subject: Re: java/4695: Error calling method from enclosing context in constructor Date: Mon, 12 May 2003 11:29:36 -0700 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit- trail&database=gcc&pr=4695 Hello, I can verify that on 3.2, 3.3 branch and mainline (20030510) on i686-linux, the same error occurs: EnclosingCall.java: In class `EnclosingCall$Inner': EnclosingCall.java: In constructor `(EnclosingCall)': EnclosingCall.java:12: error: Can't reference `this' before the superclass constructor has been called. this(foo()); ^ 1 error Dara
See Dara's comment.
Still happens on the mainline (20030709).
*** Bug 7298 has been marked as a duplicate of this bug. ***
*** Bug 16284 has been marked as a duplicate of this bug. ***
*** Bug 18215 has been marked as a duplicate of this bug. ***
*** Bug 20659 has been marked as a duplicate of this bug. ***
*** Bug 27037 has been marked as a duplicate of this bug. ***
So why does this work when compiling via bytecode?
All gcj front end bugs have been fixed by the gcj-eclipse branch merge. I'm mass-closing the affected PRs. If you believe one of these was closed in error, please reopen it with a note explaining why. Thanks.