For users of JDI and JDWP, there are cases where objects are returned which are not referenced anywhere in the target VM. At the JDI level, this is possible with the following methods:
ArrayType.newInstance()
VirtualMachine.mirrorOf(String)
ClassType.newInstance()
ClassType.invokeMethod()
ObjectReference.invokeMethod()
There is a small chance that the objects returned by any of these methods will be immediately garbage collected in the target VM before the client can do anything with them. It would be very helpful if there was an option that instructed the VM to disable garbage collection for these objects. For the invokeMethod calls and for ClassType.newInstance, one of the unused bits in the options integer can be used to specify this behavior. The other cases are less serious since the client can always cleanly recover, but it would be better if a boolean option were added to these methods to disable collection of the newly created object.