Stack map does not match the one at exception handler
I am generating code from scratch using ASM, and in one case I get this error when executing the function. I use ClassWriter.COMPUTE_FRAMES
and MethodVisitor.visitMaxs(0, 0)
, and I also verify generated code with SimpleVerifier
and Analyzer<BasicValue>
, I get no complaints from those.
The error (below) seems to make sense: it says current stack map frame has a Cell
local at position 6, while the exception handler has null at that position. But why is ASM happy with it? In general, what does it even mean, how can exception handler not have a different stack map frame if the try
block uses local variables? Say, can't you always put a try around the whole function body? Sorry if my questions are stupid, but I am lost here, I don't even understand if I am doing something wrong.
Stack map does not match the one at exception handler 275
Exception Details:
Location:
org/japy/bin/commonpath.invoke(Lorg/japy/kernel/util/Args;Lorg/japy/kernel/exec/PyContext;)Lorg/japy/kernel/types/IPyObj; @275: aload_2
Reason:
Type 'org/japy/kernel/exec/Cell' (current frame, locals[6]) is not assignable to null (stack map, locals[6])
Current Frame:
bci: @128
flags: { }
locals: { 'org/japy/bin/commonpath', 'org/japy/kernel/util/Args', 'org/japy/kernel/exec/PyContext', 'org/japy/kernel/types/IPyObj', null, null, 'org/japy/kernel/exec/Cell', null }
stack: { 'java/lang/Throwable' }
Stackmap Frame:
bci: @275
flags: { }
locals: { 'org/japy/bin/commonpath', 'org/japy/kernel/util/Args', 'org/japy/kernel/exec/PyContext', 'org/japy/kernel/types/IPyObj', null, null, null, null }
stack: { 'java/lang/Throwable' }