-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
ServiceLoader based on module-info.java not working #7634
Comments
Hi @codepitbull , |
Thanks for your answer! I am aware of the old way, but I was looking at doing this using JPMS. So, is JPMS not fully supported on Graal? |
Thanks, Issue reproduced and we are looking into it |
With 21.0.2, even if the META-INF/services files are there, they are not recognized and ServiceLoader does not work. JVMs work fine, native-image only works using classpath instead of module-path. |
I am also seeing this issue, has any progress been made? |
Yes this seems like it is pretty bad and hurts module-info uptake. Someone developing a CLI might want to have a JLink option which would use the modulepath and then a native option for supported platforms and they would have to run it on the classpath which would actually change behavior. |
Older version of GraalVM (CE 11) is able to successfully produce a native image, where services defined in a Newer version (latest current Oracle GraalVM 21 as of 24/09/2024) produces an image that does not discover the services. I have not checked which release of GraalVM has actually broken this behaviour. |
Hi @codepitbull, thanks for your reproducer. I have looked into the issue and we now know where the problem is. I will keep you updated. |
Yes, exploiting the LazyClassPathLookupIterator at image-runtime to do the lookup worked until we actually started to implement module-system more correctly at image runtime. Now that we do, LazyClassPathLookupIterator is able to detect that it is actually not supposed to do the lookup for a Service Provider implementation Class that comes from a named module. So the hack from back then does not work anymore. See #9952 (comment) for more info. |
Hi @codepitbull! The fix that relates to this ticket has been merged (#10202) and will be part of GraalVM 24.2 |
Describe the issue
I am currently experimenting with JPMS on Java 21 and GraalVM.
I discovered using services defined in a different module than the main one aren't picked up.
Steps to reproduce the issue
Clone the reproducer:
git clone --depth 1 https://github.com/codepitbull/graalvm-bug-java21.git
There is an app module with a dependency on the dependency module defined:
The dependency defines the interface and the service implementation:
The expctation would be that the app sees the defined service when a native image is built.
Build java only
./gradlew :app:build
Output:
This shows the service is discovered running regular Java.
Build with native-image
./gradlew :app:nativeBuild
app/build/native/nativeBuild/app
Output:
This shows that the service is not discovered when using the native build.
Build image natively (to avoid possible Gradle-plugin issues)
Output:
Again, service not resolved.
Describe GraalVM and your environment:
The text was updated successfully, but these errors were encountered: