RFR: 8285295: Need better testing for IdentityHashMap [v2]
Stuart Marks
smarks at openjdk.java.net
Wed May 4 18:46:21 UTC 2022
On Wed, 4 May 2022 15:02:43 GMT, liach <duke at openjdk.java.net> wrote:
>> test/jdk/java/util/IdentityHashMap/Basic.java line 500:
>>
>>> 498: Box newKey = new Box(k1a);
>>> 499: Box newVal = new Box(v1a);
>>> 500: Box r = map.computeIfAbsent(newKey, k -> { called[0] = true; return newVal; });
>>
>> More of a curiosity than a review comment - I see that various places in this PR use a boolean array with one element instead of just a boolean type. Is that a personal coding preference or is there something more to it?
>
> This just serves as a modifiable boolean like an AtomicBoolean. Remember lambdas can only use final local var references (due to how they work), and it cannot access or modify the local variable in the caller method.
Yes, that's it; you can't mutate a local variable captured by a lambda.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8354
More information about the core-libs-dev
mailing list