java/4695: Error calling method from enclosing context in constructor

bryce@gcc.gnu.org bryce@gcc.gnu.org
Thu Oct 25 20:16:00 GMT 2001


>Number:         4695
>Category:       java
>Synopsis:       Error calling method from enclosing context in constructor
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 25 20:16:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Bryce McKinlay
>Release:        trunk
>Organization:
>Environment:

>Description:
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.
>How-To-Repeat:
public class EnclosingCall
{
  int foo()
  {
    return 5;
  }
  
  class Inner
  {
    Inner()
    {
      this(foo()); 
    }
    
    Inner (int i)
    {
    }
  }
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list