When using Jacoco, methods are instrumented to call $jacocoInit first. As a consequence the first instructions of suspend methods are not ALOAD (25) and INSTANCEOF (193) anymore. The method MethodNode.getDebugMetadataInfo() in classTransformer.kt assumes this.
The following code searches for two consecutive ALOAD/INSTANCEOF instructions with the same conditions as previously.
It replaces the second part of the body starting with "val firstInstructions: ".
return instructions.asSequence().filter {
val next = it.next
it is VarInsnNode && it.opcode == Opcodes.ALOAD && it.`var` == continuationIndex
&& next != null && next is TypeInsnNode && next.opcode == Opcodes.INSTANCEOF
}
.firstOrNull()?.let {
val continuationClassName = (it.next as TypeInsnNode).desc.replace('/', '.')
decoroutinatorJvmAgentRegistry.metadataInfoResolver.getDebugMetadataInfo(continuationClassName)
}
When using Jacoco, methods are instrumented to call $jacocoInit first. As a consequence the first instructions of suspend methods are not ALOAD (25) and INSTANCEOF (193) anymore. The method MethodNode.getDebugMetadataInfo() in classTransformer.kt assumes this.
The following code searches for two consecutive ALOAD/INSTANCEOF instructions with the same conditions as previously. It replaces the second part of the body starting with "val firstInstructions: ".