On Thu, 18 Jun 2026 01:18:24 GMT, Chris Plummer <[email protected]> wrote:

>> The PR resolves the issue JDI has with allowing collection of objects that 
>> are returned by the JDI invoke API before the caller of the API has a chance 
>> to call ObjectReference.disableCollection(). Details in the first comment.
>> 
>> Consider this to be a prototype. I'm open to discussion on other possible 
>> solutions. I also still need to update the JDI specs to reflect these 
>> changes.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Chris Plummer has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains six additional 
> commits since the last revision:
> 
>  - Merge branch 'master' into 8311176_disablegc
>    Merge
>  - support WhiteBoxAPI for debuggee
>  - fix some jcheck whitespace errors
>  - fix some jcheck whitespace errors
>  - cleanup some comments
>  - add support for diabling gc on returned objects

I just discovered one potential spec violation with the "always pin" solution. 
ClassType.instances() is only suppose to return instances that are "reachable 
for the purposes of garbage collection". This seems to not include instances 
that are only weakly reachable. So the expectation is that the ObjectReference 
returned by ClassType.newInsance() should not be included in the 
ClassType.instances() results unless a disableCollection() is done first. There 
is one test that fails because of this.

One way around this is to make "always pin"  an option the user has to enable 
via something like VirtualMachine.SetReturnedObjectRetentionPolicy(ALWAYS_PIN), 
or something like that. We've discussed this before. I was hoping that we could 
just make this default behavior and not have to require a new API that users 
must call, plus coming up with a good name is not easy. Also, it greatly 
increases testing, as we would need to test both with this enabled and disabled.

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

PR Comment: https://git.openjdk.org/jdk/pull/31421#issuecomment-4737528797

Reply via email to