-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix the interface flag when re-writing a closure call to the body method #5452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I vote for putting this into RC2.. |
@@ -325,7 +325,7 @@ class ClosureOptimizer[BT <: BTypes](val btypes: BT) { | |||
insns.insertBefore(invocation, new InsnNode(DUP)) | |||
INVOKESPECIAL | |||
} | |||
val isInterface = bodyOpcode == INVOKEINTERFACE | |||
val isInterface = classBTypeFromInternalName(lambdaBodyHandle.getOwner).isInterface.get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we ever hit a case where we don't classBTypeFromInternalName.apply
or .get
fails, say if the lambda target class was not in the current compilation classpath? (Maybe a lambda had previously been inlined into the class from which we are inlining.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, we can just call lambdaBodyHandle.isInterface
here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, used that instead
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.
LGTM. 👍 for 2.12.0 |
We need this to close the loop on scala#5452.
The itf flag of `visitMethodInsn` and `Handle` in ASM needs to be true when the method is defined in an interface. Java 8 ignores this but Java 9 fails at runtime with: java.lang.IncompatibleClassChangeError: Method ... must beInterfaceMethodref constant This commit is inspired by similar changes in scalac, in particular see 7d51b3f by Jason Zaugg (from scala#5251) and e619b03 by Lukas Rytz (from scala#5293). This issue was also discussed in scala#5452 (which does not matter for Dotty since we do not run the backend optimizer).
The itf flag of `visitMethodInsn` and `Handle` in ASM needs to be true when the method is defined in an interface. Java 8 ignores this but Java 9 fails at runtime with: java.lang.IncompatibleClassChangeError: Method ... must beInterfaceMethodref constant This commit is inspired by similar changes in scalac, in particular see 7d51b3f by Jason Zaugg (from scala#5251) and e619b03 by Lukas Rytz (from scala#5293). This issue was also discussed in scala#5452 (which does not matter for Dotty since we do not run the backend optimizer).
The itf flag of `visitMethodInsn` and `Handle` in ASM needs to be true when the method is defined in an interface. Java 8 ignores this but Java 9 fails at runtime with: java.lang.IncompatibleClassChangeError: Method ... must beInterfaceMethodref constant This commit is inspired by similar changes in scalac, in particular see 7d51b3f by Jason Zaugg (from scala#5251) and e619b03 by Lukas Rytz (from scala#5293). This issue was also discussed in scala#5452 (which does 85E1 not matter for Dotty since we do not run the backend optimizer).
The itf flag of `visitMethodInsn` and `Handle` in ASM needs to be true when the method is defined in an interface. Java 8 ignores this but Java 9 fails at runtime with: java.lang.IncompatibleClassChangeError: Method ... must beInterfaceMethodref constant This commit is inspired by similar changes in scalac, in particular see 7d51b3f by Jason Zaugg (from scala#5251) and e619b03 by Lukas Rytz (from scala#5293). This issue was also discussed in scala#5452 (which does not matter for Dotty since we do not run the backend optimizer).
When re-writing a closure invocation to the body method, the
itf
flagof 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.
Fixes scala/scala-dev#242