On Fri, 4 Dec 2020 21:22:53 GMT, Chris Plummer <[email protected]> wrote:

>> src/jdk.jdwp.agent/share/native/libjdwp/commonRef.c line 632:
>> 
>>> 630:                     if (weakRef == NULL) {
>>> 631:                         
>>> EXIT_ERROR(AGENT_ERROR_NULL_POINTER,"NewWeakGlobalRef");
>>> 632:                     }
>> 
>> I'm not so sure I agree that having a fatal error here is the right thing to 
>> do. The only other user of `weakenNode()` is 
>> `ObjectReference.disableCollection()`. It returns an error to the debugger 
>> if `weakenNode()` returns `NULL`. However, I'm not so sure that's a good 
>> thing to do here either, since it means the `VM.resume()` will need to fail. 
>> Possibly the error should just be ignored, and we live with the ref staying 
>> strong.
>
> Another options is to save away the weakref in the node when strengthening. 
> This would benefit `ObjectReference.disableCollection()` also, since it would 
> no longer need to deal with a potential OOM. However, I'm not so sure it's 
> actually worth doing. Trying to keep the debug session alive will having 
> allocation errors is probably a fools errand.

I agree a fatal error here seems excessive. Simply maintaining the strong ref 
seems reasonable.

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

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

Reply via email to