Use proper type constructor in IrIllegalArgumentException

'v.anew(Type.geType(...))' worked accidentally because
  1. By default, ASM 6 creates METHOD Type for 'Type.geType(...)' invocation
  2. It didn't fail because this type was used only in 'anew' invocation that
      calls 'internalName' only
  3. ASM 7 changes default behavior to throw Exception
This commit is contained in:
Mikhael Bogdanov
2018-10-30 15:27:09 +01:00
parent 98fa26c2d8
commit bedaa1a503
@@ -27,7 +27,7 @@ import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
class IrIllegalArgumentException : IntrinsicMethod() {
val exceptionTypeDescriptor = Type.getInternalName(IllegalArgumentException::class.java)
val exceptionTypeDescriptor = Type.getType(IllegalArgumentException::class.java)!!
override fun toCallable(
expression: IrMemberAccessExpression,
@@ -36,12 +36,17 @@ class IrIllegalArgumentException : IntrinsicMethod() {
): IrIntrinsicFunction {
return object : IrIntrinsicFunction(expression, signature, context, listOf(JAVA_STRING_TYPE)) {
override fun genInvokeInstruction(v: InstructionAdapter) {
v.invokespecial(exceptionTypeDescriptor, "<init>", Type.getMethodDescriptor(Type.VOID_TYPE, JAVA_STRING_TYPE), false)
v.invokespecial(
exceptionTypeDescriptor.internalName,
"<init>",
Type.getMethodDescriptor(Type.VOID_TYPE, JAVA_STRING_TYPE),
false
)
v.athrow()
}
override fun invoke(v: InstructionAdapter, codegen: ExpressionCodegen, data: BlockInfo): StackValue {
v.anew(Type.getType(exceptionTypeDescriptor))
v.anew(exceptionTypeDescriptor)
v.dup()
return super.invoke(v, codegen, data)
}