Wrong code generation

Andrew Haley aph@redhat.com
Fri Mar 21 12:36:00 GMT 2003


Please see the thread that begins at
http://gcc.gnu.org/ml/java/2003-01/msg00376.html
Andrew.
Michael Koch writes:
 > -----BEGIN PGP SIGNED MESSAGE-----
 > Hash: SHA1
 > 
 > Am Dienstag, 18. MŽärz 2003 15:43 schrieb Michael Koch:
 > > Hi list,
 > >
 > >
 > > The attached testcase produces wrong bytecode when compiled with
 > > gcj.
 > >
 > > When compiled and run with Sun's JDK it prints "Michael". ;-)
 > >
 > > When compiled with gcj and run with Sun's java it prints:
 > > Exception in thread "main" java.lang.VerifyError: (class:
 > > InvokeTest, method: test signature: ()V) Illegal use of nonvirtual
 > > function call
 > >
 > > (Thats a testcase I made for a bug found when bootstrapping ant
 > > 1.5.2)
 > 
 > I investigated this a bit more and looked at the differences in 
 > jcf-dump output of InvokeTest.class generated from SUN's javac 
 > 1.4.1_01 and gcj from trunk (today).
 > 
 > Sun generates for InvokeTest.test:
 > 
 > Method name:"test" public Signature: 16=()void
 > Attribute "Code", length:46, max_stack:3, max_locals:2, code_length:14
 > 0: new #5=<Class InvokeTest$InnerClass>
 > 3: dup
 > 4: aload_0
 > 5: invokespecial #6=<Method InvokeTest$InnerClass.<init> 
 > (InvokeTest)void>
 > 8: astore_1
 > 9: aload_1
 > 10: invokestatic #7=<Method InvokeTest$InnerClass.access000ドル 
 > (InvokeTest$InnerClass)void>
 > 13: return
 > Attribute "LineNumberTable", length:14, count: 3
 > line: 15 at pc: 0
 > line: 16 at pc: 9
 > line: 17 at pc: 13
 > 
 > GCJ generates for the same method:
 > 
 > Method name:"test" public Signature: 9=()void
 > Attribute "Code", length:42, max_stack:3, max_locals:2, code_length:14
 > 0: new #18=<Class InvokeTest$InnerClass>
 > 3: dup
 > 4: aload_0
 > 5: invokespecial #21=<Method InvokeTest$InnerClass.<init> 
 > (InvokeTest)void>
 > 8: astore_1
 > 9: aload_1
 > 10: invokespecial #24=<Method InvokeTest$InnerClass.invoke ()void>
 > 13: return
 > Attribute "LineNumberTable", length:10, count: 2
 > line: 15 at pc: 0
 > line: 16 at pc: 9
 > 
 > The main difference is this
 > 
 > sun: 10: invokestatic #7=<Method InvokeTest$InnerClass.access000ドル
 > (InvokeTest$InnerClass)void>
 > 
 > gcj: 10: invokespecial #24=<Method InvokeTest$InnerClass.invoke 
 > ()void>
 > 
 > 
 > The call of InvokeTest.InnerClass.invoke() is just generated wrongly.
 > 
 > 
 > I hope this helps fixing this bug.
 > 
 > 
 > Michael
 > - -- 
 > Homepage: http://www.worldforge.org/
 > -----BEGIN PGP SIGNATURE-----
 > Version: GnuPG v1.2.1 (GNU/Linux)
 > 
 > iD8DBQE+ewV+WSOgCCdjSDsRAvvHAJ9GoYKPYT8wd7Mg0+piP90UBBW20gCfftpV
 > oIk1oOA8J7hE4uESNZkb1JM=
 > =dnDV
 > -----END PGP SIGNATURE-----


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /