Skip to content

Conversation

erguiti-imane
Copy link
Member

fix: add reachability metadata for jjwt-jackson 0.12.0

  • Updated test usage to Jwts.parser() instead of parserBuilder() to align with jjwt-jackson 0.12.0 API.
  • Ensures native-image-agent can generate metadata without crashing due to illegal reflective access.
  • Added required JVM arguments to the test task to allow reflective access to internal JDK classes:
    • --add-opens=java.base/sun.security.util=ALL-UNNAMED
    • --add-opens=java.base/java.io=ALL-UNNAMED
  • Generated reflect-config.json is now valid for jjwt-jackson 0.12.0.

What does this PR do?

Code sections where the PR accesses files, network, docker or some external service

  • (example link to code section)

Checklist before merging

@erguiti-imane erguiti-imane requested a review from a team as a code owner June 5, 2025 19:47
@erguiti-imane erguiti-imane requested a review from fniephaus June 5, 2025 19:47
@@ -41,3 +41,9 @@ dependencies {
test {
useJUnitPlatform()
}
tasks.named('test') {
jvmArgs(
'--add-opens=java.base/sun.security.util=ALL-UNNAMED',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you really need --add-opens= here. What error message do you get when you don not use these two --add-opens?

Copy link
Member Author

@erguiti-imane erguiti-imane Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olpaw Yes, the --add-opens flags are required for JJWT 0.12.0 specifically. Without these flags, all tests fail with:

java.lang.IllegalAccessException: class io.jsonwebtoken.impl.lang.OptionalMethodInvoker cannot access class sun.security.util.KeyUtil (in module java.base) because module java.base does not export sun.security.util to unnamed module @26275bef 

This is a documented bug in JJWT 0.12.0 when running on Java 17+, tracked in JJWT issue #849, the issue was fixed in 0.12.2.

Adjusted 'Jwts.parserBuilder()' to 'Jwts.parser()' to match jjwt-jackson 0.12.0.

Added necessary JVM args to allow reflective access for native-image-agent:

- '--add-opens=java.base/sun.security.util=ALL-UNNAMED'
- '--add-opens=java.base/java.io=ALL-UNNAMED'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants