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

Warnings about brotli (and other native libraries) in quarkus when using JDK 24+15 or better #44257

Open
zakkak opened this issue Nov 1, 2024 · 9 comments
Labels
kind/bug Something isn't working

Comments

@zakkak
Copy link
Contributor

zakkak commented Nov 1, 2024

Describe the bug

https://openjdk.org/jeps/472 got included with JDK 24. This means that JNI access will produce warnings when run with JDK 24 and certain restricted methods get called.

The warnings produced by the JDK are like the following:

WARNING: java.lang.System::loadLibrary has been called by com.aayushatharva.brotli4j.Brotli4jLoader in an unnamed module (file:/home/sgehwolf/Documents/openjdk/quarkus/quarkus-quickstarts/getting-started/target/getting-started-1.0.0-SNAPSHOT-native-image-source-jar/lib/com.aayushatharva.brotli4j.brotli4j-1.16.0.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

Expected behavior

No warnings should be shown.

Actual behavior

A warning is produced.

How to Reproduce?

export JAVA_HOME=/home/zakkak/jvms/jdk-24+20
./mvnw -pl integration-tests/vertx-http-compressors/all verify

Output of uname -a or ver

No response

Output of java -version

openjdk version "24-beta" 2025-03-18 OpenJDK Runtime Environment Temurin-24+20-202410171910 (build 24-beta+20-ea) OpenJDK 64-Bit Server VM Temurin-24+20-202410171910 (build 24-beta+20-ea, mixed mode, sharing)

Quarkus version or git rev

8077229

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

The output of the reproducer is:

...
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running io.quarkus.compressors.it.RESTEndpointsTest
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::loadLibrary has been called by com.aayushatharva.brotli4j.Brotli4jLoader in an unnamed module (file:/home/zakkak/.m2/repository/com/aayushatharva/brotli4j/brotli4j/1.16.0/brotli4j-1.16.0.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

2024-11-01 13:58:43,527 INFO  [io.quarkus] (main) quarkus-integration-test-vertx-http-compressors-all 999-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 0.860s. Listening on: http://localhost:8081
...
@zakkak zakkak added the kind/bug Something isn't working label Nov 1, 2024
@zakkak
Copy link
Contributor Author

zakkak commented Nov 1, 2024

I believe the way to fix this is to have Quarkus add the Enable-Native-Access: ALL-UNNAMED attribute to the jar manifests (and pass --enable-native-access=ALL-UNNAMED to java when not using a jar file, e.g. during unit tests).

@zakkak
Copy link
Contributor Author

zakkak commented Nov 1, 2024

I believe the way to fix this is to have Quarkus add the Enable-Native-Access: ALL-UNNAMED attribute to the jar manifests (and pass --enable-native-access=ALL-UNNAMED to java when not using a jar file, e.g. during unit tests).

A proof of concept only covering the runner jars can be seen in #44258

@geoand
Copy link
Contributor

geoand commented Nov 1, 2024

I believe the way to fix this is to have Quarkus add the Enable-Native-Access: ALL-UNNAMED attribute to the jar manifests (and pass --enable-native-access=ALL-UNNAMED to java when not using a jar file, e.g. during unit tests).

I was not aware of this!
Is this a general thing that will work with the various restrictions the JDK is putting in place?

@geoand
Copy link
Contributor

geoand commented Nov 1, 2024

when not using a jar file, e.g. during unit tests

I wonder if Maven surefire provides us a way to add entries to the manifest. @dmlloyd do you know perhaps?

@zakkak
Copy link
Contributor Author

zakkak commented Nov 4, 2024

Is this a general thing that will work with the various restrictions the JDK is putting in place?

That's my so far understanding.

@geoand
Copy link
Contributor

geoand commented Nov 4, 2024

Very interesting, I was not aware of that. If that is the case, it means that we can vastly improve the experience for users when down the line all these flags start to become necessary ...

@dmlloyd
Copy link
Member

dmlloyd commented Nov 4, 2024

For Surefire we should probably give JVM args. But one thing I'd be concerned about is that today, we might use --enable-native-access=ALL-UNNAMED, but in the future it might be e.g. --enable-native-access=io.quarkus.bootstrap or something like that. So we should hide this from the user if possible. Also, we can think about it for a little while at least, because this is still a warning.

@zakkak
Copy link
Contributor Author

zakkak commented Nov 4, 2024

So we should hide this from the user if possible.

How could one achieve that? In runner jars it's easy to achieve through the manifest entry, but in JVM args I guess it's not possible to hide it from verbose output.

Also, we can think about it for a little while at least, because this is still a warning.

+1 it's not a pressing issue, but even if it stays as a warning in JDK 25, it won't look good to have warnings popping up when using extensions that access native code.

@dmlloyd
Copy link
Member

dmlloyd commented Nov 4, 2024

So we should hide this from the user if possible.

How could one achieve that? In runner jars it's easy to achieve through the manifest entry, but in JVM args I guess it's not possible to hide it from verbose output.

I don't mean "hide" as in "secret", I mean "hide" as in "abstract it away from the user so we can change it later without affecting them".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants