RFR: 8357798: ReverseOrderListView allocates Boolean boxes

ExE Boss duke at openjdk.org
Tue May 27 07:07:54 UTC 2025


On Mon, 26 May 2025 17:08:45 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> SonarCloud complains that since [JDK-8356080](https://bugs.openjdk.org/browse/JDK-8356080) we are allocating and using `Boolean` boxes in `ReverseOrderListView`. This change `boolean` -> `Boolean` was made in [JDK-8356080](https://bugs.openjdk.org/browse/JDK-8356080) to allow `@Stable` folding of boolean field. But it is very awkward to trade in the object allocation on common path to allow optional constant folding.
> 
> We can flatten this field to `byte` and check the specific non-zero values. The field is final, so it is never actually in `0` state.
> 
> Additional testing:
>  - [x] Linux x86_64 server fastdebug, `java/util`

Well, this does at least make `ReverseOrderListView` have the same layout size as before [JDK‑8356080] and no longer grow when `‑XX:‑UseCompressedOops` is used.

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

Also, shouldn’t `ReverseOrderListView`’s `final` fields already be trusted to be immutable?

[JDK‑8356080]: https://bugs.openjdk.org/browse/JDK-8356080

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

PR Comment: https://git.openjdk.org/jdk/pull/25456#issuecomment-2911387045


More information about the core-libs-dev mailing list