-
Notifications
You must be signed in to change notification settings - Fork 249
Add JAR integration test for JDK compatibility #704
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
Conversation
Add the Enable-Native-Access: ALL-UNNAMED attribute to the JAR manifest to suppress native access warnings on JDK 24+ without requiring users to add the --enable-native-access=ALL-UNNAMED command-line flag. This manifest attribute allows the library to declare its need for native access, which helps suppress the warnings introduced by JEP 472 when snappy-java loads native libraries via JNI. Benefits: - Users no longer need to add JVM flags for basic usage - Warnings are suppressed automatically when the JAR is on the classpath - Backwards compatible with all JDK versions (attribute is ignored on JDK < 24) Related to #689 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary of ChangesHello @xerial, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the user experience for snappy-java users running on JDK 24 and newer by automatically handling native access permissions. It integrates a specific manifest attribute into the JAR, which allows the JVM to grant necessary native access without requiring any manual configuration or command-line flags from the user, thus streamlining deployment and reducing potential friction. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds the Enable-Native-Access: ALL-UNNAMED manifest attribute to handle native access warnings in JDK 24+. The change is straightforward and well-explained. I have one suggestion to improve the robustness of the sbt build configuration by using ++= instead of := to avoid overwriting other package options.
build.sbt
Outdated
| packageOptions := Seq( | ||
| Package.ManifestAttributes("Enable-Native-Access" -> "ALL-UNNAMED") | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this might work in the current configuration, using := overwrites any previously defined package options. It is safer and more idiomatic in sbt to append to sequence-based settings like packageOptions using ++=. This will prevent potential conflicts with other plugins (like the sbt-osgi plugin enabled in this project) or other settings that might also be adding manifest attributes.
packageOptions ++= Seq(
Package.ManifestAttributes("Enable-Native-Access" -> "ALL-UNNAMED")
)
Add a comprehensive integration test that verifies snappy-java works in a separate JVM process. This test: 1. Builds the JAR with sbt 2. Compiles a simple test program that uses snappy-java 3. Runs the test in a fresh JVM WITHOUT --enable-native-access flag 4. Verifies the compression/decompression works correctly 5. Checks for JEP 472 warnings on JDK 24+ The test can be run two ways: - Via JUnit: testOnly org.xerial.snappy.JarManifestIntegrationTest - Via script: ./script/test-jar-integration.sh Findings: The Enable-Native-Access manifest attribute is present but does NOT suppress warnings when the JAR is used as a library on the classpath. The attribute only works for executable JARs (java -jar). Users still need to add --enable-native-access=ALL-UNNAMED for now. Related to #689 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Changes: - Remove Enable-Native-Access manifest attribute (doesn't work for library JARs) - Remove unused JUnit integration test (using shell script instead) - Add JAR integration test to CI workflow for all JDK versions The integration test now runs in CI after regular tests, verifying that the built JAR works correctly in a separate JVM process on each tested JDK version (8, 11, 17, 21, 25). Related to #689 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The manifest check is no longer needed since we decided not to include the Enable-Native-Access attribute. Related to #689 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Details
This PR adds a comprehensive integration test that validates the snappy-java JAR functions correctly when used as a library.
What's included
Integration test script (
script/test-jar-integration.sh):--enable-native-accessflagCI integration:
Test program (
src/test/resources/integration/SnappyIntegrationTest.java):Example output (JDK 25)
Key findings
✅ JAR works correctly on all JDK versions - compression/decompression succeeds
⚠️ JDK 24+ shows warnings - expected behavior per JEP 472
ℹ️ Users need
--enable-native-access=ALL-UNNAMED- as documented in #702This test confirms that:
Why no manifest attribute?
We initially tried adding
Enable-Native-Access: ALL-UNNAMEDto the JAR manifest, but testing showed it does not suppress warnings when snappy-java is used as a library on the classpath. Per JEP 472, that attribute only works for executable JARs launched viajava -jar.Test plan
Run locally:
./script/test-jar-integration.shRelated to #689
🤖 Generated with Claude Code