Package org.eclipse.mat.parser.model
Class ClassImpl
- java.lang.Object
-
- org.eclipse.mat.parser.model.AbstractObjectImpl
-
- org.eclipse.mat.parser.model.ClassImpl
-
- All Implemented Interfaces:
Serializable,Comparable<ClassImpl>,IClass,IObject
public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<ClassImpl>
Implementation of a Java object representing a java.lang.Class object. As well as some standard object information it contains information about the class and summary details about instances of this class.- See Also:
- Serialized Form
- No Extend:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.mat.snapshot.model.IObject
IObject.Type
-
-
Field Summary
Fields Modifier and Type Field Description static StringJAVA_LANG_CLASS-
Fields inherited from interface org.eclipse.mat.snapshot.model.IClass
JAVA_LANG_CLASSLOADER
-
-
Constructor Summary
Constructors Constructor Description ClassImpl(long address, String name, long superAddress, long loaderAddress, Field[] staticFields, FieldDescriptor[] fields)Construct a class object based on name, address and fields.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInstance(long usedHeapSize)voidaddSubClass(ClassImpl clazz)intcompareTo(ClassImpl other)booleandoesExtend(String className)Does this class extend a class of the supplied name? With multiple class loaders the supplied name might not be the class you were intending to find.List<IClass>getAllSubclasses()Returns all sub-classes including sub-classes of its sub-classes.SerializablegetCacheEntry()Gets the key for extra information about this class.longgetClassLoaderAddress()Returns the address of the class loader which loaded this class.intgetClassLoaderId()Returns the id of the class loader which loaded this class.List<FieldDescriptor>getFieldDescriptors()Returns field descriptors for all member variables of instances of this class.longgetHeapSizePerInstance()Returns the heap size of one instance of this class.StringgetName()Returns the fully qualified class name of this class.intgetNumberOfObjects()Returns the number of instances of this class present in the heap dump.int[]getObjectIds()Ids of all instances of this class (an empty array if there are no instances of the class)List<NamedReference>getOutboundReferences()Get list of snapshot objects referenced from this snapshot object with the name of the field over which it was referenced.ArrayLonggetReferences()Gets the outbound references from this object, as addresses.longgetRetainedHeapSizeOfObjects(boolean calculateIfNotAvailable, boolean approximation, IProgressListener listener)Returns the retained size of all objects of this instance including the class instance.List<Field>getStaticFields()Returns the static fields and it values.List<IClass>getSubclasses()Returns the direct sub-classes.ClassImplgetSuperClass()Returns the super class.longgetSuperClassAddress()intgetSuperClassId()Returns the id of the super class.StringgetTechnicalName()Get technical name of this object which is something like class@address.longgetTotalSize()longgetUsedHeapSize()Get used heap size of just this object.booleanhasSuperClass()Returns true if the class has a super class.booleanisArrayType()Returns true if the class is an array class.voidremoveInstance(long heapSizePerInstance)voidremoveSubClass(ClassImpl clazz)voidsetCacheEntry(Serializable cacheEntry)Sets the key for extra information about this class.voidsetClassLoaderAddress(long address)voidsetClassLoaderIndex(int classLoaderIndex)Sets the class loader index.voidsetHeapSizePerInstance(long size)voidsetName(String name)voidsetSnapshot(ISnapshot dump)Set the snapshot for an object.voidsetSuperClassIndex(int superClassIndex)Sets the superclass index.voidsetUsedHeapSize(long usedHeapSize)-
Methods inherited from class org.eclipse.mat.parser.model.AbstractObjectImpl
equals, getClassAddress, getClassId, getClassSpecificName, getClazz, getComparatorForClassSpecificName, getComparatorForTechnicalName, getComparatorForUsedHeapSize, getDisplayName, getGCRootInfo, getObjectAddress, getObjectId, getRetainedHeapSize, getSnapshot, hashCode, resolveValue, setClassInstance, setObjectAddress, setObjectId, toString
-
Methods inherited from interface org.eclipse.mat.snapshot.model.IObject
getClassSpecificName, getClazz, getDisplayName, getGCRootInfo, getObjectAddress, getObjectId, getRetainedHeapSize, getSnapshot, resolveValue
-
-
-
-
Field Detail
-
JAVA_LANG_CLASS
public static final String JAVA_LANG_CLASS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ClassImpl
public ClassImpl(long address, String name, long superAddress, long loaderAddress, Field[] staticFields, FieldDescriptor[] fields)Construct a class object based on name, address and fields.- Parameters:
address- the address of the class objectname- the class name, using '.' as package separatorsuperAddress- the address of the superclass, or 0 if none.loaderAddress- the address of the class loaderstaticFields- all the static fields, with valuesfields- all the instance fields as descriptors
-
-
Method Detail
-
getCacheEntry
public Serializable getCacheEntry()
Gets the key for extra information about this class.- Returns:
- the key
-
setCacheEntry
public void setCacheEntry(Serializable cacheEntry)
Sets the key for extra information about this class.- Parameters:
cacheEntry- the key
-
setSuperClassIndex
public void setSuperClassIndex(int superClassIndex)
Sets the superclass index. May need to be changed after reindexing of a snapshot.- Parameters:
superClassIndex- the new index
-
setClassLoaderIndex
public void setClassLoaderIndex(int classLoaderIndex)
Sets the class loader index. May need to be changed after reindexing of a snapshot.- Parameters:
classLoaderIndex- the new index
-
getObjectIds
public int[] getObjectIds() throws UnsupportedOperationException, SnapshotExceptionDescription copied from interface:IClassIds of all instances of this class (an empty array if there are no instances of the class)- Specified by:
getObjectIdsin interfaceIClass- Throws:
UnsupportedOperationExceptionSnapshotException
-
getRetainedHeapSizeOfObjects
public long getRetainedHeapSizeOfObjects(boolean calculateIfNotAvailable, boolean approximation, IProgressListener listener) throws SnapshotExceptionDescription copied from interface:IClassReturns the retained size of all objects of this instance including the class instance.- Specified by:
getRetainedHeapSizeOfObjectsin interfaceIClass- Throws:
SnapshotException
-
getUsedHeapSize
public long getUsedHeapSize()
Description copied from interface:IObjectGet used heap size of just this object.- Specified by:
getUsedHeapSizein interfaceIObject- Specified by:
getUsedHeapSizein classAbstractObjectImpl- Returns:
- used heap size of this object
-
getReferences
public ArrayLong getReferences()
Description copied from class:AbstractObjectImplGets the outbound references from this object, as addresses.- Specified by:
getReferencesin classAbstractObjectImpl- Returns:
- a list of outbound references
-
getOutboundReferences
public List<NamedReference> getOutboundReferences()
Description copied from interface:IObjectGet list of snapshot objects referenced from this snapshot object with the name of the field over which it was referenced.- Specified by:
getOutboundReferencesin interfaceIObject- Returns:
- list of snapshot objects referenced from this snapshot object with the name of the field over which it was referenced
-
getClassLoaderAddress
public long getClassLoaderAddress()
Description copied from interface:IClassReturns the address of the class loader which loaded this class.- Specified by:
getClassLoaderAddressin interfaceIClass
-
setClassLoaderAddress
public void setClassLoaderAddress(long address)
-
getFieldDescriptors
public List<FieldDescriptor> getFieldDescriptors()
Description copied from interface:IClassReturns field descriptors for all member variables of instances of this class. If the snapshot data format does not contain field data then this will be an empty list.- Specified by:
getFieldDescriptorsin interfaceIClass
-
getNumberOfObjects
public int getNumberOfObjects()
Description copied from interface:IClassReturns the number of instances of this class present in the heap dump.- Specified by:
getNumberOfObjectsin interfaceIClass
-
getHeapSizePerInstance
public long getHeapSizePerInstance()
Description copied from interface:IClassReturns the heap size of one instance of this class. Not valid if this class represents an array.- Specified by:
getHeapSizePerInstancein interfaceIClass- Since:
- 1.0
-
setHeapSizePerInstance
public void setHeapSizePerInstance(long size)
- Since:
- 1.0
-
getName
public String getName()
Description copied from interface:IClassReturns the fully qualified class name of this class. The package components are separated by dots '.'. Inner classes use $ to separate the parts.
-
setName
public void setName(String name)
-
getStaticFields
public List<Field> getStaticFields()
Description copied from interface:IClassReturns the static fields and it values. If the snapshot data format does not contain field data then this will be an empty list.- Specified by:
getStaticFieldsin interfaceIClass
-
getSuperClassAddress
public long getSuperClassAddress()
-
getSuperClassId
public int getSuperClassId()
Description copied from interface:IClassReturns the id of the super class. -1 if it has no super class, i.e. if it is java.lang.Object.- Specified by:
getSuperClassIdin interfaceIClass
-
getSuperClass
public ClassImpl getSuperClass()
Description copied from interface:IClassReturns the super class.- Specified by:
getSuperClassin interfaceIClass
-
getTotalSize
public long getTotalSize()
-
hasSuperClass
public boolean hasSuperClass()
Description copied from interface:IClassReturns true if the class has a super class.- Specified by:
hasSuperClassin interfaceIClass
-
compareTo
public int compareTo(ClassImpl other)
- Specified by:
compareToin interfaceComparable<ClassImpl>
-
addInstance
public void addInstance(long usedHeapSize)
- Since:
- 1.0
-
removeInstance
public void removeInstance(long heapSizePerInstance)
- Since:
- 1.0
-
getSubclasses
public List<IClass> getSubclasses()
Description copied from interface:IClassReturns the direct sub-classes.- Specified by:
getSubclassesin interfaceIClass
-
getAllSubclasses
public List<IClass> getAllSubclasses()
Description copied from interface:IClassReturns all sub-classes including sub-classes of its sub-classes.- Specified by:
getAllSubclassesin interfaceIClass
-
isArrayType
public boolean isArrayType()
Description copied from interface:IClassReturns true if the class is an array class.- Specified by:
isArrayTypein interfaceIClass
-
getTechnicalName
public String getTechnicalName()
Description copied from interface:IObjectGet technical name of this object which is something like class@address.- Specified by:
getTechnicalNamein interfaceIObject- Overrides:
getTechnicalNamein classAbstractObjectImpl- Returns:
- technical name of this object which is something like class@address
-
getClassLoaderId
public int getClassLoaderId()
Description copied from interface:IClassReturns the id of the class loader which loaded this class.- Specified by:
getClassLoaderIdin interfaceIClass
-
addSubClass
public void addSubClass(ClassImpl clazz)
-
removeSubClass
public void removeSubClass(ClassImpl clazz)
-
setUsedHeapSize
public void setUsedHeapSize(long usedHeapSize)
- Since:
- 1.0
-
doesExtend
public boolean doesExtend(String className) throws SnapshotException
Description copied from interface:IClassDoes this class extend a class of the supplied name? With multiple class loaders the supplied name might not be the class you were intending to find.- Specified by:
doesExtendin interfaceIClass- Returns:
- true if it does extend
- Throws:
SnapshotException
-
setSnapshot
public void setSnapshot(ISnapshot dump)
Description copied from class:AbstractObjectImplSet the snapshot for an object. Used once the entire snapshot has been built, or an object has been deserialized.- Overrides:
setSnapshotin classAbstractObjectImpl- Parameters:
dump- the actual current snapshot
-
-