From e794e513264373bc73b0b338cb1fef647984e26a Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Sun, 9 Oct 2016 10:24:00 -0500 Subject: Fix the interface flag when re-writing a closure call to the body method When re-writing a closure invocation to the body method, the `itf` flag of the invocation instruction was incorrect: it needs to be true if the method is defined in an interface (including static methdos), not if the method is invoked through `INVOKEINTERFACE`. JDK 8 doesn't flag this inconsistency and executes the bytecode, but the verifier in JDK 9 throws an `IncompatibleClassChangeError`. Similar fixes went into e619b03. --- src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/compiler/scala/tools/nsc/backend') diff --git a/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala b/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala index 081830d61d..35ee5ba13d 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/opt/ClosureOptimizer.scala @@ -325,8 +325,7 @@ class ClosureOptimizer[BT <: BTypes](val btypes: BT) { insns.insertBefore(invocation, new InsnNode(DUP)) INVOKESPECIAL } - val isInterface = bodyOpcode == INVOKEINTERFACE - val bodyInvocation = new MethodInsnNode(bodyOpcode, lambdaBodyHandle.getOwner, lambdaBodyHandle.getName, lambdaBodyHandle.getDesc, isInterface) + val bodyInvocation = new MethodInsnNode(bodyOpcode, lambdaBodyHandle.getOwner, lambdaBodyHandle.getName, lambdaBodyHandle.getDesc, lambdaBodyHandle.isInterface) ownerMethod.instructions.insertBefore(invocation, bodyInvocation) val bodyReturnType = Type.getReturnType(lambdaBodyHandle.getDesc) -- cgit v1.2.3