Java method that returns reachable objects

102 Views Asked by At

Is there a Java equivalent for following Ruby method ?

ObjectSpace.reachable_objects_from: This method returns all the objects directly reachable from the given object.

Reference: Look for ObjectSpace.reachable_objects_from in the following document http://globaldev.co.uk/2013/03/ruby-2-0-0-in-detail/

1

There are 1 best solutions below

0
kittylyst On

Bear in mind that all Java programs are inherently multithreaded, and so to give an accurate answer to the question "what is reachable from this object", a Stop-The-World event would be required (as other threads may be mutating the object graph).

For inherently multithreaded systems, giving this level of power to a developer is a very bad idea.