On Thu, 7 Aug 2025 18:39:14 GMT, Chen Liang <li...@openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/ClassValue.java line 479: >> >>> 477: put(classValue.identity, updated); >>> 478: } >>> 479: // Add to the cache, to enable the fast path, next >>> time. >> >> A question: do we only care about `if (updated != entry)` path for this >> cache-add then? Should this code be moved into that block? > > I think whenever we hit `readAccess`, it means we are missing this item in > the cache and are already in this slow path. I pondered this may happen due > to cache being too full too, in which case we have `updated == entry` in the > backing map, so leaving it out of the if block should be correct. Also, this cache mechanism was authored before JDK 8 introduced fast table cache in `ConcurrentHashMap`. In the long run, we may switch the ClassValueMap to a ConcurrentHashMap-derived structure, like a `ReferencedKeyMap`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/26679#discussion_r2261143735