RFR: 8304164: jdk/classfile/CorpusTest.java still fails after JDK-8303910
Jaikiran Pai
jpai at openjdk.org
Fri Mar 17 05:52:19 UTC 2023
On Wed, 15 Mar 2023 08:44:34 GMT, Adam Sotona <asotona at openjdk.org> wrote:
> Massive parallel execution of parametrised CorpusTest junit tests revealed race condition in `ClassHierarchyImpl.CachedClassHierarchyResolver::getClassInfo`.
>
> The race condition may skip calculation of the ClassHierarchyInfo. In this specific case it caused SegmentScope not being identified as an interface and verify error on assignability between declared method return type and actual returned type has been emitted by the test.
>
> Proposed patch fixes the race condition in `ClassHierarchyImpl.CachedClassHierarchyResolver::getClassInfo`.
>
> Please review.
>
> Thank you,
> Adam
Marked as reviewed by jpai (Reviewer).
src/java.base/share/classes/jdk/internal/classfile/impl/ClassHierarchyImpl.java line 133:
> 131: //using NOPE to distinguish between null value and non-existent record in the cache
> 132: //this code is on JDK bootstrap critical path, so cannot use lambdas here
> 133: var res = resolvedCache.getOrDefault(classDesc, NOPE);
`resolvedCache` is a `Collections.synchronizedMap` backed by a `HashMap`. So the `getOrDefault()` (internally) synchronizes on the `resolvedCache` instance itself and thus this operation would be thread safe in context of access to this cache in rest of this code. So what you propose here looks good to me.
-------------
PR: https://git.openjdk.org/jdk/pull/13037
More information about the core-libs-dev
mailing list