VirtualMachine (Java SE 19 & JDK 19) (original) (raw)

Method Details

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 canGetModuleInfo() to determine if the operation is supported.
Implementation Requirements:
The default implementation throws UnsupportedOperationException.
Returns:
a list of ModuleReference objects, each mirroring a module in the target VM.
Throws:
[UnsupportedOperationException](../../../../java.base/java/lang/UnsupportedOperationException.html "class in java.lang") - if the target virtual machine does not support this operation.
Since:
9

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 - the class/interface name to search for
Returns:
a list of ReferenceType objects, each mirroring a type in the target VM with the given name.

Returns all loaded types in the target VM.
The returned list includes all reference types, includinghidden classes or interfaces, loaded at least to the point of preparation and types (like array) for which preparation is not defined.
Returns:
a list of ReferenceType objects, each mirroring a loaded type in the target VM.
See Also:

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

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 liveplatform thread in the target VM. This includes platform threads created with thejava.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 livevirtual 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:
a list of ThreadReference objects for the threads in the target VM

void suspend()
Suspends the execution of the application running in this virtual machine. All threads currently running will be suspended.
Unlike Thread.suspend(), 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.
Throws:
[VMCannotBeModifiedException](VMCannotBeModifiedException.html "class in com.sun.jdi") - if the VirtualMachine is read-only - see canBeModified().

void resume()
Continues the execution of the application running in this virtual machine. All threads are resumed as documented inThreadReference.resume().
Throws:
[VMCannotBeModifiedException](VMCannotBeModifiedException.html "class in com.sun.jdi") - if the VirtualMachine is read-only - see canBeModified().
See Also:

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:
a list of ThreadGroupReference objects, one for each top level thread group.

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:
the EventQueue for this virtual machine.
Throws:
[VMCannotBeModifiedException](VMCannotBeModifiedException.html "class in com.sun.jdi") - if the VirtualMachine is read-only - see canBeModified().

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:
the EventRequestManager for this virtual machine.
Throws:
[VMCannotBeModifiedException](VMCannotBeModifiedException.html "class in com.sun.jdi") - if the VirtualMachine is read-only - see canBeModified().

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 - a boolean for which to create the value
Returns:
the BooleanValue for the given boolean.

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 - a byte for which to create the value
Returns:
the ByteValue for the given byte.

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 - a char for which to create the value
Returns:
the CharValue for the given char.

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 - a short for which to create the value
Returns:
the ShortValue for the given short.

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 - an int for which to create the value
Returns:
the IntegerValue for the given int.

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 - a long for which to create the value
Returns:
the LongValue for the given long.

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 - a float for which to create the value
Returns:
the FloatValue for the given float.

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 - a double for which to create the value
Returns:
the DoubleValue for the given double.

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 - the string to be created
Returns:
a StringReference that mirrors the newly created string in the target VM.
Throws:
[VMCannotBeModifiedException](VMCannotBeModifiedException.html "class in com.sun.jdi") - if the VirtualMachine is read-only -see canBeModified().

Returns:
the VoidValue.

Returns:
the Process object for this virtual machine, or null if it was not launched by a LaunchingConnector.
Throws:
[VMCannotBeModifiedException](VMCannotBeModifiedException.html "class in com.sun.jdi") - if the VirtualMachine is read-only -see canBeModified().

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:

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 - the exit code for the target VM. On some platforms, the exit code might be truncated, for example, to the lower order 8 bits.
Throws:
[VMCannotBeModifiedException](VMCannotBeModifiedException.html "class in com.sun.jdi") - if the VirtualMachine is read-only - see canBeModified().

boolean canWatchFieldModification()
Determines if the target VM supports watchpoints for field modification.
Returns:
true if the feature is supported,false otherwise.

boolean canWatchFieldAccess()
Determines if the target VM supports watchpoints for field access.
Returns:
true if the feature is supported,false otherwise.

boolean canGetBytecodes()
Determines if the target VM supports the retrieval of a method's bytecodes.
Returns:
true if the feature is supported,false otherwise.

boolean canGetSyntheticAttribute()
Determines if the target VM supports the query of the synthetic attribute of a method or field.
Returns:
true if the feature is supported,false otherwise.

boolean canGetOwnedMonitorInfo()
Determines if the target VM supports the retrieval of the monitors owned by a thread.
Returns:
true if the feature is supported,false otherwise.

boolean canGetCurrentContendedMonitor()
Determines if the target VM supports the retrieval of the monitor for which a thread is currently waiting.
Returns:
true if the feature is supported,false otherwise.

boolean canGetMonitorInfo()
Determines if the target VM supports the retrieval of the monitor information for an object.
Returns:
true if the feature is supported,false otherwise.

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

boolean canRedefineClasses()
Determines if the target VM supports any level of class redefinition.
Returns:
true if the feature is supported,false otherwise.
Since:
1.4
See Also:

Determines if the target VM supports the addition of methods when performing class redefinition.
Returns:
true if the feature is supported,false otherwise.
Since:
1.4
See Also:

@Deprecated(since="15")boolean canUnrestrictedlyRedefineClasses()
Determines if the target VM supports changes when performing class redefinition that are otherwise restricted by redefineClasses(java.util.Map<? extends com.sun.jdi.ReferenceType, byte[]>).
Returns:
true if the feature is supported,false otherwise.
Since:
1.4
See Also:

boolean canPopFrames()
Determines if the target VM supports popping frames of a threads stack.
Returns:
true if the feature is supported,false otherwise.
Since:
1.4
See Also:

boolean canGetSourceDebugExtension()
Determines if the target VM supports getting the source debug extension.
Returns:
true if the feature is supported,false otherwise.
Since:
1.4
See Also:

boolean canRequestVMDeathEvent()
Determines if the target VM supports the creation ofVMDeathRequests.
Returns:
true if the feature is supported,false otherwise.
Since:
1.4
See Also:

boolean canGetMethodReturnValues()
Determines if the target VM supports the inclusion of return values inMethodExitEvents.
Returns:
true if the feature is supported,false otherwise.
Since:
1.6
See Also:

boolean canGetInstanceInfo()
Determines if the target VM supports the accessing of class instances, instance counts, and referring objects.
Returns:
true if the feature is supported,false otherwise.
Since:
1.6
See Also:

boolean canUseSourceNameFilters()
Returns:
true if the feature is supported,false otherwise.
Since:
1.6

boolean canForceEarlyReturn()
Determines if the target VM supports the forcing of a method to return early.
Returns:
true if the feature is supported,false otherwise.
Since:
1.6
See Also:

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:
true if the feature is supported,false otherwise.
Since:
1.5

boolean canRequestMonitorEvents()
Returns:
true if the feature is supported,false otherwise.
Since:
1.6
See Also:

boolean canGetMonitorFrameInfo()
Determines if the target VM supports getting which frame has acquired a monitor.
Returns:
true if the feature is supported,false otherwise.
Since:
1.6
See Also:

boolean canGetClassFileVersion()
Determines if the target VM supports reading class file major and minor versions.
Returns:
true if the feature is supported,false otherwise.
Since:
1.6
See Also:

boolean canGetConstantPool()
Determines if the target VM supports getting constant pool information of a class.
Returns:
true if the feature is supported,false otherwise.
Since:
1.6
See Also:

default boolean canGetModuleInfo()
Determines if the target VM supports getting information about modules.
Implementation Requirements:
The default implementation returns false.
Returns:
true if the feature is supported, false otherwise
Since:
9
See Also:

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 - the stratum to set as VM default, or null to use per-class defaults.
Throws:
[UnsupportedOperationException](../../../../java.base/java/lang/UnsupportedOperationException.html "class in java.lang") - if the target virtual machine does not support this operation.
Since:
1.4

String getDefaultStratum()
Return this VM's default stratum.
Returns:
null (meaning that the per-class default - ReferenceType.defaultStratum() - should be used) unless the default stratum has been set withsetDefaultStratum(String).
Since:
1.4
See Also:

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 canGetInstanceInfo() to determine if the operation is supported.
Parameters:
refTypes - the list of ReferenceType objects for which counts are to be obtained.
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.
Throws:
[UnsupportedOperationException](../../../../java.base/java/lang/UnsupportedOperationException.html "class in java.lang") - if the target virtual machine does not support this operation - seecanGetInstanceInfo()
[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang") - if the 'refTypes' list is null.
Since:
1.6
See Also:

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 throughversion(), VirtualMachineManager.majorInterfaceVersion(), and VirtualMachineManager.minorInterfaceVersion()
Returns:
the description.

Returns:
the target VM version.

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

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 - identifies which kinds of tracing to enable.