Skip to content

docs: document the identity contract of the serializer constant labels - #1898

Open
velo wants to merge 1 commit into
masterfrom
document-constant-label-identity-contract
Open

docs: document the identity contract of the serializer constant labels#1898
velo wants to merge 1 commit into
masterfrom
document-constant-label-identity-contract

Conversation

@velo

@velo velo commented Aug 19, 2026

Copy link
Copy Markdown
Member

Documentation only, no behaviour change.

SerializerBase.constantToLabel is an IdentityHashMap keyed on arbitrary
constants supplied by the caller, and getConstantToLabel() exposes it as public
API. Nothing said so, which matters in two directions:

  • A dialect that overrides serializeConstant to bind by label depends on
    the identity keying; one that binds positionally (JPA and SQL both do) does not.
  • It is a deliberate identity dependency on user values. JEP 401 (Value Objects,
    preview in JDK 28) migrates the primitive wrappers and LocalDate to value
    classes, at which point == and identityHashCode become state-based and the
    map starts collapsing equal-but-distinct constants onto one label.

Added javadoc on the field and the accessor recording both, and pointed at
SerializerBaseTest, which pins the current behaviour.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WnNBe1GoG2SxfU3FN7bcAA

Signed-off-by: Marvin Froeder <velo.br@gmail.com>
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