On Fri, 13 Mar 2026 19:31:35 GMT, Alex Menkov <[email protected]> wrote:
> Updated jdwp agent to not use weak references for value objects (use strong > references instead) > > testing: tier1,tier2,tier3,hs-tier5-svc with enable-preview This is the JDWP spec for ObjectIDs: “Uniquely identifies an object in the target VM. A particular object will be identified by exactly one objectID in JDWP commands and replies throughout its lifetime (or until the objectID is explicitly disposed). An ObjectID is not reused to identify a different object unless it has been explicitly disposed, regardless of whether the referenced object has been garbage collected.” This is why we can’t free ObjectIDs simply because the refcnt is 0. The ObjectID needs to remain valid until the object is collected or the debugger decides it does not need it anymore. This might mean our current implementation is ok. JDI disposes an ObjectID when it discovers there are no longer any hard references to the containing ObjectReference. This should prevent the accumulation of too many ObjectIDs for value objects. The only downside is preventing the collection of the value object instance until the debugger is done referring to it. Note you could probably write a test that allocates a value object, keeps no references to it, and forces a GC. On the debugger side it would expect ObjectReference.IsCollected to return true, but it will return false. I'm not sure if this is a bug though. It depends on whether this GC behavior is spec'd or not. I'm pretty sure we have JDI tests like this already, but they act on regular types, not value types, so behave as expected (object is collected due to the debug agent tracking it with a weak ref). They may be testing expected implementation behavior, not spec'd behavior. ------------- PR Comment: https://git.openjdk.org/valhalla/pull/2229#issuecomment-4071202487
