aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes jdi popframes method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "jdi popframes method" Watch "jdi popframes method" New topic
Author

jdi popframes method

caid bradley
Greenhorn

Joined: Jan 08, 2005
Posts: 5
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

Joined: Oct 25, 2000
Posts: 7292

Moving to Other APIs


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
 
 
subject: jdi popframes method