Add JVM --add-opens flags for Java 17 strong encapsulation workarounds#555
Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Open
Add JVM --add-opens flags for Java 17 strong encapsulation workarounds#555devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Conversation
Add JVM flags to test and bootRun tasks to open java.base modules (java.lang, java.lang.reflect, java.util) to unnamed modules. These flags are proactively added for the Spring Boot 2.7.x + MyBatis + Java 17 tech stack to prevent potential InaccessibleObjectException and IllegalAccessError at runtime. While tests currently pass without them, these modules are commonly accessed reflectively by Spring Framework, MyBatis, Jackson, and jjwt libraries. Note: The spotlessJava task has a separate IllegalAccessError (google-java-format accessing jdk.compiler internals) which requires Spotless plugin configuration changes, not test/bootRun JVM flags. Co-Authored-By: shayan <shayan@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Adds
--add-opensJVM arguments to thetestandbootRuntasks inbuild.gradleto handle Java 17's strong encapsulation of JDK internals. Three modules are opened toALL-UNNAMED:java.base/java.langjava.base/java.lang.reflectjava.base/java.utilThese are proactively added for the Spring Boot 2.7.x + MyBatis + Jackson + jjwt stack, which commonly uses reflective access to these modules. During testing, compilation and all tests passed without these flags, but they are known to be needed at runtime for this tech stack to prevent
InaccessibleObjectException.Note: The
spotlessJavatask has a separateIllegalAccessError(google-java-format accessingjdk.compilerinternals) that is not addressed by this PR, as it requires Spotless plugin configuration changes rather than test/bootRun JVM flags.Review & Testing Checklist for Human
--add-opensflags are sufficient for runtime — consider whether additional modules (e.g.,java.base/java.io,java.base/sun.security.ssl) may be needed for jjwt or Spring Security./gradlew clean build -x spotlessCheckand./gradlew bootRunlocally with Java 17 to confirm no new illegal access warnings appear at runtimebootRunconfiguration elsewhere in the build that could conflict with the new blockNotes
useJUnitPlatform()(tab → spaces) is intentional cleanup alongside the functional changeIllegalAccessErroron Java 17 is a known issue that needs to be addressed separately (typically by upgrading the Spotless plugin or adding--add-opensto the Spotless task's own JVM args)Link to Devin session: https://app.devin.ai/sessions/f32d7e86677744e381004de72ac6d100
Requested by: @shayanshafii