Bug 4695 - Error calling method from enclosing context in constructor
Summary: Error calling method from enclosing context in constructor
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 7298 16284 18215 20659 27037 (view as bug list)
Depends on: 28067
Blocks: 9943 13607 18131
  Show dependency treegraph
 
Reported: 2001-10-25 20:16 UTC by Bryce McKinlay
Modified: 2007-01-09 20:43 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-09-23 23:19:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bryce McKinlay 2001-10-25 20:16:00 UTC
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)
    {
    }
  }
}
Comment 1 Dara Hazeghi 2003-05-12 11:29:36 UTC
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
Comment 2 Andrew Pinski 2003-05-26 18:44:36 UTC
See Dara's comment.
Comment 3 Andrew Pinski 2003-07-10 02:56:28 UTC
Still happens on the mainline (20030709).
Comment 4 Andrew Pinski 2003-08-10 03:54:20 UTC
*** Bug 7298 has been marked as a duplicate of this bug. ***
Comment 5 Andrew Pinski 2004-06-29 22:39:00 UTC
*** Bug 16284 has been marked as a duplicate of this bug. ***
Comment 6 Andrew Pinski 2004-10-29 03:54:06 UTC
*** Bug 18215 has been marked as a duplicate of this bug. ***
Comment 7 Andrew Pinski 2005-03-27 22:17:48 UTC
*** Bug 20659 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2006-04-05 00:25:48 UTC
*** Bug 27037 has been marked as a duplicate of this bug. ***
Comment 9 Taral 2006-04-05 00:27:05 UTC
So why does this work when compiling via bytecode?
Comment 10 Tom Tromey 2007-01-09 20:43:33 UTC
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.