RFR: 8255987: JDI tests fail with com.sun.jdi.ObjectCollectedException [v2]

David Holmes dholmes at openjdk.java.net
Mon Dec 7 22:09:15 UTC 2020


On Mon, 7 Dec 2020 10:57:08 GMT, Per Liden <pliden at openjdk.org> wrote:

>> I agree a fatal error here seems excessive. Simply maintaining the strong ref seems reasonable.
>
> I was trying to mimic what we already do in `strengthenNode()`, i.e. it's a fatal error if we can't create a JNI ref. Here:
> 
>         strongRef = JNI_FUNC_PTR(env,NewGlobalRef)(env, node->ref);
>         /*
>          * NewGlobalRef on a weak ref will return NULL if the weak
>          * reference has been collected or if out of memory.
>          * It never throws OOM.
>          * We need to distinguish those two occurrences.
>          */
>         if ((strongRef == NULL) && !isSameObject(env, node->ref, NULL)) {
>             EXIT_ERROR(AGENT_ERROR_NULL_POINTER,"NewGlobalRef");
>         }
> 
> So it seems appropriate to do the same thing if we fail to create a JNI weak ref. Also, as @plummercj mentioned, if we can't create a JNI ref, continuing the debug session seems rather pointless as we're about to go down anyway (the next allocation in the JVM will be fatal).

Okay.

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

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


More information about the serviceability-dev mailing list