RFR: 8256370: Add asserts to Reference.getInactive()

Mandy Chung mchung at openjdk.java.net
Mon Nov 16 18:33:07 UTC 2020


On Mon, 16 Nov 2020 17:29:20 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

> A follow-up to JDK-8256106, this is adding two asserts to check that the API is used as it should be, i.e. only on inactive FinalReferences. Also, in Finalizer, where getInactive() is used, there is a null-check. The GC must never clean the referent, and Java code doesn't clean it either, it would be a bug if we ever see null there. I think it's better to fail there (with assert or NPE) when that happens instead of silently accepting it.
> 
> Testing:
>  - [x] tier1
>  - [x] tier2

Thanks for adding this asserts.  If there is any reason to use `getInactive` by other references in the future, we could remove these asserts at that time.

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

Marked as reviewed by mchung (Reviewer).

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


More information about the core-libs-dev mailing list