RFR: 8293207: Add assert to JVM_ReferenceRefersTo to clarify its API
Stefan Karlsson
stefank at openjdk.org
Thu Sep 1 13:52:17 UTC 2022
On Thu, 1 Sep 2022 10:47:50 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
> JVM_ReferenceRefersTo should only be used for soft/weak references and not phantom references, which has its own implementation. This is not clear from the name. `java_lang_ref_Reference::weak_referent_no_keepalive(ref_oop)` is only a valid call if `!java_lang_ref_Reference::is_phantom(ref_oop)`.
>
> Adds an assert and comment to make this clear.
>
> Testing: Oracle platforms tier 1-3
Marked as reviewed by stefank (Reviewer).
src/hotspot/share/prims/jvm.cpp line 3286:
> 3284: oop ref_oop = JNIHandles::resolve_non_null(ref);
> 3285: // PhantomReference has it's own implementation of refersTo().
> 3286: assert(!java_lang_ref_Reference::is_phantom(ref_oop), "precondition");
Maybe this would be even clearer if it said:
// PhantomReference has it's own implementation of refersTo(). See: JVM_PhantomReferenceRefersTo
-------------
PR: https://git.openjdk.org/jdk/pull/10117
More information about the hotspot-dev
mailing list