RFR: 8288425: Footprint regression due MH creation when initializing StringConcatFactory

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed Jun 15 21:34:08 UTC 2022


On Tue, 14 Jun 2022 15:16:27 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> Avoid doing MH creation when initializing `StringConcatFactory` by lazily initializing to a `@Stable` field instead.

src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java line 729:

> 727:         MethodHandle base = PREPEND_BASE;
> 728:         if (base == null) {
> 729:             base = PREPEND_BASE = MethodHandles.dropArguments(

I'm curious about this idiom - couldn't this result in the `PREPEND_BASE` field being assigned twice, with objects that are morally identical, but could have different identities? (thus violating `@Stable` contract)

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

PR: https://git.openjdk.org/jdk/pull/9154


More information about the core-libs-dev mailing list