Replace boxed-primitive constructors with valueOf (CodeQL java/inefficient-boxed-constructor)#247
Open
vharseko wants to merge 2 commits into
Open
Conversation
…cient-boxed-constructor) Replace 17 uses of the deprecated boxed-primitive constructors (new Long/Integer/Short/Byte/Character/Float/Double(...)) with the corresponding X.valueOf(...) factory methods across 6 files. valueOf avoids an unnecessary allocation and may reuse cached instances; the change is behavior-preserving (equal values, same equals/hashCode). Verified by compiling persistit/core, persistit/ui and the jaspi jwt-session-module, plus javac for the persistit FindFile Ant example.
267cbf5 to
7dd40df
Compare
maximthomas
approved these changes
Jul 9, 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.
Summary
Resolves the CodeQL
java/inefficient-boxed-constructoralerts (17 open) by replacing deprecated boxed-primitive constructors with the correspondingvalueOf(...)factory methods.new Integer(x)/new Long(x)/ … always allocate a fresh object and have been deprecated since Java 9.X.valueOf(x)is the recommended form: it avoids the redundant allocation and may reuse cached instances. The change is behavior-preserving — equal values with identicalequals/hashCode; none of the touched sites rely on reference identity (==).Changes (17 replacements across 6 files)
AbstractJwtSessionModule.javaLongDefaultValueCoder.javaCharacterManagementImpl.javaInteger, 5×LongPersistit.javaIntegerFindFile.javaCharacterValueInspectorTreeNode.javaByte,Short,Character,Integer,Long,Float,DoubleVerification
persistit/core,persistit/uiand the jaspijwt-session-module(all clean).javacfor theFindFilepersistit Ant example (not part of the Maven reactor).Annotation of the fix is purely local (
new X(→X.valueOf(); arguments and surrounding expressions are unchanged.