Wrong error reported
Øystein Myhre Andersen
o.myhre at gmail.com
Mon Jun 10 08:06:52 UTC 2024
I got:
Exception in thread "main" java.lang.IllegalArgumentException: Operand
stack underflow at bytecode offset 26 of method _STM()
- max stack: 65535
max locals: 65535
attributes: []
//stack map frame @0: {locals: [simulaTestPrograms/adHoc01_P_TXT2], stack:
[]}
0: {opcode: ALOAD_0, slot: 0}
1: {opcode: GETFIELD, owner: simulaTestPrograms/adHoc01_P_TXT2, field name:
P_T, field type: Lsimula/runtime/RTS_TXT;}
4: {opcode: NEW, type: simulaTestPrograms/adHoc01_P_TXT2}
7: {opcode: DUP}
8: {opcode: ALOAD_0, slot: 0}
9: {opcode: GETFIELD, owner: simula/runtime/RTS_RTObject, field name: _SL,
field type: Lsimula/runtime/RTS_RTObject;}
12: {opcode: CHECKCAST, type: simulaTestPrograms/adHoc01}
15: {opcode: INVOKESPECIAL, owner: simulaTestPrograms/adHoc01_P_TXT2,
method name: <init>, method type:
(Lsimula/runtime/RTS_RTObject;Lsimula/runtime/RTS_TXT;)V}
18: {opcode: GETFIELD, owner: simulaTestPrograms/adHoc01_P_TXT2, field
name: _RESULT, field type: Lsimula/runtime/RTS_TXT;}
21: {opcode: LDC, constant value: Abra}
23: {opcode: INVOKESTATIC, owner: simulaTestPrograms/adHoc01_P_TXT2, method
name: _ASGSTR, method type:
(Lsimula/runtime/RTS_TXT;Ljava/lang/String;)Lsimula/runtime/RTS_TXT;}
26: {opcode: INVOKESTATIC, owner: simulaTestPrograms/adHoc01_P_TXT2, method
name: _ASGTXT, method type:
(Lsimula/runtime/RTS_TXT;Lsimula/runtime/RTS_TXT;)Lsimula/runtime/RTS_TXT;}
29: {opcode: POP}
30: {opcode: ALOAD_0, slot: 0}
31: {opcode: INVOKEVIRTUAL, owner: simulaTestPrograms/adHoc01_P_TXT2,
method name: EBLK, method type: ()V}
34: {opcode: ALOAD_0, slot: 0}
35: {opcode: ARETURN}
Then I monitor the operand stack as follows:
0: {opcode: ALOAD_0, slot: 0}
1: {opcode: GETFIELD, owner: simulaTestPrograms/adHoc01_P_TXT2, field
name: P_T, field type: Lsimula/runtime/RTS_TXT;}
==> STACK: this.P_T
4: {opcode: NEW, type: simulaTestPrograms/adHoc01_P_TXT2}
==> STACK: P_TXT2, this.P_T
7: {opcode: DUP}
==> STACK: P_TXT2, P_TXT2, this.P_T
8: {opcode: ALOAD_0, slot: 0}
9: {opcode: GETFIELD, owner: simula/runtime/RTS_RTObject, field name:
_SL, field type: Lsimula/runtime/RTS_RTObject;}
12: {opcode: CHECKCAST, type: simulaTestPrograms/adHoc01}
==> STACK: this.SL, P_TXT2, P_TXT2, this.P_T
15: {opcode: INVOKESPECIAL, owner: simulaTestPrograms/adHoc01_P_TXT2,
method name: <init>, method type:
(Lsimula/runtime/RTS_RTObject;Lsimula/runtime/RTS_TXT;)V}
==> STACK: P_TXT2, this.P_T
18: {opcode: GETFIELD, owner: simulaTestPrograms/adHoc01_P_TXT2, field
name: _RESULT, field type: Lsimula/runtime/RTS_TXT;}
==> STACK: P_TXT2.RESULT, this.P_T
21: {opcode: LDC, constant value: Abra}
==> STACK: "Abra", P_TXT2.RESULT, this.P_T
23: {opcode: INVOKESTATIC, owner: simulaTestPrograms/adHoc01_P_TXT2,
method name: _ASGSTR, method type:
(Lsimula/runtime/RTS_TXT;Ljava/lang/String;)Lsimula/runtime/RTS_TXT;}
==> STACK: Return-value-1, this.P_T
26: {opcode: INVOKESTATIC, owner: simulaTestPrograms/adHoc01_P_TXT2,
method name: _ASGTXT, method type:
(Lsimula/runtime/RTS_TXT;Lsimula/runtime/RTS_TXT;)Lsimula/runtime/RTS_TXT;}
==> STACK: Return-value-2
29: {opcode: POP}
==> STACK:
30: {opcode: ALOAD_0, slot: 0}
31: {opcode: INVOKEVIRTUAL, owner: simulaTestPrograms/adHoc01_P_TXT2,
method name: EBLK, method type: ()V}
34: {opcode: ALOAD_0, slot: 0}
35: {opcode: ARETURN}
This shows that the error 'Operand stack underflow at bytecode offset 26 of
method _STM()' is wrong.
I have also compiled it fram java source:
public adHoc01_P_TXT2 _STM() {
// JavaLine 45 <== SourceLine 6
_ASGTXT(P_T, _ASGSTR(new adHoc01_P_TXT2((_CUR._SL))._RESULT, "Abra") );
EBLK();
return (this);
} // End of Procedure BODY
Which compiles to the same byte-code. AND it executes correctly.
Is there something I'm not seeing here ?
- Regards, Øystein Myhre Andersen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20240610/cc87ceff/attachment.htm>
More information about the classfile-api-dev
mailing list