Skip to content

Conversation

@lrytz
Copy link
Member

@lrytz lrytz commented Oct 9, 2016

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.

Fixes scala/scala-dev#242

@scala-jenkins scala-jenkins added this to the 2.12.0-RC2 milestone Oct 9, 2016
@lrytz
Copy link
Member Author

lrytz commented Oct 9, 2016

I vote for putting this into RC2..

INVOKESPECIAL
}
val isInterface = bodyOpcode == INVOKEINTERFACE
val isInterface = classBTypeFromInternalName(lambdaBodyHandle.getOwner).isInterface.get
Copy link
Member

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.)

Copy link
Member

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!

Copy link
Member Author

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.
@retronym
Copy link
Member

retronym commented Oct 9, 2016

LGTM. 👍 for 2.12.0

@adriaanm adriaanm merged commit d7fe049 into scala:2.12.0 Oct 10, 2016
retronym added a commit to retronym/scala that referenced this pull request Oct 13, 2016
@adriaanm adriaanm added the 2.12 label Oct 29, 2016
@lrytz lrytz deleted the sd242 branch April 12, 2017 07:53
smarter added a commit to dotty-staging/scala that referenced this pull request Sep 17, 2017
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).
smarter added a commit to lampepfl/scala that referenced this pull request Oct 12, 2017
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).
smarter added a commit to dotty-staging/scala that referenced this pull request Aug 23, 2018
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).
smarter added a commit to dotty-staging/scala that referenced this pull request Aug 23, 2018
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants