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.) -- Summary: GCJ generates inner class code that fails to verify. Product: gcc Version: 3.4.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: java AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gcc-java at esclat dot net CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18728