Use primitive wrapper valueOf method
MSALThe constructors of all primitive wrapper types have been deprecated in favor of using the static factory method valueOf available for each of the primitive type wrappers. Using valueOf enables object caching for frequently used values, reducing unnecessary heap allocations. Note that this changes identity semantics: valueOf may return cached instances (such as Boolean.TRUE or Integer values in [-128, 127]), so code that compares boxed values with ==/!=, relies on System.identityHashCode, or synchronizes on the boxed value may behave differently after this change. Enable onlyIfImmediatelyUnboxed to preserve allocations in contexts where wrapper identity can be observed.
org. openrewrite. staticanalysis. PrimitiveWrapperClassConstructorToValueOfOptional
Only replace constructors whose result is immediately unboxed in a primitive variable initializer, primitive cast, or primitive value accessor. This preserves fresh wrapper identity when references can escape. Defaults to false for the standalone migration; enabled by CommonStaticAnalysis.
mod run . --recipe= org. openrewrite. staticanalysis. PrimitiveWrapperClassConstructorToValueOfInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.