Deciphering Variable Information While Debugging Java

Deciphering variable information while debugging Java

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.

While debugging java app what information is shown for a variable in a stack frame

The @ is the object count number since the app started. So @1012 means the 1012th object created since the app started.

It is not the identity hashcode.

Here is some proof: (I say this because I don't actually know, but I observed it)

public static void main(String [] args) throws Throwable {

Object object = new Object();
Object object1 = new Object();
Integer foo = new Integer(5);
Object object2 = new Object();
String str = new String("bar");

System.out.println("code :" + System.identityHashCode(object));

RuntimeException exception = new RuntimeException();
exception.printStackTrace(); //put breakpoint here

}

Output:
code :789451787
code :java.lang.Object@2f0e140b

789451787=2f0e140b By the way...

Output from IntelliJ Debugger:

static = org.boon.core.MyClass
args = {java.lang.String[0]@**97**}
object = {java.lang.Object@**98**}
object1 = {java.lang.Object@**99**}
foo = {java.lang.Integer@**100**}"5"
object2 = {java.lang.Object@**101**}
str = {java.lang.String@**102**}"bar"
exception = {java.lang.RuntimeException@**103**}"java.lang.RuntimeException"

I know this empirically, but I don't know the actual implementation, but I think it is related to issues like this:

as3: meaningful object identification while debugging.

While debugging Java codes what does @ mean in statements like {Instance@789} or SomeThread@321: RUNNING?

@730 means the 730th object created since the application started.
It is not the hashcode. Length of this can be more or less than 3 digits.

It's totally depends upon which IDE you are using, may eclipse will give something else instead of @730 and in different format also, so it is the way of intellij to maintaining the debugging.

(id=25) near variable debug info in Eclipse

The ID is just an arbitary number assigned by the eclipse debugger. This can be used to determine whether two references are pointing to the same object or not. So two references to the same object should have a same id. This can be a help while debugging.

What does the @ next to a Class instance mean?

This is an object id.

It is controlled by the Settings (Preferences on macOS) | Build, Execution, Deployment | Debugger | Data Views | Java | Show | Object id option.

As pointed in the comment to another answer the objectID is:

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.



Related Topics



Leave a reply



Submit