Question

Very specifically, in JDI and JPDA context, I have the following questions:

  • Why ObjectReference does not expose its underlying object? Is it based on some specification? Are all implementations such as Eclipse Debug Project the same that do not expose the underlying object?

  • Considering the situation that you have the uniqueID() from ObjectReference, is there any way to resolve the underlying object from JVM?

  • If no to the previous question, then what is the best way to resolve the underlying object? I should add that I am familiar with how Value's can be obtained from StackFrame information, but I really need the object reference not the internal values or structure of the fields.

Was it helpful?

Solution

Why ObjectReference does not expose its underlying object?

I am assuming that you are referring to the com.sun.jdi.ObjectReference interface. If so, it is a combination of two things:

  • On the face of it, it wouldn't make sense. The ObjectReference is in the JVM running the debugger, but the corresponding Java object exists on the target machine.

  • Assuming that it did make sense, then it would be a bad thing to expose the actual pbject addresses and memory contents. This would allow the debugger to do things to the target JVM that would lead to hard crashes.

Considering the situation that you have the uniqueID() from ObjectReference, is there any way to resolve the underlying object from JVM?

No.

If no to the previous question, then what is the best way to resolve the underlying object?

AFAIK, there is no way to do this, apart from writing your own debug agent in C / C++ using the JVM Tool Interface and configuring the target JVM to run it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top