The following test case crashes because no class initialization for "Bar" is generated. Release: gcc version 3.1 20011221 (experimental) How-To-Repeat: class Bar { static Bar B = new Bar(); int i = 1; } public class Qual2 { public static void main(String[] args) { System.out.println (Bar.B.i); // crash System.out.println ((Bar.B).i); // crash } }
Confirmed on 3.3 (20021216), Yes I know that this is an old prelease but still. But fixed on mainline (20030524).
Hello, with gcc 3.2.3, 3.3 branch, and mainline (20030524), the testcase here crashes as reported: Exception in thread "main" java.lang.NullPointerException at Qual.main(java.lang.String[]) (Unknown Source) Dara
I cannot reproduce this on the mainline (20030524) on i686-pc-linux-gnu: tin:~/src/gnu/gcctest>gcj --main=Qual2 Qual2.java tin:~/src/gnu/gcctest>./a.out 1 1 tin:~/src/gnu/gcctest>gcj --main=Qual2 Qual2.java -O3 tin:~/src/gnu/gcctest>./a.out 1 1 tin:~/src/gnu/gcctest>gcj --main=Qual2 Qual2.java -O3 -C gcj: cannot specify `main' class when not linking tin:~/src/gnu/gcctest>gcj Qual2.java -O3 -C tin:~/src/gnu/gcctest>gij Qual2 1 1 tin:~/src/gnu/gcctest>java Qual2 1 1 tin:~/src/gnu/gcctest>javac Qual2.java tin:~/src/gnu/gcctest>!gij gij Qual2 1 1 tin:~/src/gnu/gcctest>gcj Qual2.class --main=Qual2 Bar.class tin:~/src/gnu/gcctest>./a.out 1 1
This is fixed for 3.4 as noted above by me.
Since this is not a regression I can closing this bug as it is fixed in a later version of gcc.