I am just starting to figure out JDI a little bit for creating a custom debugger. I have been trying to convert reference objects into real objects, so I can access their fields or methods without using invoke. I include the jar into the project from the target vm so I have access to all of the real objects. I then try to cast but get the exception like com.sun.tools.jdi.ObjectReference cannot be cast to myobject
. Is there any way to do something like this or do you have to use invoke?
User user = (User) frame.thisObject();
This kind of cast is not possible at all because you have to think a debugger as an external process that doesn't know nothing about target program domain objects.
Your scenario is a special situation but usually debugger doesn't include target jars.