graal icon indicating copy to clipboard operation
graal copied to clipboard

[Native Image] Resource registration takes precedence over ServiceLoaderFeatureExcludeServices flag

Open ma-hab opened this issue 2 months ago • 1 comments

Describe the Issue

There seems to a bug when using native image with spring and hibernate as described here where one hand we have -H:ServiceLoaderFeatureExcludeServices=org.hibernate.bytecode.spi.BytecodeProvider flag while on other hand that same class is registered in resource-config.json (which could happen by accident through tracing agent usage).

Now, the behavior seems to be that resource registration takes precedence over ServiceLoaderFeatureExcludeServices which means that if some class is excluded with ServiceLoaderFeatureExcludeServices0 it will still be included if it is registered as resource which in my opinion should not happen.

If this is intended behavior for valid reason then please close this.

Using the latest version of GraalVM can resolve many issues.

GraalVM Version

21.0.2

Operating System and Version

Debian 6.1.140-1 (2025-05-22) aarch64 GNU/Linux

Build Command

Through org.graalvm.buildtools native-maven-plugin with ./mvnw -Pnative package

Expected Behavior

If some class is excluded with ServiceLoaderFeatureExcludeServices and at the same time it is registered as resource, it should not be included

Actual Behavior

If some class is excluded with ServiceLoaderFeatureExcludeServices, it will still be included if it is registered as resource

Steps to Reproduce

Described here

Additional Context

No response

Build Log Output and Error Messages

No response

ma-hab avatar Sep 22 '25 12:09 ma-hab