Save This Page
Home » openjdk-7 » com.sun » jdi » [javadoc | source]
public interface: StackFrame [javadoc | source]

All Implemented Interfaces:
    Locatable, Mirror

All Known Implementing Classes:
    StackFrameImpl, StackFrameImpl

The state of one method invocation on a thread's call stack. As a thread executes, stack frames are pushed and popped from its call stack as methods are invoked and then return. A StackFrame mirrors one such frame from a target VM at some point in its thread's execution. The call stack is, then, simply a List of StackFrame objects. The call stack can be obtained any time a thread is suspended through a call to ThreadReference#frames

StackFrames provide access to a method's local variables and their current values.

The lifetime of a StackFrame is very limited. It is available only for suspended threads and becomes invalid once its thread is resumed.

Any method on StackFrame which takes StackFrame as an parameter may throw com.sun.jdi.VMDisconnectedException if the target VM is disconnected and the com.sun.jdi.event.VMDisconnectEvent has been or is available to be read from the com.sun.jdi.event.EventQueue .

Any method on StackFrame which takes StackFrame as an parameter may throw com.sun.jdi.VMOutOfMemoryException if the target VM has run out of memory.

Method from com.sun.jdi.StackFrame Summary:
getArgumentValues,   getValue,   getValues,   location,   setValue,   thisObject,   thread,   visibleVariableByName,   visibleVariables
Method from com.sun.jdi.StackFrame Detail:
 public List<Value> getArgumentValues()
    Returns the values of all arguments in this frame. Values are returned even if no local variable information is present.
 public Value getValue(LocalVariable variable)
 public Map<LocalVariable, Value> getValues(List<LocalVariable> variables)
    Returns the values of multiple local variables in this frame. Each variable must be valid for this frame's method and visible according to the rules described in #visibleVariables .
 public Location location()
    Returns the Location of the current instruction in the frame. The method for which this frame was created can also be accessed through the returned location. For the top frame in the stack, this location identifies the next instruction to be executed. For all other frames, this location identifies the instruction that caused the next frame's method to be invoked. If the frame represents a native method invocation, the returned location indicates the class and method, but the code index will not be valid (-1).
 public  void setValue(LocalVariable variable,
    Value value) throws InvalidTypeException, ClassNotLoadedException
    Sets the Value of a LocalVariable in this frame. The variable must be valid for this frame's method and visible according to the rules described in #visibleVariables .

    Object values must be assignment compatible with the variable type (This implies that the variable type must be loaded through the enclosing class's class loader). Primitive values must be either assignment compatible with the variable type or must be convertible to the variable type without loss of information. See JLS section 5.2 for more information on assignment compatibility.

 public ObjectReference thisObject()
    Returns the value of 'this' for the current frame. The ObjectReference for 'this' is only available for non-native instance methods.
 public ThreadReference thread()
    Returns the thread under which this frame's method is running.
 public LocalVariable visibleVariableByName(String name) throws AbsentInformationException
    Finds a LocalVariable that matches the given name and is visible at the current frame location. See #visibleVariables for more information on visibility.
 public List<LocalVariable> visibleVariables() throws AbsentInformationException
    Returns a list containing each LocalVariable that can be accessed from this frame's location.

    Visibility is based on the code index of the current instruction of this StackFrame. Each variable has a range of byte code indices in which it is accessible. If this stack frame's method matches this variable's method and if the code index of this StackFrame is within the variable's byte code range, the variable is visible.

    A variable's byte code range is at least as large as the scope of that variable, but can continue beyond the end of the scope under certain circumstances:

    • the compiler/VM does not immediately reuse the variable's slot.
    • the compiler/VM is implemented to report the extended range that would result from the item above.
    The advantage of an extended range is that variables from recently exited scopes may remain available for examination (this is especially useful for loop indices). If, as a result of the extensions above, the current frame location is contained within the range of multiple local variables of the same name, the variable with the highest-starting range is chosen for the returned list.