Skip to content

Replace primitive wrapper constructors with valueOf() factory methods#2

Closed
trly wants to merge 1 commit into
mainfrom
wrapper-valueof-7b3f9c
Closed

Replace primitive wrapper constructors with valueOf() factory methods#2
trly wants to merge 1 commit into
mainfrom
wrapper-valueof-7b3f9c

Conversation

@trly

@trly trly commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Replaces deprecated primitive wrapper constructors (e.g. new Boolean(true),
new Integer(1)) with the recommended static .valueOf() factory methods
(Boolean.valueOf(true), Integer.valueOf(1)).

These constructors are deprecated since Java 9 because they always allocate a
new object, whereas .valueOf() can return cached instances. Covers
Boolean, Integer, Long, Double, Float, Short, Byte, and Character.

Scope notes:

  • Only single-argument constructor calls are rewritten (avoids no-arg and
    multi-arg constructors of unrelated local classes).
  • testData/ fixture directories are excluded to avoid breaking golden-file tests.
  • Files/dirs that define project-local classes shadowing java.lang wrapper
    names are excluded.

Generated mechanically with comby.

Created by Sourcegraph batch change travis.lyons/2463b5d8-1b2d-44f9-b052-188e686493b8.

@trly trly force-pushed the wrapper-valueof-7b3f9c branch from d59a387 to eaab771 Compare June 10, 2026 17:23
@trly trly marked this pull request as ready for review June 10, 2026 17:28
@trly trly closed this Jun 16, 2026
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