• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdi popframes method

 
caid bradley
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

We're implementing a debugger extension that uses the JDI popframes method to pop the most recent method's stack frame of the stack.
The popframes blurb in the JDI specification gives an example

===========
All frames up to and including the frame are popped off the stack. The frame previous to the parameter frame will become the current frame.

After this operation, this thread will be suspended at the invoke instruction of the target method that created frame. The frame's method can be reentered with a step into the instruction.

The operand stack is restored, however, any changes to the arguments that occurred in the called method, remain. For example, if the method foo:

void foo(int x) {
System.out.println("Foo: " + x);
x = 4;
System.out.println("pop here");
}


was called with foo(7) and foo is popped at the second println and resumed, it will print: Foo: 4.
==================

where it states that any changes made the integer argument passed into the method will not be restored if the method's stack frame is popped. I understand that. What I DON'T understand, is why this is.

If the method argument "int x" is stored in the leaf method's stack frame, and that stack frame is popped with the popframes method, then surely this method argument would also be popped off the stack too, and original value stored in the caller method would be passed back in when the method is re-invoked? I mean, the int is a primitive, and so is passed-by-value into the method.

Any explanation would be hugely appreciated.

Regards

caid
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Other APIs
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic