This is the mail archive of the java-prs@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

java/7482: gij verify error


>Number:         7482
>Category:       java
>Synopsis:       gij verify error
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 03 16:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     jmr@fulcrummicro.com
>Release:        3.3 20020801 (experimental)
>Organization:
>Environment:
System: Linux churchill 2.4.3-12 #1 Fri Jun 8 15:05:56 EDT 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-threads=posix --prefix=/home/user/jmr/app/gcc --enable-shared --enable-languages=c++,java : (reconfigured) 
>Description:
	The gij verifier erroneously gives an error when run on the class
        file resulting from the following code:

        X.java:

        public class X {
            private interface I { }
            private static class U implements I { }
            private static class V implements I { }

            private static I g(Object o) {
                I i;
                if (o == null)
                    i = new U();
                else
                    i = new V();
                return i;
            }

            public static void main(String[] args) {
                System.out.println(g(null));
            }
        }

        It will also fail if the inner classes are put in their own files,
        so it's not an issue with inner classes.

        I tried all four combinations of compiling the .java with gcj /
        Sun's javac, and interpreting with gij / Sun's java.  It failed
        in both gij cases, but neither of the java cases, so I'm assuming
        that the .class generation is ok on the part of both compilers.

>How-To-Repeat:
; gcj -C -v X.java
Reading specs from /home/user/jmr/app/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
Configured with: ../gcc/configure --enable-threads=posix --prefix=/home/user/jmr/app/gcc --enable-shared --enable-languages=c++,java : (reconfigured) 
Thread model: posix
gcc version 3.3 20020801 (experimental)
 /home/user/jmr/app/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.3/jc1 X.java -quiet -dumpbase X.java -g1 -version -fsyntax-only -femit-class-files -o /dev/null
GNU Java version 3.3 20020801 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 3.2 20020713 (experimental).
Class path starts here:
    ./
    /home/user/jmr/app/gcc/share/java/libgcj-3.3.jar/ (system) (zip)

; gij X
Exception in thread "main" java.lang.VerifyError: verification failed at PC 24 in X:g((Ljava.lang.Object;)LX$I;): incompatible return type
   at java.lang.Throwable.Throwable(java.lang.String) (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at java.lang.Error.Error(java.lang.String) (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at java.lang.LinkageError.LinkageError(java.lang.String) (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at java.lang.VerifyError.VerifyError(java.lang.String) (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at _Jv_BytecodeVerifier.verify_fail(byte, int) (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at _Jv_BytecodeVerifier.verify_instructions_0() (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at _Jv_VerifyMethod(_Jv_InterpMethod) (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at _Jv_PrepareClass(java.lang.Class) (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at java.lang.ClassLoader.linkClass0(java.lang.Class) (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at java.lang.ClassLoader.resolveClass0(java.lang.Class) (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at java.lang.Class.initializeClass() (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at java.lang.Class.forName(java.lang.String) (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at gnu.gcj.runtime.FirstThread.run() (/home/user/jmr/app/gcc/lib/libgcj.so.3)
   at _Jv_ThreadRun(java.lang.Thread) (/home/user/jmr/app/gcc/lib/libgcj.so.3)

; gij --version
gij (GNU libgcj) version 3.3 20020801 (experimental)

Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

>Fix:
	In this case, a workaround is to write
        if (o == null)
            return new U();
        else
            return new V();
        instead.  There may be more complex examples where coding around
        the problem isn't as easy.
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]