gcj/256: Cannot access static fields of static inner classes
mark@klomp.org
mark@klomp.org
Thu Jun 8 13:50:00 GMT 2000
>Number: 256
>Category: gcj
>Synopsis: Cannot access static fields of static inner classes
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: apbianco
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jun 08 13:50:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: mark@klomp.org
>Release: gcc version 2.96 20000602 (experimental)
>Organization:
>Environment:
>Description:
The following code does not compile:
public class A {
public static void main(String args[]) {
B.Hello hello = new B.Hello();
System.out.println(hello.WORLD);
System.out.println(B.Hello.World);
}
}
class B {
static class Hello {
public static final String WORLD = "Hello World!";
}
}
'gcj --main=A A.java' gives:
A.java: In class `A':
A.java: In method `main(java.lang.String[])':
A.java:5: No variable `Hello' defined in type `B'.
System.out.println(B.Hello.World);
^
1 error
Note that commenting out that line does compile.
So it is possible to access the field indirectly by creating
an object, but not directly through the inner class.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Java-prs
mailing list