Suppress sun.misc.Unsafe and JNA native-access warnings on Java 23+#1408
Draft
nevingeorgesunny wants to merge 1 commit into
Draft
Suppress sun.misc.Unsafe and JNA native-access warnings on Java 23+#1408nevingeorgesunny wants to merge 1 commit into
nevingeorgesunny wants to merge 1 commit into
Conversation
On Java 24+, XStream's SunUnsafeReflectionProvider triggers a terminally
deprecated sun.misc.Unsafe warning by default (JEP 498). JNA similarly
warns about restricted native access on Java 23+. Both warnings pollute
test output on Java 25 but are harmless — no tests fail.
This adds a Java 23+ profile that injects two JVM flags into Surefire's
argLine via late-binding @{jenkins.java23Plus}:
- --sun-misc-unsafe-memory-access=allow (silences XStream Unsafe warning)
- --enable-native-access=ALL-UNNAMED (silences JNA native-access warning)
The flags are gated behind a [23,) profile so they are never passed to
Java 17 or 21, where they would cause an unrecognized VM option error.
Relates to: https://issues.jenkins.io/browse/JENKINS-65837
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jglick
approved these changes
Jun 30, 2026
jglick
left a comment
Member
There was a problem hiding this comment.
For the short term I think this makes sense. We do still need to get XStream to behave properly on 23+ (especially before it breaks by default on 26+ or whatever it is 😱), and we do need to find ways to eliminate JNA (and JNI) in normal usage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Java 24+, XStream's
SunUnsafeReflectionProvidertriggers a terminally deprecatedsun.misc.Unsafewarning by default (JEP 498). JNA similarly warns about restricted native access on Java 23+. Both warnings are harmless — no tests fail — but they produce significant noise in test output (2,000+ warnings per PCT/ATH build run on Java 25).This adds a Java 23+ Maven profile that injects two JVM flags into Surefire's
argLinevia late-binding@{jenkins.java23Plus}:--sun-misc-unsafe-memory-access=allow— silences XStreamsun.misc.Unsafedeprecation warning (x-stream/xstream#362)--enable-native-access=ALL-UNNAMED— silences JNA restricted native-access warningThe flags are gated behind a
[23,)profile so they are never passed to Java 17 or 21, where they would cause anUnrecognized VM optionerror and break the build.