On Fri, 14 Jan 2022 19:27:18 GMT, Aleksey Shipilev <sh...@openjdk.org> wrote:

> JDK-8277072 introduced java.io.ClassCache, but there seem to be at least two 
> issues with it:
>   - The cache cannot disambiguate between cleared SoftReference and the 
> accidental passing of `null` value; in that case, the retry loop would spin 
> indefinitely;
>   - If retry loop would spin several times, every time discovering a cleared 
> SoftReference, it would create and register new SoftReference on the 
> ReferenceQueue. However, it would not *drain* the RQ in the loop; in that 
> case, we might have the unbounded garbage accumulating in RQ; 
> 
> Attention @rkennke, @plevart.
> 
> Additional testing:
>   - [x] Linux x86_64 fastdebug `java/io/ObjectStreamClass`
>   - [x] Linux x86_64 fastdebug `tier1`
>   - [ ] Linux x86_64 fastdebug `tier2`
>   - [ ] Linux x86_64 fastdebug `tier3`

Right, good catches! It seems a bit weird that the constructors of Reference 
would accept null referents anyway, but it is like it is. *shrugs*
One additional improvement would be to change r.get() == null to 
r.refersTo(null) to check for cleared reference, that avoids reviving the 
referent, e.g. in SATB GCs. I leave that up to you.

-------------

Marked as reviewed by rkennke (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/7092

Reply via email to