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

Chris Plummer cjplummer at openjdk.java.net
Tue Dec 8 19:25:41 UTC 2020


On Tue, 8 Dec 2020 14:04:33 GMT, Per Liden <pliden at openjdk.org> wrote:

>> I read "reachable for the purposes of garbage collection" as not including objects reachable only via weak reference. So if the only reference to an object is a weak reference, which is normally what you have after calling `ClassType.newInstance()`, then the object is not considered reachable. At the very least, his is how `ReferenceType.instances()` is implemented, and is based on JVMTI [FollowReferences](https://docs.oracle.com/en/java/javase/14/docs/specs/jvmti.html#FollowReferences)().
>> 
>> So given that, the expectation would be that an object returned `ClassType.newInstance()` would not be counted by `ReferenceType.instances()` unless something is done to add a strong reference to the object, such as calling `ObjectReference.disableCollection()`. Now with Per's changes a strong reference is also created with doing a VM.suspend(). The test doesn't expect this behavior, and it's understandable why.
>
> I think we're still within what the spec says, given that the wording is so loose. But it's hard to tell if this change will be problematic for some use case.

I'm ok with making the change and then seeing if there is any fallout from it. My guess is there won't be. I do think there is a need to cleanup the JDI and JDWP specs in a few areas w.r.t. object liveness. Another CR can be filed for that.

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

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


More information about the serviceability-dev mailing list