Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deciphering variable information while debugging 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}

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?

Thanks in advance.

like image 418
Jon Onstott Avatar asked Feb 24 '10 00:02

Jon Onstott


1 Answers

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

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.

like image 66
CrazyCoder Avatar answered Nov 12 '22 23:11

CrazyCoder