Repository navigation
Use the canonical constructor when mapping Java record inputs - #2361
Merged
jjacobs44 merged 1 commit intoOct 19, 2026
Merged
Conversation
Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
auraseb
requested review from
asibross,
iparadiso,
iuliiasobolevska,
jjacobs44,
kzwang,
paulbakker and
srinivasankavitha
as code owners
October 18, 2026 02:49
jjacobs44
approved these changes
Oct 19, 2026
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.
Pull request checklist
first
Pull Request type
Changes in this PR
DefaultInputObjectMapper.handleRecordClassuseddeclaredConstructors.first()to build a record. The order ofgetDeclaredConstructors()is unspecified, and when a record declares a convenience constructor HotSpot returns that one first, so mapping failed withIllegalArgumentException: wrong number of arguments.The mapper now looks up the canonical constructor by the record component types, which is how the canonical constructor is defined by the JLS.
Tests added in
InputObjectMapperTest:RecordInput, which existed as a fixture but was not used by any test)RecordInputWithSecondaryConstructor), which fails on master and passes with this changeIssue #
Alternatives considered
Filtering
declaredConstructorsby parameter count. That still picks the wrong constructor when a second constructor has the same arity, so looking it up by component types is the precise option.Fixes #2360