Compiling the following code with gcj (at least with version 3.4.2 as shipped with Fedora Core 3) reports no errors or warnings: class A { class B { int value; } } class VerifyBug { A.B b; VerifyBug() { b = new A.B(); } static void main(String args[]) { VerifyBug v = new VerifyBug(); } } However when attempting to run the resulting class files with either libgcj or the Sun JDK 1.5.0 a java.lang.VerifyError is thrown. Below is the output from a gij invocation: Exception in thread "main" java.lang.VerifyError: verification failed at PC 10 in VerifyBug:<init>(()V): incompatible type on stack at _Jv_BytecodeVerifier.verify_fail(byte, int) (/usr/lib/libgcj.so.5.0.0) at _Jv_BytecodeVerifier.pop_init_ref(_Jv_BytecodeVerifier.type) (/usr/lib/libgcj.so.5.0.0) at _Jv_BytecodeVerifier.verify_instructions_0() (/usr/lib/libgcj.so.5.0.0) at _Jv_VerifyMethod(_Jv_InterpMethod) (/usr/lib/libgcj.so.5.0.0) at _Jv_PrepareClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0) at _Jv_WaitForState(java.lang.Class, int) (/usr/lib/libgcj.so.5.0.0) at java.lang.VMClassLoader.linkClass0(java.lang.Class) (/usr/lib/libgcj.so.5.0.0) at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0) at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.5.0.0) at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0) at java.lang.Class.forName(java.lang.String) (/usr/lib/libgcj.so.5.0.0) at gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.5.0.0) at _Jv_ThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.5.0.0) at _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/libgcj.so.5.0.0) at __libc_start_main (/lib/tls/libc-2.3.3.so) I believe the original Java code is actually wrong, as non-static inner classes can't be instantiated without an instance of the enclosing class around for some unfathomable reason. But gcj compiles it without complaint. (I appologize if this is a duplicate. I searched the list of open and fixed bugs for Java and didn't anything that seemed to be the same problem, but it seems possible that the cause is something already in the bug database but not obvious to me.)
This is almost a dup of bug 9884 but not quiet. Confirmed.
I'm changing the title to reflect that it is a front end bug and not a class generation bug. The code should not be accepted.
All gcj front end bugs have been fixed by the gcj-eclipse branch merge. I'm mass-closing the affected PRs. If you believe one of these was closed in error, please reopen it with a note explaining why. Thanks.