Skip to content


8309688: Data race on$CacheRef.strongReferent
Browse files Browse the repository at this point in the history
Reviewed-by: rriggs, shade
  • Loading branch information
Man Cao committed Jun 15, 2023
1 parent 81bfd78 commit 5c70516
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/java.base/share/classes/java/io/
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ abstract class ClassCache<T> {

private static class CacheRef<T> extends SoftReference<T> {
private final Class<?> type;
// This field is deliberately accessed without sychronization. ClassValue
// provides synchronization when CacheRef is published. However, when
// a thread reads this field, while another thread is clearing the field, it
// would formally constitute a data race. But that data race is benign, and
// fixing it could introduce noticeable performance penalty, see JDK-8309688.
private T strongReferent;

CacheRef(T referent, ReferenceQueue<T> queue, Class<?> type) {
Expand Down

1 comment on commit 5c70516

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.