调试Java时解密变量信息 [英] Deciphering variable information while debugging Java

查看:89
本文介绍了调试Java时解密变量信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IntelliJ IDEA 8来调试一些Java,但这个问题可能适用于所有的Java调试器。在变量列表中,它们显示为:

I'm using IntelliJ IDEA 8 for debugging some Java, but this question could probably apply to all Java debuggers. In the list of variables, they are displayed as:


myVariable = {some.package.SomeClass@12345}

myVariable = {some.package.SomeClass@12345}

我很好奇类名后面的数字。什么是正确的数字?如果两个变量是相同的底层对象,那么两个变量是否相同?

I am curious about the number that comes after the class name. What is the number exactly? Would two variables have the same number if it is the same underlying object that is being referred to?

提前感谢

推荐答案

这是JVM报告的 objectId ,详情请参阅 JDWP规范

That is objectId reported by the JVM, for details please see the JDWP specification.



目标虚拟机中唯一标识对象。一个特定的对象将是
,在
JDWP命令和
的整个生命期间(或直到objectID为
明确处理)中正好一个objectID。一个ObjectID是
不被重用以识别一个不同的
对象,除非它已被明确地
处理,而不管
引用的对象是否已收集垃圾
。 objectID为0表示
一个空对象。请注意,对象ID的
的存在不会阻止对象的
垃圾回收。任何
尝试访问垃圾
收集的对象,其对象ID
将导致INVALID_OBJECT
错误代码。垃圾收集可以通过DisableCollection
命令禁用
,但通常不需要

Uniquely identifies an object in the target VM. A particular object will be identified by exactly one objectID in JDWP commands and replies throughout its lifetime (or until the objectID is explicitly disposed). An ObjectID is not reused to identify a different object unless it has been explicitly disposed, regardless of whether the referenced object has been garbage collected. An objectID of 0 represents a null object. Note that the existence of an object ID does not prevent the garbage collection of the object. Any attempt to access a a garbage collected object with its object ID will result in the INVALID_OBJECT error code. Garbage collection can be disabled with the DisableCollection command, but it is not usually necessary to do so.

这篇关于调试Java时解密变量信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆