java/10334: Runtime error when trying to access an initialized static member.

marcel.offermans@luminis.nl marcel.offermans@luminis.nl
Mon Apr 7 11:56:00 GMT 2003


>Number:         10334
>Category:       java
>Synopsis:       Runtime error when trying to access an initialized static member.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 07 11:56:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     marcel.offermans@luminis.nl
>Release:        gcc-3.2.2
>Organization:
>Environment:
RedHat Linux 7.3
>Description:
Compile the class below like this:

gcj --main=A A.java

And it will give you a NPE when you run it. Uncomment the System.out.println statement which accesses B.a prior to assigning anything to B.a.a and everything works fine.

public class A {
    public static void main(String[] args) {
        //System.out.println("" + B.a);
        B.a.a = "test";
    }
}

class B {
    public static class C {
        public String a;
    }
    public static C a = new C();
}
>How-To-Repeat:

>Fix:

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



More information about the Java-prs mailing list