VerifyError when added code pushes the offset of a conditional backward jump below -32768
Code reproducing the issue:
https://gist.github.com/vootelerotov/23641ee63473565cf3ef5c8fbc12a791
Also uploaded it as a Maven project.
Error:
Exception in thread "main" java.lang.VerifyError: Expecting a stackmap frame at
branch target 32779
Exception Details:
Location:
TestClass.test()I @32771: if_icmpeq
Reason:
Expected stackmap frame at this location.
The root cause seems to be that when a conditional backward jump is converted to
GOTO_W in MethodWriter#visitJumpInsn, a jump is added to next instruction after
the conditional backward jump. This instruction might not have a stackmap frame.
Only relevant if the frames are not re-computed.