1

I want to output the value of a reference. This should be similar to printing the value of a pointer in languages like C or GoLang.

I understand that the reference value is not an address, as objects in Java get shuffled in memory during garbage collection. However, the JVM must be able to distinguish all object instances, via their reference value. This reference value is not necessarily an integral type but I want to explore its data within Java.

To be clear, I want the reference value, the thing that is compared when the == operator is used between objects in Java.

How can I go about obtaining this value using Java? Something like System.referenceValue(Object)? Are the reference values themselves also ephemeral, and thus out of the question?

0 Answers0