Skip to content

Add JVM --add-opens flags for Java 17 strong encapsulation workarounds#555

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776282012-java17-jvm-flags
Open

Add JVM --add-opens flags for Java 17 strong encapsulation workarounds#555
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776282012-java17-jvm-flags

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 15, 2026

Summary

Adds --add-opens JVM arguments to the test and bootRun tasks in build.gradle to handle Java 17's strong encapsulation of JDK internals. Three modules are opened to ALL-UNNAMED:

  • java.base/java.lang
  • java.base/java.lang.reflect
  • java.base/java.util

These 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 spotlessJava task has a separate IllegalAccessError (google-java-format accessing jdk.compiler internals) 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

  • Verify these three --add-opens flags 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
  • Run ./gradlew clean build -x spotlessCheck and ./gradlew bootRun locally with Java 17 to confirm no new illegal access warnings appear at runtime
  • Confirm no existing bootRun configuration elsewhere in the build that could conflict with the new block

Notes

  • The whitespace change on useJUnitPlatform() (tab → spaces) is intentional cleanup alongside the functional change
  • The spotless/google-java-format IllegalAccessError on Java 17 is a known issue that needs to be addressed separately (typically by upgrading the Spotless plugin or adding --add-opens to the Spotless task's own JVM args)

Link to Devin session: https://app.devin.ai/sessions/f32d7e86677744e381004de72ac6d100
Requested by: @shayanshafii


Open with Devin

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>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

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.

1 participant