RFR: 8274811: Remove superfluous use of boxing in java.base

Andrey Turbanov github.com+741251+turbanoff at openjdk.java.net
Wed Oct 6 07:23:22 UTC 2021


On Sat, 11 Sep 2021 17:22:01 GMT, Сергей Цыпанов <github.com+10835776+stsypanov at openjdk.org> wrote:

>> Usages of primitive types should be preferred and makes code easier to read.
>> Similar cleanups:
>> 1. [JDK-8273168](https://bugs.openjdk.java.net/browse/JDK-8273168) java.desktop
>> 2. [JDK-8274234](https://bugs.openjdk.java.net/browse/JDK-8274234) java.sql.rowset
>
> src/java.base/share/classes/java/util/ResourceBundle.java line 3732:
> 
>> 3730:     }
>> 3731: 
>> 3732:     private static final boolean TRACE_ON = Boolean.parseBoolean(
> 
> I think for `Boolean` it doesn't make significant difference, as both `Boolean.TRUE` and `Boolean.FALSE` are cached and initialized immediately along with the class itself:
> 
> public static Boolean valueOf(String s) {
>   return parseBoolean(s) ? TRUE : FALSE;
> }

Yes, there is no allocation for booleans. But still 2 redundant method calls in interpreter mode (valueOf+booleanValue)

-------------

PR: https://git.openjdk.java.net/jdk/pull/5481


More information about the security-dev mailing list