GCJ Bug accessing field of inner class (gcc version 2.97 20010117)
Barnet Wagman
wagman@enteract.com
Thu Jan 18 20:43:00 GMT 2001
GCJ appears to be unable to access the field of an inner class from within
a different class.ÃÂ Here's a simple example:
package A;
public class HasInnerClass {
ÃÂ ÃÂ ÃÂ InnerClass ic0;
ÃÂ ÃÂ ÃÂ public HasInnerClass() {
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ic0 = new InnerClass();
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ System.err.println("In
HasInnerClass(), ic0.s = " + ic0.s);
ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ public class InnerClass {
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ String s;
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ int i;
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ public InnerClass() {
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
s = "A stringggggggggggggggggggggggggggggggggggggggg";
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
i = 123;
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ public InnerClass newInnerClass() { return( new
InnerClass() ); }
}
ÃÂ
package A;
public class UsesInnerClass {
ÃÂ ÃÂ ÃÂ public UsesInnerClass() {
ÃÂ
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ HasInnerClass hic =
new HasInnerClass();
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ System.err.println(
"In UsesInnerClass(), hic.ic0.s = " + hic.ic0.s);
ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ public static void main(String[] argv) { new
UsesInnerClass(); }
}
After compiling with gcj, gcc version 2.97 20010117 (experimental),ÃÂ
runningÃÂ it yields
I n HasInnerClass(), ic0.s = A stringggggggggggggggggggggggggggggggggggggggg
Out of Memory!ÃÂ Returning NIL!
instead of
In HasInnerClass(), ic0.s = A stringggggggggggggggggggggggggggggggggggggggg
In UsesInnerClass(), hic.ic0.s = A stringggggggggggggggggggggggggggggggggggggggg
ÃÂ
Is this a known bug?
Regards,
Barnet Wagman
More information about the Java
mailing list