Java 对象方法堆栈帧参数
因此,在 java 中,假设类“Foo”中有一个非静态方法“bar()”。
class Foo
{
private int m_answer;
public Foo()
{
m_answer = -1;
}
public void bar(int newAnswer)
{
m_answer = newAnswer;
}
}
假设您像这样调用此方法:
Foo myFoo = new Foo();
myFoo.bar(42);
现在,调用的堆栈帧包括整数参数,以及用作对象内部引用的“this”参数。
除了“this”和方法参数之外,还有哪些其他有趣的参数被复制到新的堆栈帧?
。
So in java, say you have a non-static method 'bar()' in an class 'Foo'.
class Foo
{
private int m_answer;
public Foo()
{
m_answer = -1;
}
public void bar(int newAnswer)
{
m_answer = newAnswer;
}
}
Say then that you call this method like so:
Foo myFoo = new Foo();
myFoo.bar(42);
Now the stack frame for the call includes the integer parameter, as well as a 'this' parameter to be used as an internal reference to the object.
What other interesting parameters are copied to the new stack frame, in addition to 'this' and the method parameters?
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常是指向调用指令的指针,以便VM(在本例中是本机应用程序中的CPU)知道在哪里设置指令指针(或PC - 程序计数器),因此堆栈将正确展开
Usually a pointer to the calling instruction, so that the VM (in this case, the CPU in native apps) will know where to set the instruction pointer (or PC - Program Counter) so the stack will be unfolded correctly