RFR: 8351996: Behavioral updates for ClassValue::remove [v11]
Shaojin Wen
swen at openjdk.org
Fri May 2 12:47:52 UTC 2025
On Wed, 30 Apr 2025 20:26:33 GMT, Chen Liang <liach at openjdk.org> wrote:
>> The recent patch #23866 makes calling `ClassValue::remove()` from `ClassValue::computeValue()` end up in infinite loops while fixing the stale value risk from the method.
>>
>> The proposed fix is to preserve the stale value risk fix, and update the remove-from-compute behavior from the original designated no-op behavior to throwing an exception, as the original behavior conflicts with the stale value fix.
>>
>> The implementation track the owner thread in promises (accessed in locked section); as a result, we can fail-fast on recursive removals from `computeValue`. I did not choose to use `ThreadTracker` as it is designed for single tracker and multiple threads, while this case here sees often just one thread, and the threads outlive the promise objects.
>>
>> Also updated the API specs for `remove` to more concisely describe the memory effects. Please review the associated CSR as well.
>
> Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 19 additional commits since the last revision:
>
> - Merge branch 'master' of https://github.com/openjdk/jdk into fix/classvalue-compute-remove
> - Reviews from viktor
> - Rewrite impl to follow the new simplified spec
> - Merge branch 'master' of https://github.com/openjdk/jdk into fix/classvalue-compute-remove
> - Try to simplify the model - use the finish of computeValue
>
> - Test updates - remove repetition, test case for no stale installation
> - Fix incorrect promise removal when unnecessary and add regression test
> - Cannot test for recursion eagerly - add test case
> - More spec, eager exception, finish with existing, thanks John
> - Merge branch 'master' of https://github.com/openjdk/jdk into fix/classvalue-compute-remove
> - ... and 9 more: https://git.openjdk.org/jdk/compare/b679d9c3...2292212b
src/java.base/share/classes/java/lang/ClassValue.java line 371:
> 369: Version<T> v = version();
> 370: if (v == null) return false;
> 371: if (v.isLive()) return true;
Suggestion:
if (v == null) return false;
if (v.isLive()) return true;
Remove a space to align the code
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24043#discussion_r2071561616
More information about the core-libs-dev
mailing list