4

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.

4

1 回答 1

3

为什么 ObjectReference 不暴露其底层对象?

我假设您指的是com.sun.jdi.ObjectReference界面。如果是这样,它是两件事的组合:

  • 从表面上看,这没有任何意义。ObjectReference 在运行调试器的 JVM 中,但对应的 Java 对象存在于目标机器上。

  • 假设它确实有意义,那么暴露实际的 pbject 地址和内存内容将是一件坏事。这将允许调试器对目标 JVM 执行可能导致硬崩溃的操作。

考虑到您拥有来自 ObjectReference 的 uniqueID() 的情况,有没有办法从 JVM 解析底层对象?

不。

如果上一个问题没有,那么解决底层对象的最佳方法是什么?

AFAIK,除了使用 JVM 工具接口在 C/C++ 中编写自己的调试代理并配置目标 JVM 以运行它之外,没有办法做到这一点。

于 2010-11-12T15:15:41.837 回答