From bedaa1a503faa644e8fae6e33bc34e38ec5a3398 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Tue, 30 Oct 2018 15:27:09 +0100 Subject: [PATCH] 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 --- .../jvm/intrinsics/IrIllegalArgumentException.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIllegalArgumentException.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIllegalArgumentException.kt index 1e4c9ffb536..3e8203ffa25 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIllegalArgumentException.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIllegalArgumentException.kt @@ -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, "", Type.getMethodDescriptor(Type.VOID_TYPE, JAVA_STRING_TYPE), false) + v.invokespecial( + exceptionTypeDescriptor.internalName, + "", + 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) }