com.jrockit.memleak.value
Class AbstractObjectInfo

java.lang.Object
  extended by com.jrockit.memleak.value.AbstractObjectInfo
All Implemented Interfaces:
IObjectInfo, IObjectSpecifier, IClassInfoHolder
Direct Known Subclasses:
ArrayInfo, ObjectInfo

public abstract class AbstractObjectInfo
extends java.lang.Object
implements IObjectInfo, IClassInfoHolder

Representation of an object reference, including its class and ID.

Author:
mpersson

Field Summary
protected  ClassInfo classInfo
          The ClassInfo for this object, never null.
protected  int objectID
          The object ID for this object.
 
Fields inherited from interface com.jrockit.memleak.IObjectInfo
EMPTY_ARRAY
 
Constructor Summary
AbstractObjectInfo(int objectID, ClassInfo classInfo)
           
 
Method Summary
 boolean equals(AbstractObjectInfo other)
           
 boolean equals(java.lang.Object other)
           
 ClassInfo getClassInfo()
           
<T> T
getField(java.lang.String fieldName, java.lang.Class<T> type, Policy policy)
          Get the actual primitive wrapper or object representation of of the most visible field that has the name fieldName and is assignable to the class type as per IValue.isAssignableTo(Class) in the object represented by this IObjectInfo.
 IObjectInfo getFieldReference(java.lang.String fieldName, Policy policy)
          Get the IObjectInfo corresponding to the value of the most visible non-primitive field with the name fieldName in the object represented by this IObjectInfo.
 IFieldValue getFieldValue(java.lang.String fieldName, java.lang.Class<?> type, Policy policy)
          Get the IFieldValue of the most visible field that has the name fieldName and is assignable to the class type as per IValue.isAssignableTo(Class) in the object represented by this IObjectInfo.
 LimitedNumber getKeepAliveSize(long stopAt, Policy policy)
          Get the total size of all objects held on to by this object (the transitive closure).
 int getObjectId()
           
 int hashCode()
           
 boolean isDiscarded()
           
 boolean isValid()
          Is this a valid reference to an actual object?
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jrockit.memleak.IObjectInfo
getFieldValues
 

Field Detail

objectID

protected final int objectID
The object ID for this object.


classInfo

protected final ClassInfo classInfo
The ClassInfo for this object, never null.

Constructor Detail

AbstractObjectInfo

public AbstractObjectInfo(int objectID,
                          ClassInfo classInfo)
Parameters:
objectID -
classInfo -
Method Detail

getObjectId

public int getObjectId()
Specified by:
getObjectId in interface IObjectSpecifier
Returns:
the ID of this object.

getClassInfo

public ClassInfo getClassInfo()
Specified by:
getClassInfo in interface IObjectInfo
Specified by:
getClassInfo in interface IClassInfoHolder
Returns:
the IClassInfo for the class of this object.

isDiscarded

public boolean isDiscarded()
Specified by:
isDiscarded in interface IObjectInfo
Returns:
true iff the object is known to have been garbage collected.

isValid

public boolean isValid()
Is this a valid reference to an actual object? Only valid references might be queried for information that isn't cached. Actual object liveness doesn't directly affect the validity of a reference. However, if an object is known to have been discarded, references to it can be invalidated without further loss of information.

Note that invalid references are only equals(Object) to themselves.

Returns:
true iff this reference is still valid.

getFieldValue

public IFieldValue getFieldValue(java.lang.String fieldName,
                                 java.lang.Class<?> type,
                                 Policy policy)
                          throws GarbageCollectedException,
                                 NoMatchingFieldException
Description copied from interface: IObjectInfo
Get the IFieldValue of the most visible field that has the name fieldName and is assignable to the class type as per IValue.isAssignableTo(Class) in the object represented by this IObjectInfo.

The most visible field is defined from a Java source perspective in that it normally would be the field that is in scope from within the actual class. More specifically, starting from the actual class and moving up the super class hierarchy, the first non-synthetic field with fieldName and a matching type, is returned. If no such field is found, the first synthetic field of that name and with a matching type, found by looking in the same order, is returned. If no field with that name and a matching type could be found at all, NoMatchingFieldException is thrown.

Specified by:
getFieldValue in interface IObjectInfo
Parameters:
fieldName - the name of the field
policy - the cache policy to use
Returns:
a IFieldValue, unless the value is currently unavailable according to policy, in which case null is returned.
Throws:
GarbageCollectedException - if the object has been garbage collected.
NoMatchingFieldException - if no field with the given name and a matching type could be found

getField

public <T> T getField(java.lang.String fieldName,
                      java.lang.Class<T> type,
                      Policy policy)
           throws GarbageCollectedException,
                  NoMatchingFieldException
Description copied from interface: IObjectInfo
Get the actual primitive wrapper or object representation of of the most visible field that has the name fieldName and is assignable to the class type as per IValue.isAssignableTo(Class) in the object represented by this IObjectInfo.

The most visible field is defined from a Java source perspective in that it normally would be the field that is in scope from within the actual class. More specifically, starting from the actual class and moving up the super class hierarchy, the value of the first non-synthetic field with fieldName and a matching type, is returned. If no such field is found, the value of the first synthetic field of that name and with a matching type, found by looking in the same order, is returned. If no field with that name and a matching type could be found at all, NoMatchingFieldException is thrown.

Specified by:
getField in interface IObjectInfo
Type Parameters:
T - implicit
Parameters:
fieldName - the name of the field
policy - the cache policy to use
Returns:
an instance of T (that is, a primitive wrapper or an IObjectInfo), or null
Throws:
GarbageCollectedException - if the object has been garbage collected.
NoMatchingFieldException - if no field with the given name and a matching type could be found

getFieldReference

public IObjectInfo getFieldReference(java.lang.String fieldName,
                                     Policy policy)
                              throws GarbageCollectedException,
                                     NoMatchingFieldException
Description copied from interface: IObjectInfo
Get the IObjectInfo corresponding to the value of the most visible non-primitive field with the name fieldName in the object represented by this IObjectInfo.

The most visible field is defined from a Java source perspective in that it normally would be the field that is in scope from within the actual class. More specifically, starting from the actual class and moving up the super class hierarchy, the first non-synthetic and non-primitive field with fieldName is returned. If no such field is found, the first synthetic non-primitive field of that name, found by looking in the same order, is returned. If no non-primitive field with that name could be found at all, NoMatchingFieldException is thrown.

Specified by:
getFieldReference in interface IObjectInfo
Parameters:
fieldName - the name of the field
policy - the cache policy to use
Returns:
an IObjectInfo representing the field, or null according to policy
Throws:
GarbageCollectedException - if the object has been garbage collected.
NoMatchingFieldException - if no non-primitive field with the given name could be found

getKeepAliveSize

public LimitedNumber getKeepAliveSize(long stopAt,
                                      Policy policy)
Description copied from interface: IObjectInfo
Get the total size of all objects held on to by this object (the transitive closure). If stopAt >= 0 than counting will stop if the total size is larger than stopAt.

Note that a cached value below stopAt will only be returned if it is lower than the limit in effect when that value was originally calculated. (That is, if it wasn't limited by the lower limit.)

Specified by:
getKeepAliveSize in interface IObjectInfo
Parameters:
stopAt - the limit in bytes for keep alive size calculation, see above
policy - the Policy to use
Returns:
the total size in bytes of all objects held on to by this object, or null according to policy

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

equals

public boolean equals(AbstractObjectInfo other)
Parameters:
other - an AbstractObjectInfo
Returns:
true if other represent the same object in the VM.
See Also:
Object.equals(Object)


Copyright © 1999, 2011, Oracle and/or its affiliates. All rights reserved.