Getting obj.id with an OQL query in Java VisualVM (1.8.0_45) returns JavaScript object id (a long value) instead of the value of the Java field. In other words
obj.id
Currently there is no way to access Java object id field. This is a bug in OQL. You can use the following workaround:
id
obj["wrapped-object"].getValueOfField("id")