Skip to content

Commit

Permalink
Fix RecoverabilityTransformer.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
ndkoval committed Oct 28, 2020
1 parent e0026e8 commit 51473cb
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,28 @@ class RecoverableMethodTransformer(
super.visitCode()
if (!shouldTransform) return
val loop = Label()
val startLabel = Label()
val tryLabel = Label()
val endLabel = Label()
val catchLabel = Label()
visitTryCatchBlock(startLabel, endLabel, catchLabel, Type.getInternalName(CrashError::class.java))
visitTryCatchBlock(tryLabel, endLabel, catchLabel, Type.getInternalName(CrashError::class.java))

val resultIndex = newLocal(Type.BOOLEAN_TYPE)
val beforeCompleted = newLocal(Type.BOOLEAN_TYPE)
push(false)
storeLocal(resultIndex)
storeLocal(beforeCompleted)

visitLabel(loop)
visitLabel(startLabel)
visitVarInsn(Opcodes.ALOAD, 0)
visitVarInsn(Opcodes.ALOAD, 1) // get first parameter
invokeVirtual(Type.getType("L$className;"), Method(beforeName, "(I)V"))
visitLabel(tryLabel)
loadThis()
loadArgs()
invokeVirtual(Type.getType("L$className;"), Method(beforeName, descriptor!!.substring(0, descriptor.indexOf(")") + 1) + "V"))
push(true)
storeLocal(resultIndex)
visitLabel(endLabel)
storeLocal(beforeCompleted)
goTo(endLabel)
visitLabel(catchLabel)
loadLocal(resultIndex)
// Start empty catch block
pop() // remove CatchException from the stack
visitLabel(endLabel)
loadLocal(beforeCompleted)
ifZCmp(EQ, loop)
}
}

0 comments on commit 51473cb

Please sign in to comment.