我正在查看 Javap 的输出。例如:
这段代码
final Foo foo = new Foo(1,2);
...
new Callable<Integer>()
{
@Override
public Integer call() throws Exception
{
return foo.doSomething();
}
生成:
jvmOperations": [{
"byteOffset": 0,
"constantPoolIndex": null,
"opCode": 42,
"opCodeName": "aload_0",
"type": null,
"tagName": null,
"tagValue": null
}, {
"byteOffset": 1,
"constantPoolIndex": null,
"opCode": 180,
"opCodeName": "getfield",
"type": null,
"tagName": "Field",
"tagValue": "val$foo:Lcom/example/graph/demo/Foo;"
}, {
"byteOffset": 4,
"constantPoolIndex": null,
"opCode": 182,
"opCodeName": "invokevirtual",
"type": null,
"tagName": "Method",
"tagValue": "com/example/graph/demo/Foo.doSomething:()Ljava/lang/Integer;"
}, {
"byteOffset": 7,
"constantPoolIndex": null,
"opCode": 176,
"opCodeName": "areturn",
"type": null,
"tagName": null,
"tagValue": null
}]
所以我看到在这种情况下该对象由val$foo
. 并在类元数据中
"classMetaData": {
"classId": "com/example/Main$1.class",
"sourceName": "Main.java",
"isInterface": false,
"isClass": true,
"accessModifiers": ["final"],
"superClassName": "java/lang/Object",
"implementedInterfaces": ["java/util/concurrent/Callable"],
"jreTargetVersion": "51.0",
"fields": ["val$foo"],
"fieldModifiers": {
"val$foo": ["final"]
},
"methodInformationMap": {},
"interface": false,
"class": true
},
但现在我想了解更多关于原始对象的信息foo
。例如,我知道它在其中一个字段中有这些数据:
{
"byteOffset": 37,
"constantPoolIndex": null,
"opCode": 18,
"opCodeName": "ldc",
"type": null,
"tagName": "String",
"tagValue": "NODE-1"
},
JVM如何知道val$foo
指向什么?