-
Notifications
You must be signed in to change notification settings - Fork 794
Add JPMS compatibility to Jackson JSON 2 mapper by configuring ObjectMapper to work without --add-opens JVM flags. #754
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
Open
nknize
wants to merge
1
commit into
modelcontextprotocol:main
from
nknize:feature/jpms-compatibility
Open
+180
−4
Conversation
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
@nknize
nknize
force-pushed
the
feature/jpms-compatibility
branch
from
January 26, 2026 05:00
3e48ba9 to
d93ba3d
Compare
Configure ObjectMapper with JPMS-compatible settings: - Disable CAN_OVERRIDE_ACCESS_MODIFIERS to prevent setAccessible() calls - Add ParameterNamesModule to discover constructor parameter names from bytecode instead of reflection This allows applications using the MCP SDK to operate without `--add-opens` JVM flags, enabling full JPMS module encapsulation. The SDK already compiles with `-parameters` flag, which is required for ParameterNamesModule to function. Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
@nknize
nknize
force-pushed
the
feature/jpms-compatibility
branch
from
January 27, 2026 00:42
d93ba3d to
ee6444c
Compare
Author
Rebased to Jackson 2 due to the recent Jackson 3 merge. Some projects still have transitive dependencies on Jackson 2 and can't rely on a Jackson 3 migration. This retains JPMS support for Jackson 2.
@nknize
nknize
changed the title
(削除) Add JPMS compatibility to Jackson JSON mapper by configuring ObjectMapper to work without --add-opens JVM flags. (削除ここまで)
(追記) Add JPMS compatibility to Jackson JSON 2 mapper by configuring ObjectMapper to work without --add-opens JVM flags. (追記ここまで)
Jan 27, 2026
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.
Motivation and Context
Applications using the MCP Java SDK with JPMS (Java Platform Module System) currently require --add-opens JVM flags because the Jackson ObjectMapper uses setAccessible() to access record constructors. This breaks module encapsulation and prevents full JPMS adoption.
This change configures the ObjectMapper to:
CAN_OVERRIDE_ACCESS_MODIFIERSto preventsetAccessible()callsParameterNamesModuleto discover constructor parameter names from bytecodeThe SDK already compiles with
-parameters, so no additional build configuration is needed.How Has This Been Tested?
JpmsCompatibilityTeststhat verify record deserialization works without reflectionCAN_OVERRIDE_ACCESS_MODIFIERSis disabled via configuration testBreaking Changes
None. This is a transparent configuration change. Applications that previously worked will continue to work, and applications that required
--add-opensflags can now remove them.Types of changes
Checklist
Additional context
Resolves #753
The
ParameterNamesModuledependency is already transitively available via Jackson, but is now explicitly declared inpom.xmlfor clarity.