This is the mail archive of the java-prs@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcj/291: NullPointerException trying to access field in outer class from inner class initializer



>Number:         291
>Category:       gcj
>Synopsis:       NullPointerException trying to access field in outer class from inner class initializer
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apbianco
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 24 04:16:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Bryce McKinlay
>Release:        gcc version 2.96 20000723 (experimental)
>Organization:
>Environment:

>Description:
Trying to access a field in an outer class from an inner class
field initializer results in a runtime crash.
>How-To-Repeat:
Compile and run this test case. The culprit is the "foo = bar"
statement.

public class InnerInitializer
{
  public static void main(String args[])
  {
    new InnerInitializer().a();
  }

  int bar;
  
  void a()
  {
    bar = 7;
    new A();
  }
  
  class A
  { 
    int foo = bar;
  }
}
>Fix:

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]