Skip to content
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

jdk15 MethodHandle.rebind() stubbed but used #9771

Closed
pshipton opened this issue Jun 2, 2020 · 8 comments
Closed

jdk15 MethodHandle.rebind() stubbed but used #9771

pshipton opened this issue Jun 2, 2020 · 8 comments

Comments

@pshipton
Copy link
Member

pshipton commented Jun 2, 2020

https://ci.eclipse.org/openj9/job/Pipeline-OpenJDK-Acceptance/258/

22:55:19  Exception in thread "main" java.lang.InternalError: Compile stub invoked! Apart from deliberate reflective access, this should not happen. Please report this to the project so it can be addressed
22:55:19  	at java.base/java.lang.invoke.OpenJDKCompileStub.OpenJDKCompileStubThrowError(OpenJDKCompileStub.java:38)
22:55:19  	at java.base/java.lang.invoke.MethodHandle.rebind(MethodHandle.java:1479)
22:55:19  	at java.base/java.lang.invoke.StringConcatFactory.simpleConcat(StringConcatFactory.java:657)
22:55:19  	at java.base/java.lang.invoke.StringConcatFactory.generateMHInlineCopy(StringConcatFactory.java:458)
22:55:19  	at java.base/java.lang.invoke.StringConcatFactory.makeConcatWithConstants(StringConcatFactory.java:354)
22:55:19  	at java.base/java.lang.invoke.MethodHandle.invokeBsm(MethodHandle.java:1070)
22:55:19  	at java.base/java.lang.invoke.MethodHandle.resolveInvokeDynamic(MethodHandle.java:1200)
22:55:19  	at jdk.jlink/jdk.tools.jlink.internal.Utils.getPathMatcher(Utils.java:97)
22:55:19  	at jdk.jlink/jdk.tools.jmod.JmodTask$PathMatcherConverter.convert(JmodTask.java:1173)
22:55:19  	at jdk.jlink/jdk.tools.jmod.JmodTask$PathMatcherConverter.convert(JmodTask.java:1169)
22:55:19  	at jdk.internal.opt/jdk.internal.joptsimple.internal.Reflection.convertWith(Reflection.java:154)
22:55:19  	at jdk.internal.opt/jdk.internal.joptsimple.AbstractOptionSpec.convertWith(AbstractOptionSpec.java:120)
22:55:19  	at jdk.internal.opt/jdk.internal.joptsimple.ArgumentAcceptingOptionSpec.convert(ArgumentAcceptingOptionSpec.java:308)
22:55:19  	at jdk.internal.opt/jdk.internal.joptsimple.OptionSet.valuesOf(OptionSet.java:253)
22:55:19  	at jdk.jlink/jdk.tools.jmod.JmodTask.handleOptions(JmodTask.java:1397)
22:55:19  	at jdk.jlink/jdk.tools.jmod.JmodTask.run(JmodTask.java:168)
22:55:19  	at jdk.jlink/jdk.tools.jmod.Main.main(Main.java:34)

Blocking compilation of jdk15.

@pshipton
Copy link
Member Author

pshipton commented Jun 2, 2020

@DanHeidinga pls take a look.

@DanHeidinga
Copy link
Member

@andrew-m-leonard Can we get a high level description of what rebind is doing? I don't see any javadoc for it

@babsingh
Copy link
Contributor

I don't think we can support MethodHandle.rebind in OpenJ9 until we adopt the OpenJDK MethodHandles. rebind returns a BoundMethodHandle, and the OpenJ9 MethodHandle implementation doesn't support it. Created ibmruntimes/openj9-openjdk-jdk15#1 [WIP] to temporarily address this issue.

@andrew-m-leonard
Copy link
Contributor

andrew-m-leonard commented Jun 16, 2020

@DanHeidinga
rebind is implemented by BoundMethodHandle, basic description:
BoundMethodHandle.rebind():
if BoundMethodHandle "complexity" of fields and expressions is above a certain "threshold" then
return a new BoundMethodHandle based on a LambdaForm that reinvokes a target for the same type
else
return this

So you could as a wrapper just return "this"...

If the MethodHandle is not a BoundMethodHandle then it basically just does:
return a new BoundMethodHandle based on a LambdaForm that reinvokes a target for the same type

@babsingh
Copy link
Contributor

So you could as a wrapper just return "this"...

I did try returning this. BoundMethodHandle only exists as a stub in OpenJ9. Also, rebind is defined in class MethodHandle. Since OpenJ9 does not support BoundMethodHandle, this won't be an instance of BoundMethodHandle in OpenJ9. Returning this leads to other compiler errors where the return value of rebind is expected to be an instance of BoundMethodHandle.

@babsingh
Copy link
Contributor

returning a new BoundMethodHandle from rebind ...

I also tried the above approach. Firstly, BoundMethodHandle is an abstract class. So, you can't return a new instance of BoundMethodHandle. Secondly, BoundMethodHandle extends MethodHandle and introduces new methods, which are not available in MethodHandle. We will need to locate concrete MethodHandle classes which extends the abstract BoundMethodHandle. Then, we will need to support all the new methods in the abstract BoundMethodHandle. I don't think there is a quick solution to support BoundMethodHandle.

I feel that finishing the current work on adopting OpenJDK MethodHandle(s) is the best-path to support BoundMethodHandle.

@pshipton
Copy link
Member Author

pshipton commented Jun 30, 2020

@babsingh not sure if we need to keep this open as a reminder to fix the stubs?

@babsingh
Copy link
Contributor

I had opened #9895 to track all such issues so that we can revert their fix once OpenJ9 adopts OpenJDK MH. We can probably close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants