-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Shadowing Graal as library with relocation fails due to native bindings #10907
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
Comments
Relocation is not tested and not supported on our end. That it worked for you in previous versions was luck. We can add a test for this and fix potential issues in the future, but you need to provide a reproducer for us that we can integrate in our CI. |
Thanks for the reply @chumer. |
I cannot promise it. It depends on what the problems are that we will see. |
As promised, here is the minimal reproducible example: https://github.com/rubensworks/graal-shadow-relocation-mre I'm happy to help moving this forward any way I can. |
As you can see from the error its failing in JNI bindings which require a stable class name. You say fallback runtime is enough? So bad performance is ok? |
One option could be to make the JNI method registration dynamic, and allow a package prefix to be set somehow. This is what they did in netty a while ago, to solve similar issues (netty/netty#4800): Scottmitch/netty@47ae721
I think the current explicit error is fine. A fallback with bad performance might be more annoying for users to debug, unless a warning is emitted somehow. |
We can look into that. Thanks for the suggestion.
Whatever we do we cannot change package names for the optimizing runtime, we currently can attach only one optimizing runtime for Java VM. So your language will always run with the fallback runtime and in interpreted-only mode. |
Great! Do let me know if there's any way I can be of assistance.
Maybe I'm misunderstanding things. |
The current crash is for some other use of JNI that relates to all runtimes, which might be fixable.
We do print a warning by default if the optimizing runtime could not be used and we switch to the fallback runtime. So the consistent thing to do would be to gracefully handle the case (we can detect it by checking for the package name). |
Ok, got it, thanks for the clarification @chumer! |
Describe the issue
I am using GraalVM + GraalJS in a project (a Minecraft mod) in which I must shadow (+relocate, e.g.
'org.graalvm'
to'org.cyclops.integratedscripting.vendors.org.graalvm'
) these libraries. (shadow+relocate is needed for players using Graal as their JRE)When updating from Graal 22.3.2 to 24.2.0, I am not able to relocate the
com.oracle.truffle.polyglot
package anymore due to the native bindings that have been introduced in theJDKSupport
class.As a workaround, I exclude the
com.oracle.truffle.polyglot
package from relocation when building.This is unfortunately causing conflicts with other similar projects (Minecraft mods) that are shadowing GraalVM + GraalJS in a similar manner (CyclopsMC/IntegratedScripting#34).
Does anyone here know a way to work around this problem?
Ideally, I'd want to relocate
com.oracle.truffle.polyglot
as well, but, AFAIK, relocation of native bindings is not possible.One alternative solution I see is to inject a package prefix for native bindings, similar to the
io.netty.packagePrefix
in netty. But I could not find such functionality here based on some searching.Steps to reproduce the issue
Reproduction is a bit complicated, so I would not recommend trying, but I could provide steps upon request.
Describe GraalVM and your environment:
Additional Context
This is the shadow config (with excluded relocation) I am using:
https://github.com/CyclopsMC/IntegratedScripting/blob/master-1.21-lts/build.gradle#L260-L272
The text was updated successfully, but these errors were encountered: