8256106: Bypass intrinsic/barrier when calling Reference.get() from Finalizer

Reviewed-by: eosterlund
This commit is contained in:
Roman Kennke 2020-11-11 18:07:08 +00:00
parent 3c3469b9ce
commit 96e0261041
2 changed files with 15 additions and 1 deletions

View file

@ -82,7 +82,7 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
}
try {
Object finalizee = this.get();
Object finalizee = this.getInactive();
if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
jla.invokeFinalize(finalizee);

View file

@ -342,6 +342,20 @@ public abstract class Reference<T> {
return this.referent;
}
/**
* Load referent with strong semantics. Treating the referent
* as strong referent is ok when the Reference is inactive,
* because then the referent is switched to strong semantics
* anyway.
*
* This is only used from Finalizer to bypass the intrinsic,
* which might return a null referent, even though it is not
* null, and would subsequently not finalize the referent/finalizee.
*/
T getInactive() {
return this.referent;
}
/**
* Tests if the referent of this reference object is {@code obj}.
* Using a {@code null} {@code obj} returns {@code true} if the