APIdia Launch Partner
Top Description Fields Methods
com.sun.jdi

public Interface VirtualMachine

extends Mirror
Known Direct Subinterfaces
com.sun.jdi.PathSearchingVirtualMachine
Imports
java.util.List, .Map, com.sun.jdi.connect.AttachingConnector, .Connector, .LaunchingConnector, com.sun.jdi.connect.spi.Connection, com.sun.jdi.event.EventQueue, .MethodExitEvent, .VMDisconnectEvent, .VMStartEvent, com.sun.jdi.request.BreakpointRequest, .ClassPrepareRequest, .EventRequestManager, .MonitorContendedEnterRequest, .MonitorContendedEnteredRequest, .MonitorWaitRequest, .MonitorWaitedRequest, .ThreadDeathRequest, .ThreadStartRequest, .VMDeathRequest

A virtual machine targeted for debugging. More precisely, a mirror representing the composite state of the target VM. All other mirrors are associated with an instance of this interface. Access to all other mirrors is achieved directly or indirectly through an instance of this interface. Access to global VM properties and control of VM execution are supported directly by this interface.

Instances of this interface are created by instances of Connector. For example, an AttachingConnector attaches to a target VM and returns its virtual machine mirror. A Connector will typically create a VirtualMachine by invoking the VirtualMachineManager's VirtualMachineManager#createVirtualMachine(Connection) createVirtualMachine(Connection) method.

Note that a target VM launched by a launching connector is not guaranteed to be stable until after the VMStartEvent has been received.

Any method on VirtualMachine which takes VirtualMachine 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 VirtualMachine which takes VirtualMachine as an parameter may throw VMOutOfMemoryException if the target VM has run out of memory.

Authors
Robert Field, Gordon Hirsch, James McIlree
Since
1.3

Field Summary

Modifier and TypeField and Description
public static final int
TRACE_ALL

All tracing is enabled.

public static final int
TRACE_EVENTS

Tracing enabled for internal event handling.

public static final int
TRACE_NONE

All tracing is disabled.

public static final int
TRACE_OBJREFS

Tracing enabled for internal management of object references.

public static final int
TRACE_RECEIVES

Tracing enabled for JDWP packets received from target VM.

public static final int
TRACE_REFTYPES

Tracing enabled for internal management of reference types.

public static final int
TRACE_SENDS

Tracing enabled for JDWP packets sent to target VM.

Method Summary

Modifier and TypeMethod and Description
public List<ReferenceType>

Returns:

a list of ReferenceType objects, each mirroring a loaded type in the target VM.
allClasses
()

Returns all loaded types in the target VM.

public default List<ModuleReference>

Returns:

a list of ModuleReference objects, each mirroring a module in the target VM.
allModules
()

Returns all modules.

public List<ThreadReference>

Returns:

a list of ThreadReference objects for the threads in the target VM
allThreads
()

Returns a list of the live threads in the target VM.

public boolean

Returns:

true if the feature is supported, false otherwise.
canAddMethod
()
Deprecated since 15. A JVM TI based JDWP back-end will never set this capability to true.

Determines if the target VM supports the addition of methods when performing class redefinition.

public boolean

Returns:

true if the feature is supported, false otherwise.
canBeModified
()

Determines if the target VM is a read-only VM.

public boolean

Returns:

true if the feature is supported, false otherwise.
canForceEarlyReturn
()

Determines if the target VM supports the forcing of a method to return early.

public boolean

Returns:

true if the feature is supported, false otherwise.
canGetBytecodes
()

Determines if the target VM supports the retrieval of a method's bytecodes.

public boolean

Returns:

true if the feature is supported, false otherwise.
canGetClassFileVersion
()

Determines if the target VM supports reading class file major and minor versions.

public boolean

Returns:

true if the feature is supported, false otherwise.
canGetConstantPool
()

Determines if the target VM supports getting constant pool information of a class.

public boolean

Returns:

true if the feature is supported, false otherwise.
canGetCurrentContendedMonitor
()

Determines if the target VM supports the retrieval of the monitor for which a thread is currently waiting.

public boolean

Returns:

true if the feature is supported, false otherwise.
canGetInstanceInfo
()

Determines if the target VM supports the accessing of class instances, instance counts, and referring objects.

public boolean

Returns:

true if the feature is supported, false otherwise.
canGetMethodReturnValues
()

Determines if the target VM supports the inclusion of return values in MethodExitEvents.

public default boolean

Returns:

true if the feature is supported, false otherwise
canGetModuleInfo
()

Determines if the target VM supports getting information about modules.

public boolean

Returns:

true if the feature is supported, false otherwise.
canGetMonitorFrameInfo
()

Determines if the target VM supports getting which frame has acquired a monitor.

public boolean

Returns:

true if the feature is supported, false otherwise.
canGetMonitorInfo
()

Determines if the target VM supports the retrieval of the monitor information for an object.

public boolean

Returns:

true if the feature is supported, false otherwise.
canGetOwnedMonitorInfo
()

Determines if the target VM supports the retrieval of the monitors owned by a thread.

public boolean

Returns:

true if the feature is supported, false otherwise.
canGetSourceDebugExtension
()

Determines if the target VM supports getting the source debug extension.

public boolean

Returns:

true if the feature is supported, false otherwise.
canGetSyntheticAttribute
()

Determines if the target VM supports the query of the synthetic attribute of a method or field.

public boolean

Returns:

true if the feature is supported, false otherwise.
canPopFrames
()

Determines if the target VM supports popping frames of a threads stack.

public boolean

Returns:

true if the feature is supported, false otherwise.
canRedefineClasses
()

Determines if the target VM supports any level of class redefinition.

public boolean

Returns:

true if the feature is supported, false otherwise.
canRequestMonitorEvents
()

Determines if the target VM supports the creation of MonitorContendedEnterRequests.

public boolean

Returns:

true if the feature is supported, false otherwise.
canRequestVMDeathEvent
()

Determines if the target VM supports the creation of VMDeathRequests.

public boolean

Returns:

true if the feature is supported, false otherwise.
canUnrestrictedlyRedefineClasses
()
Deprecated since 15. A JVM TI based JDWP back-end will never set this capability to true.

Determines if the target VM supports changes when performing class redefinition that are otherwise restricted by redefineClasses.

public boolean

Returns:

true if the feature is supported, false otherwise.
canUseInstanceFilters
()

Determines if the target VM supports filtering events by specific instance object.

public boolean

Returns:

true if the feature is supported, false otherwise.
canUseSourceNameFilters
()

Determines if the target VM supports the filtering of class prepare events by source name.

public boolean

Returns:

true if the feature is supported, false otherwise.
canWatchFieldAccess
()

Determines if the target VM supports watchpoints for field access.

public boolean

Returns:

true if the feature is supported, false otherwise.
canWatchFieldModification
()

Determines if the target VM supports watchpoints for field modification.

public List<ReferenceType>

Returns:

a list of ReferenceType objects, each mirroring a type in the target VM with the given name.
classesByName
(String
the class/interface name to search for
className
)

Returns the loaded reference types that match a given name.

public String

Returns:

the description.
description
()

Returns text information on the target VM and the debugger support that mirrors it.

public void
dispose()

Invalidates this virtual machine mirror.

public EventQueue

Returns:

the EventQueue for this virtual machine.
eventQueue
()

Returns the event queue for this virtual machine.

public EventRequestManager

Returns:

the EventRequestManager for this virtual machine.
eventRequestManager
()

Returns the event request manager for this virtual machine.

public void
exit(int
the exit code for the target VM. On some platforms, the exit code might be truncated, for example, to the lower order 8 bits.
exitCode
)

Causes the mirrored VM to terminate with the given error code.

public String

Returns:

null (meaning that the per-class default - ReferenceType#defaultStratum() - should be used) unless the default stratum has been set with setDefaultStratum(String).
getDefaultStratum
()

Return this VM's default stratum.

public long[]

Returns:

an array of long containing one element for each element in the 'refTypes' list. Element i of the array contains the number of instances in the target VM of the ReferenceType at position i in the 'refTypes' list. If the 'refTypes' list is empty, a zero-length array is returned. If a ReferenceType in refTypes has been garbage collected, zero is returned for its instance count.
instanceCounts
(List<? extends ReferenceType>
the list of ReferenceType objects for which counts are to be obtained.
refTypes
)

Returns the number of instances of each ReferenceType in the 'refTypes' list.

public BooleanValue

Returns:

the BooleanValue for the given boolean.
mirrorOf
(boolean
a boolean for which to create the value
value
)

Creates a BooleanValue for the given value.

public ByteValue

Returns:

the ByteValue for the given byte.
mirrorOf
(byte
a byte for which to create the value
value
)

Creates a ByteValue for the given value.

public CharValue

Returns:

the CharValue for the given char.
mirrorOf
(char
a char for which to create the value
value
)

Creates a CharValue for the given value.

public ShortValue

Returns:

the ShortValue for the given short.
mirrorOf
(short
a short for which to create the value
value
)

Creates a ShortValue for the given value.

public IntegerValue

Returns:

the IntegerValue for the given int.
mirrorOf
(int
an int for which to create the value
value
)

Creates an IntegerValue for the given value.

public LongValue

Returns:

the LongValue for the given long.
mirrorOf
(long
a long for which to create the value
value
)

Creates a LongValue for the given value.

public FloatValue

Returns:

the FloatValue for the given float.
mirrorOf
(float
a float for which to create the value
value
)

Creates a FloatValue for the given value.

public DoubleValue

Returns:

the DoubleValue for the given double.
mirrorOf
(double
a double for which to create the value
value
)

Creates a DoubleValue for the given value.

public StringReference

Returns:

a StringReference that mirrors the newly created string in the target VM.
mirrorOf
(String
the string to be created
value
)

Creates a string in this virtual machine.

public VoidValue

Returns:

the VoidValue.
mirrorOfVoid
()

Creates a VoidValue.

public String

Returns:

the target VM name.
name
()

Returns the name of the target VM as reported by the property java.vm.name.

public Process

Returns:

the java.lang.Process object for this virtual machine, or null if it was not launched by a LaunchingConnector.
process
()

Returns the java.lang.Process object for this virtual machine if launched by a LaunchingConnector

public void
redefineClasses(Map<? extends ReferenceType, byte[]>
A map from ReferenceType to array of byte. The bytes represent the new class definition and are in Java Virtual Machine class file format.
classToBytes
)

All classes given are redefined according to the definitions supplied.

public void
resume()

Continues the execution of the application running in this virtual machine.

public void
setDebugTraceMode(int
identifies which kinds of tracing to enable.
traceFlags
)

Traces the activities performed by the com.sun.jdi implementation.

public void
setDefaultStratum(String
the stratum to set as VM default, or null to use per-class defaults.
stratum
)

Set this VM's default stratum (see Location for a discussion of strata).

public void
suspend()

Suspends the execution of the application running in this virtual machine.

public List<ThreadGroupReference>

Returns:

a list of ThreadGroupReference objects, one for each top level thread group.
topLevelThreadGroups
()

Returns each thread group which does not have a parent.

public String

Returns:

the target VM version.
version
()

Returns the version of the Java Runtime Environment in the target VM as reported by the property java.version.

Inherited from com.sun.jdi.Mirror:
toStringvirtualMachine

Field Detail

TRACE_ALLback to summary
public static final int TRACE_ALL

All tracing is enabled.

TRACE_EVENTSback to summary
public static final int TRACE_EVENTS

Tracing enabled for internal event handling.

TRACE_NONEback to summary
public static final int TRACE_NONE

All tracing is disabled.

TRACE_OBJREFSback to summary
public static final int TRACE_OBJREFS

Tracing enabled for internal management of object references.

TRACE_RECEIVESback to summary
public static final int TRACE_RECEIVES

Tracing enabled for JDWP packets received from target VM.

TRACE_REFTYPESback to summary
public static final int TRACE_REFTYPES

Tracing enabled for internal management of reference types.

TRACE_SENDSback to summary
public static final int TRACE_SENDS

Tracing enabled for JDWP packets sent to target VM.

Method Detail

allClassesback to summary
public List<ReferenceType> allClasses()

Returns all loaded types in the target VM.

The returned list includes all reference types, including hidden classes or interfaces, loaded at least to the point of preparation and types (like array) for which preparation is not defined.

Returns:List<ReferenceType>

a list of ReferenceType objects, each mirroring a loaded type in the target VM.

See Also
JVM TI GetLoadedClasses regarding how class and interface creation can be triggered
allModulesback to summary
public default List<ModuleReference> allModules()

Returns all modules. For each module in the target VM a ModuleReference will be placed in the returned list.

Not all target virtual machines support this operation. Use VirtualMachine#canGetModuleInfo() to determine if the operation is supported.

Implementation Specification

The default implementation throws UnsupportedOperationException.

Returns:List<ModuleReference>

a list of ModuleReference objects, each mirroring a module in the target VM.

Exceptions
UnsupportedOperationException:
if the target virtual machine does not support this operation.
Since
9
allThreadsback to summary
public List<ThreadReference> allThreads()

Returns a list of the live threads in the target VM. Threads that have not yet started or threads that have terminated are not included in the list.

The returned list contains a ThreadReference for each live platform thread in the target VM. This includes platform threads created with the java.lang.Thread API and all native threads attached to the target VM with JNI code.

It is implementation dependent if the list contains elements for live virtual threads in the target VM. The target VM may not return any references to virtual threads, or it may be configured to return a reference to some or all virtual threads. Tools that want to track all virtual threads may enable ThreadStartRequest and ThreadDeathRequest to get notifications when virtual threads start and terminate.

Returns:List<ThreadReference>

a list of ThreadReference objects for the threads in the target VM

canAddMethodback to summary
public boolean canAddMethod()

Deprecated

since 15.

A JVM TI based JDWP back-end will never set this capability to true.

Determines if the target VM supports the addition of methods when performing class redefinition.

Returns:boolean

true if the feature is supported, false otherwise.

Annotations
@Deprecated
since:15
Since
1.4
See Also
redefineClasses
canBeModifiedback to summary
public boolean canBeModified()

Determines if the target VM is a read-only VM. If a method which would modify the state of the VM is called on a read-only VM, then VMCannotBeModifiedException is thrown.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.5
canForceEarlyReturnback to summary
public boolean canForceEarlyReturn()

Determines if the target VM supports the forcing of a method to return early.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.6
See Also
ThreadReference#forceEarlyReturn(Value)
canGetBytecodesback to summary
public boolean canGetBytecodes()

Determines if the target VM supports the retrieval of a method's bytecodes.

Returns:boolean

true if the feature is supported, false otherwise.

canGetClassFileVersionback to summary
public boolean canGetClassFileVersion()

Determines if the target VM supports reading class file major and minor versions.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.6
See Also
ReferenceType#majorVersion(), ReferenceType#minorVersion()
canGetConstantPoolback to summary
public boolean canGetConstantPool()

Determines if the target VM supports getting constant pool information of a class.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.6
See Also
ReferenceType#constantPoolCount(), ReferenceType#constantPool()
canGetCurrentContendedMonitorback to summary
public boolean canGetCurrentContendedMonitor()

Determines if the target VM supports the retrieval of the monitor for which a thread is currently waiting.

Returns:boolean

true if the feature is supported, false otherwise.

canGetInstanceInfoback to summary
public boolean canGetInstanceInfo()

Determines if the target VM supports the accessing of class instances, instance counts, and referring objects.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.6
See Also
instanceCounts, ReferenceType#instances(long), ObjectReference#referringObjects(long)
canGetMethodReturnValuesback to summary
public boolean canGetMethodReturnValues()

Determines if the target VM supports the inclusion of return values in MethodExitEvents.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.6
See Also
EventRequestManager#createMethodExitRequest
canGetModuleInfoback to summary
public default boolean canGetModuleInfo()

Determines if the target VM supports getting information about modules.

Implementation Specification

The default implementation returns false.

Returns:boolean

true if the feature is supported, false otherwise

Since
9
See Also
VirtualMachine#allModules(), ReferenceType#module(), ModuleReference
canGetMonitorFrameInfoback to summary
public boolean canGetMonitorFrameInfo()

Determines if the target VM supports getting which frame has acquired a monitor.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.6
See Also
ThreadReference#ownedMonitorsAndFrames
canGetMonitorInfoback to summary
public boolean canGetMonitorInfo()

Determines if the target VM supports the retrieval of the monitor information for an object.

Returns:boolean

true if the feature is supported, false otherwise.

canGetOwnedMonitorInfoback to summary
public boolean canGetOwnedMonitorInfo()

Determines if the target VM supports the retrieval of the monitors owned by a thread.

Returns:boolean

true if the feature is supported, false otherwise.

canGetSourceDebugExtensionback to summary
public boolean canGetSourceDebugExtension()

Determines if the target VM supports getting the source debug extension.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.4
See Also
ReferenceType#sourceDebugExtension
canGetSyntheticAttributeback to summary
public boolean canGetSyntheticAttribute()

Determines if the target VM supports the query of the synthetic attribute of a method or field.

Returns:boolean

true if the feature is supported, false otherwise.

canPopFramesback to summary
public boolean canPopFrames()

Determines if the target VM supports popping frames of a threads stack.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.4
See Also
ThreadReference#popFrames
canRedefineClassesback to summary
public boolean canRedefineClasses()

Determines if the target VM supports any level of class redefinition.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.4
See Also
redefineClasses
canRequestMonitorEventsback to summary
public boolean canRequestMonitorEvents()

Determines if the target VM supports the creation of MonitorContendedEnterRequests. MonitorContendedEnteredRequests. MonitorWaitRequests. MonitorWaitedRequests.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.6
See Also
EventRequestManager#createMonitorContendedEnterRequest, EventRequestManager#createMonitorContendedEnteredRequest, EventRequestManager#createMonitorWaitRequest, EventRequestManager#createMonitorWaitedRequest
canRequestVMDeathEventback to summary
public boolean canRequestVMDeathEvent()

Determines if the target VM supports the creation of VMDeathRequests.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.4
See Also
EventRequestManager#createVMDeathRequest
canUnrestrictedlyRedefineClassesback to summary
public boolean canUnrestrictedlyRedefineClasses()

Deprecated

since 15.

A JVM TI based JDWP back-end will never set this capability to true.

Determines if the target VM supports changes when performing class redefinition that are otherwise restricted by redefineClasses.

Returns:boolean

true if the feature is supported, false otherwise.

Annotations
@Deprecated
since:15
Since
1.4
See Also
redefineClasses
canUseInstanceFiltersback to summary
public boolean canUseInstanceFilters()

Determines if the target VM supports filtering events by specific instance object. For example, see BreakpointRequest#addInstanceFilter.

Returns:boolean

true if the feature is supported, false otherwise.

canUseSourceNameFiltersback to summary
public boolean canUseSourceNameFilters()

Determines if the target VM supports the filtering of class prepare events by source name.

Returns:boolean

true if the feature is supported, false otherwise.

Since
1.6
See Also
ClassPrepareRequest#addSourceNameFilter
canWatchFieldAccessback to summary
public boolean canWatchFieldAccess()

Determines if the target VM supports watchpoints for field access.

Returns:boolean

true if the feature is supported, false otherwise.

canWatchFieldModificationback to summary
public boolean canWatchFieldModification()

Determines if the target VM supports watchpoints for field modification.

Returns:boolean

true if the feature is supported, false otherwise.

classesByNameback to summary
public List<ReferenceType> classesByName(String className)

Returns the loaded reference types that match a given name. The name must be fully qualified (for example, java.lang.String). The returned list will contain a ReferenceType for each class or interface found with the given name. The search is confined to loaded classes only; no attempt is made to load a class of the given name.

The returned list will include reference types loaded at least to the point of preparation and types (like array) for which preparation is not defined.

Parameters
className:String

the class/interface name to search for

Returns:List<ReferenceType>

a list of ReferenceType objects, each mirroring a type in the target VM with the given name.

descriptionback to summary
public String description()

Returns text information on the target VM and the debugger support that mirrors it. No specific format for this information is guaranteed. Typically, this string contains version information for the target VM and debugger interfaces. More precise information on VM and JDI versions is available through version, VirtualMachineManager#majorInterfaceVersion, and VirtualMachineManager#minorInterfaceVersion

Returns:String

the description.

disposeback to summary
public void dispose()

Invalidates this virtual machine mirror. The communication channel to the target VM is closed, and the target VM prepares to accept another subsequent connection from this debugger or another debugger, including the following tasks:

Any current method invocations executing in the target VM are continued after the disconnection. Upon completion of any such method invocation, the invoking thread continues from the location where it was originally stopped.

Resources originating in this VirtualMachine (ObjectReferences, ReferenceTypes, etc.) will become invalid.

eventQueueback to summary
public EventQueue eventQueue()

Returns the event queue for this virtual machine. A virtual machine has only one EventQueue object, this method will return the same instance each time it is invoked.

Returns:EventQueue

the EventQueue for this virtual machine.

Exceptions
VMCannotBeModifiedException:
if the VirtualMachine is read-only - see VirtualMachine#canBeModified().
eventRequestManagerback to summary
public EventRequestManager eventRequestManager()

Returns the event request manager for this virtual machine. The EventRequestManager controls user settable events such as breakpoints. A virtual machine has only one EventRequestManager object, this method will return the same instance each time it is invoked.

Returns:EventRequestManager

the EventRequestManager for this virtual machine.

Exceptions
VMCannotBeModifiedException:
if the VirtualMachine is read-only - see VirtualMachine#canBeModified().
exitback to summary
public void exit(int exitCode)

Causes the mirrored VM to terminate with the given error code. All resources associated with this VirtualMachine are freed. If the mirrored VM is remote, the communication channel to it will be closed. Resources originating in this VirtualMachine (ObjectReferences, ReferenceTypes, etc.) will become invalid.

Threads running in the mirrored VM are abruptly terminated. A thread death exception is not thrown and finally blocks are not run.

Parameters
exitCode:int

the exit code for the target VM. On some platforms, the exit code might be truncated, for example, to the lower order 8 bits.

Exceptions
VMCannotBeModifiedException:
if the VirtualMachine is read-only - see VirtualMachine#canBeModified().
getDefaultStratumback to summary
public String getDefaultStratum()

Return this VM's default stratum.

Returns:String

null (meaning that the per-class default - ReferenceType#defaultStratum() - should be used) unless the default stratum has been set with setDefaultStratum(String).

Since
1.4
See Also
setDefaultStratum(String), ReferenceType#defaultStratum()
instanceCountsback to summary
public long[] instanceCounts(List<? extends ReferenceType> refTypes)

Returns the number of instances of each ReferenceType in the 'refTypes' list. Only instances that are reachable for the purposes of garbage collection are counted.

Not all target virtual machines support this operation. Use VirtualMachine#canGetInstanceInfo() to determine if the operation is supported.

Parameters
refTypes:List<? extends ReferenceType>

the list of ReferenceType objects for which counts are to be obtained.

Returns:long[]

an array of long containing one element for each element in the 'refTypes' list. Element i of the array contains the number of instances in the target VM of the ReferenceType at position i in the 'refTypes' list. If the 'refTypes' list is empty, a zero-length array is returned. If a ReferenceType in refTypes has been garbage collected, zero is returned for its instance count.

Exceptions
UnsupportedOperationException:
if the target virtual machine does not support this operation - see canGetInstanceInfo()
NullPointerException:
if the 'refTypes' list is null.
Since
1.6
See Also
ReferenceType#instances(long), ObjectReference#referringObjects(long)
mirrorOfback to summary
public BooleanValue mirrorOf(boolean value)

Creates a BooleanValue for the given value. This value can be used for setting and comparing against a value retrieved from a variable or field in this virtual machine.

Parameters
value:boolean

a boolean for which to create the value

Returns:BooleanValue

the BooleanValue for the given boolean.

mirrorOfback to summary
public ByteValue mirrorOf(byte value)

Creates a ByteValue for the given value. This value can be used for setting and comparing against a value retrieved from a variable or field in this virtual machine.

Parameters
value:byte

a byte for which to create the value

Returns:ByteValue

the ByteValue for the given byte.

mirrorOfback to summary
public CharValue mirrorOf(char value)

Creates a CharValue for the given value. This value can be used for setting and comparing against a value retrieved from a variable or field in this virtual machine.

Parameters
value:char

a char for which to create the value

Returns:CharValue

the CharValue for the given char.

mirrorOfback to summary
public ShortValue mirrorOf(short value)

Creates a ShortValue for the given value. This value can be used for setting and comparing against a value retrieved from a variable or field in this virtual machine.

Parameters
value:short

a short for which to create the value

Returns:ShortValue

the ShortValue for the given short.

mirrorOfback to summary
public IntegerValue mirrorOf(int value)

Creates an IntegerValue for the given value. This value can be used for setting and comparing against a value retrieved from a variable or field in this virtual machine.

Parameters
value:int

an int for which to create the value

Returns:IntegerValue

the IntegerValue for the given int.

mirrorOfback to summary
public LongValue mirrorOf(long value)

Creates a LongValue for the given value. This value can be used for setting and comparing against a value retrieved from a variable or field in this virtual machine.

Parameters
value:long

a long for which to create the value

Returns:LongValue

the LongValue for the given long.

mirrorOfback to summary
public FloatValue mirrorOf(float value)

Creates a FloatValue for the given value. This value can be used for setting and comparing against a value retrieved from a variable or field in this virtual machine.

Parameters
value:float

a float for which to create the value

Returns:FloatValue

the FloatValue for the given float.

mirrorOfback to summary
public DoubleValue mirrorOf(double value)

Creates a DoubleValue for the given value. This value can be used for setting and comparing against a value retrieved from a variable or field in this virtual machine.

Parameters
value:double

a double for which to create the value

Returns:DoubleValue

the DoubleValue for the given double.

mirrorOfback to summary
public StringReference mirrorOf(String value)

Creates a string in this virtual machine. The created string can be used for setting and comparing against a string value retrieved from a variable or field in this virtual machine.

Parameters
value:String

the string to be created

Returns:StringReference

a StringReference that mirrors the newly created string in the target VM.

Exceptions
VMCannotBeModifiedException:
if the VirtualMachine is read-only - see VirtualMachine#canBeModified().
mirrorOfVoidback to summary
public VoidValue mirrorOfVoid()

Creates a VoidValue. This value can be passed to ThreadReference#forceEarlyReturn when a void method is to be exited.

Returns:VoidValue

the VoidValue.

nameback to summary
public String name()

Returns the name of the target VM as reported by the property java.vm.name.

Returns:String

the target VM name.

processback to summary
public Process process()

Returns the java.lang.Process object for this virtual machine if launched by a LaunchingConnector

Returns:Process

the java.lang.Process object for this virtual machine, or null if it was not launched by a LaunchingConnector.

Exceptions
VMCannotBeModifiedException:
if the VirtualMachine is read-only - see VirtualMachine#canBeModified().
redefineClassesback to summary
public void redefineClasses(Map<? extends ReferenceType, byte[]> classToBytes)

All classes given are redefined according to the definitions supplied. A method in a redefined class is called 'equivalent' (to the old version of the method) if

  • their bytecodes are the same except for indices into the constant pool, and
  • the referenced constants are equal.
Otherwise, the new method is called 'non-equivalent'. If a redefined method has active stack frames, those active frames continue to run the bytecodes of the previous version of the method. If the new version of such a method is non-equivalent, then a method from one of these active frames is called 'obsolete' and Method.isObsolete() will return true when called on one of these methods. If resetting such a frame is desired, use ThreadReference.popFrames(StackFrame) to pop the old obsolete method execution from the stack. New invocations of redefined methods will always invoke the new versions.

This function does not cause any initialization except that which would occur under the customary JVM semantics. In other words, redefining a class does not cause its initializers to be run. The values of preexisting static variables will remain as they were prior to the call. However, completely uninitialized (new) static variables will be assigned their default value.

If a redefined class has instances then all those instances will have the fields defined by the redefined class at the completion of the call. Preexisting fields will retain their previous values. Any new fields will have their default values; no instance initializers or constructors are run.

Threads need not be suspended.

No events are generated by this function.

All breakpoints in the redefined classes are deleted.

Not all target virtual machines support this operation. Use canRedefineClasses() to determine if the operation is supported. Use canAddMethod() to determine if the redefinition can add methods. Use canUnrestrictedlyRedefineClasses() to determine if the redefinition can change the schema, delete methods, change the class hierarchy, etc.

Parameters
classToBytes:Map<? extends ReferenceType, byte[]>

A map from ReferenceType to array of byte. The bytes represent the new class definition and are in Java Virtual Machine class file format.

Exceptions
UnsupportedOperationException:
if the target virtual machine does not support this operation.
NoClassDefFoundError:
if the bytes don't correspond to the reference type (the names don't match).
VerifyError:
if a "verifier" detects that a class, though well formed, contains an internal inconsistency or security problem.
ClassFormatError:
if the bytes do not represent a valid class.
ClassCircularityError:
if a circularity has been detected while initializing a class.
UnsupportedClassVersionError:
if the major and minor version numbers in bytes are not supported by the VM.
VMCannotBeModifiedException:
if the VirtualMachine is read-only - see VirtualMachine#canBeModified().
Since
1.4
See Also
Method#isObsolete, ThreadReference#popFrames, canRedefineClasses, canAddMethod, canUnrestrictedlyRedefineClasses
resumeback to summary
public void resume()

Continues the execution of the application running in this virtual machine. All threads are resumed as documented in ThreadReference#resume.

Exceptions
VMCannotBeModifiedException:
if the VirtualMachine is read-only
See Also
suspend(), canBeModified()
setDebugTraceModeback to summary
public void setDebugTraceMode(int traceFlags)

Traces the activities performed by the com.sun.jdi implementation. All trace information is output to System.err. The given trace flags are used to limit the output to only the information desired. The given flags are in effect and the corresponding trace will continue until the next call to this method.

Output is implementation dependent and trace mode may be ignored.

Parameters
traceFlags:int

identifies which kinds of tracing to enable.

setDefaultStratumback to summary
public void setDefaultStratum(String stratum)

Set this VM's default stratum (see Location for a discussion of strata). Overrides the per-class default set in the class file.

Affects location queries (such as, Location#sourceName()) and the line boundaries used in single stepping.

Parameters
stratum:String

the stratum to set as VM default, or null to use per-class defaults.

Exceptions
UnsupportedOperationException:
if the target virtual machine does not support this operation.
Since
1.4
suspendback to summary
public void suspend()

Suspends the execution of the application running in this virtual machine. All threads currently running will be suspended.

Suspends of both the virtual machine and individual threads are counted. Before a thread will run again, it must be resumed (through resume or ThreadReference#resume) the same number of times it has been suspended.

Exceptions
VMCannotBeModifiedException:
if the VirtualMachine is read-only
See Also
canBeModified()
topLevelThreadGroupsback to summary
public List<ThreadGroupReference> topLevelThreadGroups()

Returns each thread group which does not have a parent. For each top level thread group a ThreadGroupReference is placed in the returned list.

This command may be used as the first step in building a tree (or trees) of the existing thread groups.

Returns:List<ThreadGroupReference>

a list of ThreadGroupReference objects, one for each top level thread group.

versionback to summary
public String version()

Returns the version of the Java Runtime Environment in the target VM as reported by the property java.version. For obtaining the JDI interface version, use VirtualMachineManager#majorInterfaceVersion and VirtualMachineManager#minorInterfaceVersion

Returns:String

the target VM version.