RFR: 8355753: @SuppressWarnings("this-escape") not respected for indirect leak via field [v3]
Vicente Romero
vromero at openjdk.org
Fri May 30 13:43:54 UTC 2025
On Fri, 30 May 2025 13:23:24 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:
>> right, would an array be less heavy? not beautiful either
>
>> right, would an array be less heavy? not beautiful either
>
> If by "heavy" you mean optimization/efficiency, honestly I have no idea about that... that gets into a level of JVM optimization granularity beyond my knowledge.
>
> As for "beauty", yes using an array is a common trick for this, but IMHO doing so is more obscure than using `AtomicReference` because there is no "arrayness" here. You are just using the array as a thing that contains a single mutable reference - i.e., exactly what `AtomicReference` does. Of course, we don't care about the "atomic" part, so that's slightly confusing too.
>
> There's no perfect answer. It makes me wonder... maybe someday we could make stateful lambdas easier, e.g.:
>
> Runnable r = () -> {
> static int count;
> System.out.println("Invoked " + ++count + " times");
> };
right, definitely there is a need for stateful lambdas
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24932#discussion_r2115948713
More information about the compiler-dev
mailing list