invokespecial on abstract method

Christian Stuellenberg gcj@stuellenberg.de
Thu Oct 2 14:33:00 GMT 2003


Hello,

I've got some bytecode, that I'm not able to compile with an native 
$ gcj -v
Reading specs from /site.opt/gcc-3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
Reading specs from /site.opt/gcc-3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3/../../../libgcj.spec
rename spec lib to liborig
Konfiguriert mit: ../gcc-3.3/configure --prefix=/site.opt/gcc-3.3 --enable-languages=c, java
Thread model: posix
gcc-Version 3.3

and also not with an crossed
$ mingw32-gcj -v
Reading specs from /site.opt/mingw32-cross/lib/gcc-lib/mingw32/3.3.1/specs
Reading specs from /site.opt/mingw32-cross/lib/gcc-lib/mingw32/3.3.1/../../../../mingw32/lib/libgcj.spec
rename spec lib to liborig
Configured with: ../gcc-3.3.1/configure --target=mingw32 --prefix=/site.opt/mingw32-cross --without-newlib --enable-shared --enable-libgcj --enable-threads=win32 --enable-languages=c,c++,java --disable-nls --disable-debug --with-gcc --with-gnu-as --with-gnu-ld --without-newlib --disable-win32-registry --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-sjlj-exceptions
Thread model: win32
gcc version 3.3.1 (mingw special 20030804-1)

The error (both output very similar) looks like:
$ gcj testing-out.jar
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
/tmp/ccFqoKy6.o: In function `testing::B::get(int)':
/tmp/ccFqoKy6.o(.text+0x2730): undefined reference to `java::util::AbstractList::get(int)'
/tmp/ccFqoKy6.o: In function `testing::B::$super$get(int)':
/tmp/ccFqoKy6.o(.text+0x2781): undefined reference to `java::util::AbstractList::get(int)'
/tmp/ccFqoKy6.o: In function `testing::A::size()':
/tmp/ccFqoKy6.o(.text+0x27cb): undefined reference to `java::util::AbstractCollection::size()'
/tmp/ccFqoKy6.o: In function `testing::A::get(int)':
/tmp/ccFqoKy6.o(.text+0x2838): undefined reference to `java::util::AbstractList::get(int)'
/tmp/ccFqoKy6.o: In function `nice::lang::Range::get(int)':
/tmp/ccFqoKy6.o(.text+0xa87f): undefined reference to `java::util::AbstractList::get(int)'
/tmp/ccFqoKy6.o: In function `nice::lang::Range::size()':
/tmp/ccFqoKy6.o(.text+0xa8d5): undefined reference to `java::util::AbstractCollection::size()'
collect2: ld returned 1 exit status

If I look at the bytecode there is an invokespecial on an abstract
method:
Method public  size () -> int
0       iconst_1
1       ifeq 9
4       aload_0
5       invokestatic #6 <Method testbug/fun.size (Ltestbug/A;)I>
8       ireturn
9       aload_0
10      invokenonvirtual #11 <Method java/util/AbstractCollection.size ()I>
13      ireturn
Method public  get (int) -> java/lang/Object
0       iload_1
1       iconst_0
2       if_icmpne 11
5       aload_0
6       iload_1
7       invokestatic #15 <Method testbug/fun.get (Ltestbug/A;I)Ljava/lang/Object;>
10      areturn
11      aload_0
12      iload_1
13      invokenonvirtual #20 <Method java/util/AbstractList.get (I)Ljava/lang/Object;
16      areturn
Method public  <init> () -> void
0       aload_0
1       invokenonvirtual #24 <Method java/util/AbstractList.<init>
        ()V>
4       return

An invokespecial to an abstract method should throw a
java.lang.AbstractMethodError at execution time (as e.g. an JVM-1.3
does), but I'm not able to compile this with gcj.

So, if I invoke the attached jar-archive (that also contains the
already mentioned bytecode) with an 
java -jar testing-out.jar 
it gives me:
Exception in thread "main" java.lang.AbstractMethodError: java.util.AbstractList.get(I)Ljava/lang/Object;
	at testing.A.get(minimal.nice)
	at testing.B.$super$get(minimal.nice)
	at testing.fun.get$1(~/Work/WorkingDirectory/e3m/src/testing)
	at testing.B.get(minimal.nice)
	at testing.fun.main(~/Work/WorkingDirectory/e3m/src/testing:14)

But if I even use
gij -jar testing-out.jar
it gives me (in german):
Speicherzugriffsfehler

So, there seems to be something wrong, doesn't it?

Christian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: testing-out.jar
Type: application/octet-stream
Size: 45002 bytes
Desc: Executable JAR
URL: <http://gcc.gnu.org/pipermail/java/attachments/20031002/d25d39b9/attachment.obj>


More information about the Java mailing list