getstatic 在字节码中的真正含义是什么?
我有这个字节码:
new java.lang.Object
// stack is [newObjectRef]
dup
// Stack is [newObjectRef newObjectRef]
invokespecial void java.lang.Object.<init>()
// Stack is [initializedAsTypeObjectObjectRef]
putstatic java.lang.Object class.a
// variable a has the reference of new object
getstatic java.io.PrintStream java.lang.System.out
// Take the static value of System.out
// Stack is [initializedAsTypeObjectObjectRef System.out]
更新这是延续:
> ldc "test" // Stack is
> [initializedAsTypeObjectObjectRef System.out "test"]
> jsr pos.0000026C // call a subrutine invokevirtual void
> java.io.PrintStream.println(java.lang.String) // actually print the
> result // stack is (I think) Empty at this time ?
翻译是:
Object a = new Object();
a = "test";
System.out.print(a);
我的堆栈好吗?
我不确定是否很好地理解了 out()。 也许我必须使用 out() setter 并在之后使用 print() ?
我总是习惯性地使用 out() 来打印..
I have this byte code:
new java.lang.Object
// stack is [newObjectRef]
dup
// Stack is [newObjectRef newObjectRef]
invokespecial void java.lang.Object.<init>()
// Stack is [initializedAsTypeObjectObjectRef]
putstatic java.lang.Object class.a
// variable a has the reference of new object
getstatic java.io.PrintStream java.lang.System.out
// Take the static value of System.out
// Stack is [initializedAsTypeObjectObjectRef System.out]
Update this is the continuation:
> ldc "test" // Stack is
> [initializedAsTypeObjectObjectRef System.out "test"]
> jsr pos.0000026C // call a subrutine invokevirtual void
> java.io.PrintStream.println(java.lang.String) // actually print the
> result // stack is (I think) Empty at this time ?
Does the translation is:
Object a = new Object();
a = "test";
System.out.print(a);
Is my stack good ?
I am not sure to well understand out().
Probably I will have to use out() setter and to print() after ?
I always use out() to print habitually..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我编译代码
并运行,
我会看到
您可以看到
getstatic
加载字段System.out
对象没有名为
method
code>out() 所以我不相信您正在查看您认为是的代码。getstatic
获取一个static
字段,例如System.out
是 System 的一个static
字段,所以如果你写这将导致使用
getstatic
If I compile the code
and run
I see
You can see that
getstatic
loads the fieldSystem.out
Object doesn't have a
method
calledout()
so I don't believe you are looking at the code you believe you are.getstatic
gets astatic
fields e.g.System.out
is astatic
field of System so if you writeThis will result in a use of
getstatic