APIdia Launch Partner
Top Inners Fields Constructors Methods
com.sun.tools.jdi

public Class ObjectReferenceImpl

extends ValueImpl
implements ObjectReference, VMListener
Class Inheritance
All Implemented Interfaces
com.sun.tools.jdi.VMListener, java.util.EventListener, com.sun.jdi.ObjectReference, com.sun.jdi.Value, com.sun.jdi.Mirror
Known Direct Subclasses
com.sun.tools.jdi.StringReferenceImpl, com.sun.tools.jdi.ThreadGroupReferenceImpl, com.sun.tools.jdi.ThreadReferenceImpl, com.sun.tools.jdi.ArrayReferenceImpl, com.sun.tools.jdi.ClassLoaderReferenceImpl, com.sun.tools.jdi.ClassObjectReferenceImpl, com.sun.tools.jdi.ModuleReferenceImpl
Imports
java.util.ArrayList, .Arrays, .HashMap, .List, .Map, com.sun.jdi.ClassNotLoadedException, .ClassType, .Field, .IncompatibleThreadStateException, .InterfaceType, .InternalException, .InvalidTypeException, .InvocationException, .Method, .ObjectReference, .ReferenceType, .ThreadReference, .Type, .Value, .VirtualMachine

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class

Field Summary

Modifier and TypeField and Description
pack-priv boolean
private ObjectReferenceImpl.Cache
private int
private static final ObjectReferenceImpl.Cache
private static final ObjectReferenceImpl.Cache
protected long
private ReferenceType

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected String
private void
public synchronized void
disableCollection()

Implements com.sun.jdi.ObjectReference.disableCollection.

Prevents garbage collection for this object.

private void
public synchronized void
enableCollection()

Implements com.sun.jdi.ObjectReference.enableCollection.

Permits garbage collection for this object.

public int
entryCount()

Implements com.sun.jdi.ObjectReference.entryCount.

Returns the number of times this object's monitor has been entered by the current owning thread if the owning thread is platform thread; Returns 0 if not owned by a platform thread.

public boolean
equals(Object obj)

Overrides com.sun.tools.jdi.MirrorImpl.equals.

Implements com.sun.jdi.ObjectReference.equals.

Compares the specified Object with this ObjectReference for equality.

protected ObjectReferenceImpl.Cache
public Value
getValue(Field sig)

Implements com.sun.jdi.ObjectReference.getValue.

Gets the value of a given instance or static field in this object.

public Map<Field, Value>
getValues(List<? extends Field> theFields)

Implements com.sun.jdi.ObjectReference.getValues.

Gets the value of multiple instance and/or static fields in this object.

public int
hashCode()

Overrides com.sun.tools.jdi.MirrorImpl.hashCode.

Implements com.sun.jdi.ObjectReference.hashCode.

Returns the hash code value for this ObjectReference.

protected ClassTypeImpl
public Value
invokeMethod(ThreadReference threadIntf, Method methodIntf, List<? extends Value> origArguments, int options)

Implements com.sun.jdi.ObjectReference.invokeMethod.

Invokes the specified Method on this object in the target VM.

pack-priv boolean
public boolean
isCollected()

Implements com.sun.jdi.ObjectReference.isCollected.

Determines if this object has been garbage collected in the target VM.

private static boolean
isNonVirtual(int options)

pack-priv JDWP.ObjectReference.MonitorInfo
protected ObjectReferenceImpl.Cache
public ThreadReference
owningThread()

Implements com.sun.jdi.ObjectReference.owningThread.

Returns a ThreadReference for the platform thread, if any, which currently owns this object's monitor.

pack-priv ValueImpl
pack-priv long
ref()

public ReferenceType
referenceType()

Implements com.sun.jdi.ObjectReference.referenceType.

Gets the ReferenceType that mirrors the type of this object.

public List<ObjectReference>
referringObjects(long maxReferrers)

Implements com.sun.jdi.ObjectReference.referringObjects.

Returns objects that directly reference this object.

pack-priv PacketStream
sendInvokeCommand(final ThreadReferenceImpl thread, final ClassTypeImpl refType, final MethodImpl method, final ValueImpl[] args, final int options)

public void
setValue(Field field, Value value)

Implements com.sun.jdi.ObjectReference.setValue.

Sets the value of a given instance or static field in this object.

public String
toString()

Overrides java.lang.Object.toString.

Implements com.sun.jdi.Mirror.toString.

Returns a String describing this mirror

public Type
type()

Implements com.sun.jdi.Value.type.

Returns the run-time type of this value.

pack-priv byte
public long
uniqueID()

Implements com.sun.jdi.ObjectReference.uniqueID.

Returns a unique identifier for this ObjectReference.

pack-priv void
pack-priv void
pack-priv void
pack-priv void
validateMethodInvocation(Method method, int options)

public boolean
public boolean
public List<ThreadReference>
waitingThreads()

Implements com.sun.jdi.ObjectReference.waitingThreads.

Returns a List containing a ThreadReference for each platform thread currently waiting for this object's monitor.

Inherited from com.sun.tools.jdi.ValueImpl:
prepareForAssignmenttypeValueKey

Field Detail

addedListenerback to summary
pack-priv boolean addedListener
cacheback to summary
private ObjectReferenceImpl.Cache cache
gcDisableCountback to summary
private int gcDisableCount
markerCacheback to summary
private static final ObjectReferenceImpl.Cache markerCache
noInitCacheback to summary
private static final ObjectReferenceImpl.Cache noInitCache
refback to summary
protected long ref
typeback to summary
private ReferenceType type

Constructor Detail

ObjectReferenceImplback to summary
pack-priv ObjectReferenceImpl(VirtualMachine aVm, long aRef)

Method Detail

descriptionback to summary
protected String description()
disableCacheback to summary
private void disableCache()
disableCollectionback to summary
public synchronized void disableCollection()

Implements com.sun.jdi.ObjectReference.disableCollection.

Doc from com.sun.jdi.ObjectReference.disableCollection.

Prevents garbage collection for this object. By default all ObjectReference values returned by JDI may be collected at any time the target VM is running. A call to this method guarantees that the object will not be collected. enableCollection can be used to allow collection once again.

Calls to this method are counted. Every call to this method requires a corresponding call to enableCollection before garbage collection is re-enabled.

Note that while the target VM is suspended, no garbage collection will occur because all threads are suspended. The typical examination of variables, fields, and arrays during the suspension is safe without explicitly disabling garbage collection.

This method should be used sparingly, as it alters the pattern of garbage collection in the target VM and, consequently, may result in application behavior under the debugger that differs from its non-debugged behavior.

enableCacheback to summary
private void enableCache()
enableCollectionback to summary
public synchronized void enableCollection()

Implements com.sun.jdi.ObjectReference.enableCollection.

Doc from com.sun.jdi.ObjectReference.enableCollection.

Permits garbage collection for this object. By default all ObjectReference values returned by JDI may be collected at any time the target VM is running. A call to this method is necessary only if garbage collection was previously disabled with disableCollection.

entryCountback to summary
public int entryCount() throws IncompatibleThreadStateException

Implements com.sun.jdi.ObjectReference.entryCount.

Doc from com.sun.jdi.ObjectReference.entryCount.

Returns the number of times this object's monitor has been entered by the current owning thread if the owning thread is platform thread; Returns 0 if not owned by a platform thread. See ThreadReference#ownedMonitors for a definition of ownership.

Not all target VMs support this operation. See VirtualMachine#canGetMonitorInfo to determine if the operation is supported.

Exceptions
IncompatibleThreadStateException:
if the owning thread is not suspended in the target VM
equalsback to summary
public boolean equals(Object obj)

Overrides com.sun.tools.jdi.MirrorImpl.equals.

Implements com.sun.jdi.ObjectReference.equals.

Doc from com.sun.jdi.ObjectReference.equals.

Compares the specified Object with this ObjectReference for equality.

getCacheback to summary
protected ObjectReferenceImpl.Cache getCache()
getValueback to summary
public Value getValue(Field sig)

Implements com.sun.jdi.ObjectReference.getValue.

Doc from com.sun.jdi.ObjectReference.getValue.

Gets the value of a given instance or static field in this object. The Field must be valid for this ObjectReference; that is, it must be from the mirrored object's class or a superclass of that class.

getValuesback to summary
public Map<Field, Value> getValues(List<? extends Field> theFields)

Implements com.sun.jdi.ObjectReference.getValues.

Doc from com.sun.jdi.ObjectReference.getValues.

Gets the value of multiple instance and/or static fields in this object. The Fields must be valid for this ObjectReference; that is, they must be from the mirrored object's class or a superclass of that class.

hashCodeback to summary
public int hashCode()

Overrides com.sun.tools.jdi.MirrorImpl.hashCode.

Implements com.sun.jdi.ObjectReference.hashCode.

Doc from com.sun.jdi.ObjectReference.hashCode.

Returns the hash code value for this ObjectReference.

Annotations
@Override
invokableReferenceTypeback to summary
protected ClassTypeImpl invokableReferenceType(Method method)
invokeMethodback to summary
public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List<? extends Value> origArguments, int options) throws InvalidTypeException, IncompatibleThreadStateException, InvocationException, ClassNotLoadedException

Implements com.sun.jdi.ObjectReference.invokeMethod.

Doc from com.sun.jdi.ObjectReference.invokeMethod.

Invokes the specified Method on this object in the target VM. The specified method can be defined in this object's class, in a superclass of this object's class, or in an interface implemented by this object. The method may be a static method or an instance method, but not a static initializer or constructor. Use ClassType#newInstance to create a new object and run its constructor.

The method invocation will occur in the specified thread. Method invocation can occur only if the specified thread has been suspended by an event which occurred in that thread. Method invocation is not supported when the target VM has been suspended through VirtualMachine#suspend or when the specified thread is suspended through ThreadReference#suspend.

The specified method is invoked with the arguments in the specified argument list. The method invocation is synchronous; this method does not return until the invoked method returns in the target VM. If the invoked method throws an exception, this method will throw an InvocationException which contains a mirror to the exception object thrown.

Object arguments must be assignment compatible with the argument type (This implies that the argument type must be loaded through the enclosing class's class loader). Primitive arguments must be either assignment compatible with the argument type or must be convertible to the argument type without loss of information. If the method being called accepts a variable number of arguments, then the last argument type is an array of some component type. The argument in the matching position can be omitted, or can be null, an array of the same component type, or an argument of the component type followed by any number of other arguments of the same type. If the argument is omitted, then a 0 length array of the component type is passed. The component type can be a primitive type. Autoboxing is not supported. See section 5.2 of The Java Language Specification for more information on assignment compatibility.

By default, the method is invoked using dynamic lookup as documented in section 15.12.4.4 of The Java Language Specification in particular, overriding based on the runtime type of the object mirrored by this ObjectReference will occur. This behavior can be changed by specifying the INVOKE_NONVIRTUAL bit flag in the options argument. If this flag is set, the specified method is invoked whether or not it is overridden for this object's runtime type. The method, in this case, must have an implementation, either in a class or an interface. This option is useful for performing method invocations like those done with the super keyword in the Java programming language.

By default, all threads in the target VM are resumed while the method is being invoked if they were previously suspended by an event or by VirtualMachine#suspend or ThreadReference#suspend. This is done to prevent the deadlocks that will occur if any of the threads own resources, such as monitors, that will be needed by the invoked method. Note, however, that this implicit resume acts exactly like ThreadReference#resume, so if the thread's suspend count is greater than 1, it will remain in a suspended state during the invocation and thus a deadlock could still occur. By default, when the invocation completes, all threads in the target VM are suspended, regardless their state before the invocation. It is possible that breakpoints or other events might occur during the invocation. This can cause deadlocks as described above. It can also cause a deadlock if invokeMethod is called from the client's event handler thread. In this case, this thread will be waiting for the invokeMethod to complete and won't read the EventSet that comes in for the new event. If this new EventSet is SUSPEND_ALL, then a deadlock will occur because no one will resume the EventSet. To avoid this, all EventRequests should be disabled before doing the invokeMethod, or the invokeMethod should not be done from the client's event handler thread.

The resumption of other threads during the invocation can be prevented by specifying the INVOKE_SINGLE_THREADED bit flag in the options argument; however, there is no protection against or recovery from the deadlocks described above, so this option should be used with great caution. Only the specified thread will be resumed (as described for all threads above). Upon completion of a single threaded invoke, the invoking thread will be suspended once again. Note that any threads started during the single threaded invocation will not be suspended when the invocation completes.

If the target VM is disconnected during the invoke (for example, through VirtualMachine#dispose) the method invocation continues.

Exceptions
InvalidTypeException:
If the arguments do not meet this requirement -- Object arguments must be assignment compatible with the argument type. This implies that the argument type must be loaded through the enclosing class's class loader. Primitive arguments must be either assignment compatible with the argument type or must be convertible to the argument type without loss of information. See JLS section 5.2 for more information on assignment compatibility.
IncompatibleThreadStateException:
if the specified thread has not been suspended by an event.
InvocationException:
if the method invocation resulted in an exception in the target VM.
ClassNotLoadedException:
if any argument type has not yet been loaded through the appropriate class loader.
isClassObjectback to summary
pack-priv boolean isClassObject()
isCollectedback to summary
public boolean isCollected()

Implements com.sun.jdi.ObjectReference.isCollected.

Doc from com.sun.jdi.ObjectReference.isCollected.

Determines if this object has been garbage collected in the target VM.

isNonVirtualback to summary
private static boolean isNonVirtual(int options)
jdwpMonitorInfoback to summary
pack-priv JDWP.ObjectReference.MonitorInfo jdwpMonitorInfo() throws IncompatibleThreadStateException
newCacheback to summary
protected ObjectReferenceImpl.Cache newCache()
owningThreadback to summary
public ThreadReference owningThread() throws IncompatibleThreadStateException

Implements com.sun.jdi.ObjectReference.owningThread.

Doc from com.sun.jdi.ObjectReference.owningThread.

Returns a ThreadReference for the platform thread, if any, which currently owns this object's monitor. See ThreadReference#ownedMonitors for a definition of ownership.

Not all target VMs support this operation. See VirtualMachine#canGetMonitorInfo to determine if the operation is supported.

Exceptions
IncompatibleThreadStateException:
if the owning thread is not suspended in the target VM
prepareForAssignmentToback to summary
pack-priv ValueImpl prepareForAssignmentTo(ValueContainer destination) throws InvalidTypeException, ClassNotLoadedException

Implements abstract com.sun.tools.jdi.ValueImpl.prepareForAssignmentTo.

refback to summary
pack-priv long ref()
referenceTypeback to summary
public ReferenceType referenceType()

Implements com.sun.jdi.ObjectReference.referenceType.

Doc from com.sun.jdi.ObjectReference.referenceType.

Gets the ReferenceType that mirrors the type of this object. The type may be a subclass or implementor of the declared type of any field or variable which currently holds it. For example, right after the following statement.

Object obj = new String("Hello, world!");

The ReferenceType of obj will mirror java.lang.String and not java.lang.Object.

The type of an object never changes, so this method will always return the same ReferenceType over the lifetime of the mirrored object.

The returned ReferenceType will be a ClassType or ArrayType and never an InterfaceType.

referringObjectsback to summary
public List<ObjectReference> referringObjects(long maxReferrers)

Implements com.sun.jdi.ObjectReference.referringObjects.

Doc from com.sun.jdi.ObjectReference.referringObjects.

Returns objects that directly reference this object. Only objects that are reachable for the purposes of garbage collection are returned. Note that an object can also be referenced in other ways, such as from a local variable in a stack frame, or from a JNI global reference. Such non-object referrers are not returned by this method.

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

sendInvokeCommandback to summary
pack-priv PacketStream sendInvokeCommand(final ThreadReferenceImpl thread, final ClassTypeImpl refType, final MethodImpl method, final ValueImpl[] args, final int options)
setValueback to summary
public void setValue(Field field, Value value) throws InvalidTypeException, ClassNotLoadedException

Implements com.sun.jdi.ObjectReference.setValue.

Doc from com.sun.jdi.ObjectReference.setValue.

Sets the value of a given instance or static field in this object. The Field must be valid for this ObjectReference; that is, it must be from the mirrored object's class or a superclass of that class. The field must not be final.

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

Exceptions
InvalidTypeException:
if the value's type does not match the field's type.
ClassNotLoadedException:
if 'value' is not null, and the field type has not yet been loaded through the appropriate class loader.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements com.sun.jdi.Mirror.toString.

Doc from com.sun.jdi.Mirror.toString.

Returns a String describing this mirror

typeback to summary
public Type type()

Implements com.sun.jdi.Value.type.

Doc from com.sun.jdi.Value.type.

Returns the run-time type of this value.

typeValueKeyback to summary
pack-priv byte typeValueKey()

Implements abstract com.sun.tools.jdi.ValueImpl.typeValueKey.

uniqueIDback to summary
public long uniqueID()

Implements com.sun.jdi.ObjectReference.uniqueID.

Doc from com.sun.jdi.ObjectReference.uniqueID.

Returns a unique identifier for this ObjectReference. It is guaranteed to be unique among all ObjectReferences from the same VM that have not yet been disposed. The guarantee applies as long as this ObjectReference has not yet been disposed.

validateAssignmentback to summary
pack-priv void validateAssignment(ValueContainer destination) throws InvalidTypeException, ClassNotLoadedException
validateClassMethodInvocationback to summary
pack-priv void validateClassMethodInvocation(Method method, int options) throws InvalidTypeException, InvocationException
validateIfaceMethodInvocationback to summary
pack-priv void validateIfaceMethodInvocation(Method method, int options) throws InvalidTypeException, InvocationException
validateMethodInvocationback to summary
pack-priv void validateMethodInvocation(Method method, int options) throws InvalidTypeException, InvocationException
vmNotSuspendedback to summary
public boolean vmNotSuspended(VMAction action)

Implements com.sun.tools.jdi.VMListener.vmNotSuspended.

vmSuspendedback to summary
public boolean vmSuspended(VMAction action)

Implements com.sun.tools.jdi.VMListener.vmSuspended.

waitingThreadsback to summary
public List<ThreadReference> waitingThreads() throws IncompatibleThreadStateException

Implements com.sun.jdi.ObjectReference.waitingThreads.

Doc from com.sun.jdi.ObjectReference.waitingThreads.

Returns a List containing a ThreadReference for each platform thread currently waiting for this object's monitor. See ThreadReference#currentContendedMonitor for information about when a thread is considered to be waiting for a monitor.

Not all target VMs support this operation. See VirtualMachine#canGetMonitorInfo to determine if the operation is supported.

Exceptions
IncompatibleThreadStateException:
if any waiting thread is not suspended in the target VM
com.sun.tools.jdi back to summary

protected Class ObjectReferenceImpl.Cache

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.tools.jdi.ThreadGroupReferenceImpl.Cache, com.sun.tools.jdi.ThreadReferenceImpl.Cache, com.sun.tools.jdi.ClassLoaderReferenceImpl.Cache

Field Summary

Modifier and TypeField and Description
pack-priv JDWP.ObjectReference.MonitorInfo

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

monitorInfoback to summary
pack-priv JDWP.ObjectReference.MonitorInfo monitorInfo

Constructor Detail

Cacheback to summary
protected Cache()