[kaffe] Bytecode fails verification when anonymous class inherits
inner class of another class.
Kalle Olavi Niemitalo
kon at iki.fi
Sun Jan 16 10:54:10 PST 2005
Compile this code (from <http://gcc.gnu.org/PR19471>) with kjc
of Kaffe 1.1.4.PRECVS6-1 from Debian:
class First {
class Inner {}
};
class Second {
void fn(First first) {
first.new Inner() {
void crash() {}
};
}
}
The resulting Second$1Inner.class contains this method:
Method name:"<init>" public Signature: (Second,First)void
Attribute "Code", length:38, max_stack:2, max_locals:3, code_length:14
0: aload_0
1: aload_2
2: getfield <Field First$Inner.this$0 First>
5: invokespecial <Method First$Inner.<init> (First)void>
8: aload_0
9: aload_1
10: putfield <Field Second$1Inner.this$0 Second>
13: return
Attribute "LineNumberTable", length:6, count: 1
line: 7 at pc: 0
Attribute "Signature", length:2
The getfield instruction at PC=2 is incorrect, as shown by GCC:
$ gcj -c 'Second$1Inner.class'
PR19471.java: In class 'Second$1Inner':
PR19471.java: In constructor '(Second,First)':
PR19471.java:7: error: verification error at PC=2
PR19471.java:7: error: expected type 'First$Inner' but stack contains 'First'
Compare to the result from Jikes:
Method name:"<init>" Signature: (Second,First)void
Attribute "Code", length:39, max_stack:2, max_locals:3, code_length:11
0: aload_0
1: aload_1
2: putfield <Field Second$1.this Second>
5: aload_0
6: aload_2
7: invokespecial <Method First$Inner.<init> (First)void>
10: return
Attribute "LineNumberTable", length:10, count: 2
line: 7 at pc: 5
line: 7 at pc: 10
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://pogo.kaffe.org/pipermail/kaffe/attachments/20050116/fd4ba7c8/attachment.bin
More information about the kaffe
mailing list