Bug 18728 - GCJ allows creation of inner class without qualifying reference
Summary: GCJ allows creation of inner class without qualifying reference
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 3.4.2
: P2 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
Keywords: accepts-invalid
Depends on: 9884 28067
Blocks: 18131
  Show dependency treegraph
Reported: 2004-11-29 20:43 UTC by Jeff Gold
Modified: 2007-01-09 20:46 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2005-06-12 23:21:04


Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Gold 2004-11-29 20:43:46 UTC
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)
   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)
   at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.5.0.0)
   at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader)
   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)
   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.)
Comment 1 Andrew Pinski 2004-11-29 20:54:31 UTC
This is almost a dup of bug 9884 but not quiet.

Comment 2 Tom Tromey 2004-12-02 18:25:59 UTC
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
Comment 3 Tom Tromey 2007-01-09 20:46:41 UTC
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.