This is the mail archive of the
java-prs@sources.redhat.com
mailing list for the Java project.
gcj/291: NullPointerException trying to access field in outer class from inner class initializer
- To: java-gnats at sourceware dot cygnus dot com
- Subject: gcj/291: NullPointerException trying to access field in outer class from inner class initializer
- From: bryce at albatross dot co dot nz
- Date: 24 Jul 2000 11:12:48 -0000
- Reply-To: bryce at albatross dot co dot nz
- Resent-Cc: java-prs at sourceware dot cygnus dot com, green at cygnus dot com
- Resent-Reply-To: java-gnats@sourceware.cygnus.com, bryce@albatross.co.nz
>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: