RFR: 8304164: jdk/classfile/CorpusTest.java still fails after JDK-8303910
Adam Sotona
asotona at openjdk.org
Fri Mar 17 11:50:22 UTC 2023
On Fri, 17 Mar 2023 05:49:45 GMT, Jaikiran Pai <jpai 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
>
> 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.
Thank you.
-------------
PR: https://git.openjdk.org/jdk/pull/13037
More information about the core-libs-dev
mailing list