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
 VMDisconnectedException if the target VM is
 disconnected and the VMDisconnectEvent has been or is
 available to be read from the EventQueue.
 
 Any method on StackFrame which
 takes StackFrame as an parameter may throw
 VMOutOfMemoryException if the target VM has run out of memory.
- Since:
- 1.3
- 
Method SummaryModifier and TypeMethodDescriptionReturns the values of all arguments in this frame.getValue(LocalVariable variable) Gets theValueof aLocalVariablein this frame.getValues(List<? extends LocalVariable> variables) Returns the values of multiple local variables in this frame.location()Returns theLocationof the current instruction in the frame.voidsetValue(LocalVariable variable, Value value) Sets theValueof aLocalVariablein this frame.Returns the value of 'this' for the current frame.thread()Returns the thread under which this frame's method is running.visibleVariableByName(String name) Finds aLocalVariablethat matches the given name and is visible at the current frame location.Returns a list containing eachLocalVariablethat can be accessed from this frame's location.Methods declared in interface com.sun.jdi.MirrortoString, virtualMachine
- 
Method Details- 
locationLocation location()Returns theLocationof 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).- Specified by:
- locationin interface- Locatable
- Returns:
- the Locationof the current instruction.
- Throws:
- InvalidStackFrameException- if this stack frame has become invalid. Once the frame's thread is resumed, the stack frame is no longer valid.
 
- 
threadThreadReference thread()Returns the thread under which this frame's method is running.- Returns:
- a ThreadReferencewhich mirrors the frame's thread.
- Throws:
- InvalidStackFrameException- if this stack frame has become invalid. Once the frame's thread is resumed, the stack frame is no longer valid.
 
- 
thisObjectObjectReference thisObject()Returns the value of 'this' for the current frame. TheObjectReferencefor 'this' is only available for non-native instance methods.- Returns:
- an ObjectReference, or null if the frame represents a native or static method.
- Throws:
- InvalidStackFrameException- if this stack frame has become invalid. Once the frame's thread is resumed, the stack frame is no longer valid.
 
- 
visibleVariablesReturns a list containing eachLocalVariablethat 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.
 - Returns:
- the list of LocalVariableobjects currently visible; the list will be empty if there are no visible variables; specifically, frames in native methods will always return a zero-length list.
- Throws:
- AbsentInformationException- if there is no local variable information for this method.
- InvalidStackFrameException- if this stack frame has become invalid. Once the frame's thread is resumed, the stack frame is no longer valid.
- NativeMethodException- if the current method is native.
 
- 
visibleVariableByNameFinds aLocalVariablethat matches the given name and is visible at the current frame location. SeevisibleVariables()for more information on visibility.- Parameters:
- name- the variable name to find
- Returns:
- the matching LocalVariable, or null if there is no visible variable with the given name; frames in native methods will always return null.
- Throws:
- AbsentInformationException- if there is no local variable information for this method.
- InvalidStackFrameException- if this stack frame has become invalid. Once the frame's thread is resumed, the stack frame is no longer valid.
- NativeMethodException- if the current method is native.
 
- 
getValueGets theValueof aLocalVariablein this frame. The variable must be valid for this frame's method and visible according to the rules described invisibleVariables().- Parameters:
- variable- the- LocalVariableto be accessed
- Returns:
- the Valueof the instance field.
- Throws:
- IllegalArgumentException- if the variable is either invalid for this frame's method or not visible.
- InvalidStackFrameException- if this stack frame has become invalid. Once the frame's thread is resumed, the stack frame is no longer valid.
 
- 
getValuesReturns 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 invisibleVariables().- Parameters:
- variables- a list of- LocalVariableobjects to be accessed
- Returns:
- a map associating each LocalVariablewith itsValue
- Throws:
- IllegalArgumentException- if any variable is either invalid for this frame's method or not visible.
- InvalidStackFrameException- if this stack frame has become invalid. Once the frame's thread is resumed, the stack frame is no longer valid.
 
- 
setValuevoid setValue(LocalVariable variable, Value value) throws InvalidTypeException, ClassNotLoadedException Sets theValueof aLocalVariablein this frame. The variable must be valid for this frame's method and visible according to the rules described invisibleVariables().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. - Parameters:
- variable- the field containing the requested value
- value- the new value to assign
- Throws:
- IllegalArgumentException- if the field is not valid for this object's class.
- InvalidTypeException- if the value's type does not match the variable's type.
- ClassNotLoadedException- if the variable type has not yet been loaded through the appropriate class loader.
- InvalidStackFrameException- if this stack frame has become invalid. Once the frame's thread is resumed, the stack frame is no longer valid.
- VMCannotBeModifiedException- if the VirtualMachine is read-only - see- VirtualMachine.canBeModified().
 
- 
getArgumentValuesReturns the values of all arguments in this frame. Values are returned even if no local variable information is present.- Returns:
- a list containing a Valueobject for each argument to this frame, in the order in which the arguments were declared. If the method corresponding to this frame has no arguments, an empty list is returned.
- Throws:
- InvalidStackFrameException- if this stack frame has become invalid. Once the frame's thread is resumed, the stack frame is no longer valid.
- Since:
- 1.6
 
 
-