[Native Image] Missing support for ServiceLoader
services registered via module-info
#9952
Open
1 of 2 tasks
Describe the Issue
Java Platform Module System defines a way to register services to be located by ServiceLoader. However there seems to be no support for such registrations in native image.
Using the latest version of GraalVM can resolve many issues.
GraalVM Version
I tried two versions:
GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30)
None of them works the way it "should". Looking at the code of ServiceLoaderFeature explains why it is not working - there is no ModuleLayer related code at all - which is probably necessary to extract information from the
module-info.class
of the modules on module path.Operating System and Version
Tested on Ubuntu, but this is cross OS problem
Diagnostic Flag Confirmation
-H:ThrowMissingRegistrationErrors=
flag.Run Command
I have prepared a special repository with NativeImageModuleDemo with a demo Maven project, follow the read me that suggests to:
e.g. two modules
Api
andImpl
are enabled andHi from Impl!
gets printed. While withnative-image
:e.g. two modules are enabled, but the
ServiceLoader.load
finds no implementation of the interface it is looking for.Expected Behavior
Native image version should work just like the JVM one:
Actual Behavior
Steps to Reproduce
I have prepared a special repository with NativeImageModuleDemo with a demo Maven project, follow the read me that suggests to:
e.g. two modules
Api
andImpl
are enabled andHi from Impl!
gets printed. While withnative-image
:e.g. two modules are enabled, but the
ServiceLoader.load
finds no implementation of the interface it is looking for.Additional Context
No response
Run-Time Log Output and Error Messages
No response
The text was updated successfully, but these errors were encountered: