What is the meaning of the Value column for an object in a NetBeans Debugger Variable window?

The NetBeans 8 Debugger Settings window has a Value column. The value of the column is pretty clear for primitive types and strings and arrays, but for objects in the column the "#" symbol is displayed, followed by a (usually 4-digit) number. The value, apparently, is associated with the identity of the object, because several variables that refer to the same object have the same number, and objects constructed in series appear to be sequential numbers. The number is not object.hashCode (). Can someone tell me more about what number will be shown? I just wonder if this number can be obtained as a method or property of an object similar to hashCode (). If not, is there a way to access this number programmatically?

My explanation of the value of the column corresponds to the last section https://ui.netbeans.org/docs/hi/debugger3.4/variables/index.html#specific , which is entitled "Object Rows". It states that "Object strings are used to display links to class instances. Each link can be considered to have a class instance number (from some table of instances in the virtual machine), therefore this number is displayed in the value column (with the prefix" # ") for the link .

I am trying to get a better explanation of what the article simply calls "some instance table in a virtual machine."

thanks

+5
source share
1 answer

I don’t think there is a way to access this number if you are not creating a debugger plugin. Netbeans simply assigns a new number to each new object that it encounters during a debugging session. The check "is a new object" is probably based on the identifier ( == ), and not on Object.hashCode() / System.identityHashCode() .

You can take "some instance table in a virtual machine" literally. Even if the JVM does not have explicit tables, you can still get such a list from a heap dump (HPROF). OQL (Object Query Language) allows SQL-like access to such data. For instance:

 select f.field1 from my.package.MyClass f where f.field2 = 123 

By the way, in this question I was looking for a way to display toString() instead of #number - to get that I had to right-click the header of the variable table and select the new column "Row Value". An alternative way is to add a Variable formatter to "Tools / Options / Java / Java Debugger / Variable formatters"

0
source

All Articles