Skip to content

Replace deprecated primitive wrapper constructors with valueOf()#5

Draft
trly wants to merge 1 commit into
mainfrom
replace-wrapper-constructors-97a85097-4942-49c5-a8b7-dcf227effeb5
Draft

Replace deprecated primitive wrapper constructors with valueOf()#5
trly wants to merge 1 commit into
mainfrom
replace-wrapper-constructors-97a85097-4942-49c5-a8b7-dcf227effeb5

Conversation

@trly

@trly trly commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

The primitive wrapper constructors (new Boolean(...), new Integer(...), etc.)
are deprecated for removal (JEP 390, https://openjdk.org/jeps/390). They always
allocate a new object, defeating value caching, and are misleading about identity.

This change replaces them with the recommended valueOf(...) factory methods,
which may return cached instances and clearly express value semantics.

See https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Boolean.html#%3Cinit%3E(boolean)

Test sources were excluded.

Created by Sourcegraph batch change travis.lyons/97a85097-4942-49c5-a8b7-dcf227effeb5.

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