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
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:
- No Extend:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.mat.snapshot.model.IObject
IObject.Type
-
Field Summary
Fields inherited from interface org.eclipse.mat.snapshot.model.IClass
JAVA_LANG_CLASSLOADER
-
Constructor Summary
ConstructorDescriptionClassImpl
(long address, String name, long superAddress, long loaderAddress, Field[] staticFields, FieldDescriptor[] fields) Construct a class object based on name, address and fields. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInstance
(long usedHeapSize) Note another instance to this class.void
addSubClass
(ClassImpl clazz) Add a subclass of this class.int
boolean
doesExtend
(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.Returns all sub-classes including sub-classes of its sub-classes.Gets the key for extra information about this class.long
Returns the address of the class loader which loaded this class.int
Returns the id of the class loader which loaded this class.Returns field descriptors for all member variables of instances of this class.long
Returns the heap size of one instance of this class.getName()
Returns the fully qualified class name of this class.int
Returns the number of instances of this class present in the heap dump.int[]
Ids of all instances of this class (an empty array if there are no instances of the class)Get list of snapshot objects referenced from this snapshot object with the name of the field over which it was referenced.Gets the outbound references from this object, as addresses.long
getRetainedHeapSizeOfObjects
(boolean calculateIfNotAvailable, boolean approximation, IProgressListener listener) Returns the retained size of all objects of this instance including the class instance.Returns the static fields and it values.Returns the direct sub-classes.Returns the super class.long
Gets the address of the superclass.int
Returns the id of the super class.Get technical name of this object which is something like class@address.long
The size of all the instances of this class.long
Get used heap size of just this object.boolean
Does the class have a super class?boolean
Test if this class an array type.void
removeInstance
(long heapSizePerInstance) Remove an instance of this class.void
removeSubClass
(ClassImpl clazz) Remove a subclass of this class.void
setCacheEntry
(Serializable cacheEntry) Sets the key for extra information about this class.void
setClassLoaderAddress
(long address) Sets the class loader for this class.void
setClassLoaderIndex
(int classLoaderIndex) Sets the class loader index.void
setHeapSizePerInstance
(long size) Sets the size per instance for the classvoid
Sets the class name.void
setSnapshot
(ISnapshot dump) Set the snapshot for an object.void
setSuperClassIndex
(int superClassIndex) Sets the superclass index.void
setUsedHeapSize
(long usedHeapSize) Sets the used heap size for this particular class.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 Details
-
JAVA_LANG_CLASS
Shortcut for java.lang.Class- See Also:
-
-
Constructor Details
-
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 Details
-
getCacheEntry
Gets the key for extra information about this class.- Returns:
- the key
-
setCacheEntry
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
Description copied from interface:IClass
Ids of all instances of this class (an empty array if there are no instances of the class)- Specified by:
getObjectIds
in interfaceIClass
- Returns:
- an array of all the object IDs of instances of this class
- Throws:
SnapshotException
- if there is a problem retrieving the dataUnsupportedOperationException
-
getRetainedHeapSizeOfObjects
public long getRetainedHeapSizeOfObjects(boolean calculateIfNotAvailable, boolean approximation, IProgressListener listener) throws SnapshotException Description copied from interface:IClass
Returns the retained size of all objects of this instance including the class instance.- Specified by:
getRetainedHeapSizeOfObjects
in interfaceIClass
- Parameters:
calculateIfNotAvailable
- whether to calculateapproximation
- whether an approximate calculation is sufficientlistener
- for reporting progress or for the user to cancel the calculation- Returns:
- the total retained size in bytes, negative if an approximation
- Throws:
SnapshotException
- if there is a problem
-
getUsedHeapSize
public long getUsedHeapSize()Description copied from interface:IObject
Get used heap size of just this object.- Specified by:
getUsedHeapSize
in interfaceIObject
- Specified by:
getUsedHeapSize
in classAbstractObjectImpl
- Returns:
- used heap size of this object
-
getReferences
Description copied from class:AbstractObjectImpl
Gets the outbound references from this object, as addresses.- Specified by:
getReferences
in classAbstractObjectImpl
- Returns:
- a list of outbound references
-
getOutboundReferences
Description copied from interface:IObject
Get list of snapshot objects referenced from this snapshot object with the name of the field over which it was referenced.- Specified by:
getOutboundReferences
in 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:IClass
Returns the address of the class loader which loaded this class.- Specified by:
getClassLoaderAddress
in interfaceIClass
- Returns:
- the address of the class loader
-
setClassLoaderAddress
public void setClassLoaderAddress(long address) Sets the class loader for this class.- Parameters:
address
- the address of the loader
-
getFieldDescriptors
Description copied from interface:IClass
Returns 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:
getFieldDescriptors
in interfaceIClass
- Returns:
- the field descriptors for this class
-
getNumberOfObjects
public int getNumberOfObjects()Description copied from interface:IClass
Returns the number of instances of this class present in the heap dump.- Specified by:
getNumberOfObjects
in interfaceIClass
- Returns:
- the number of instances
-
getHeapSizePerInstance
public long getHeapSizePerInstance()Description copied from interface:IClass
Returns the heap size of one instance of this class. Not valid if this class represents an array.- Specified by:
getHeapSizePerInstance
in interfaceIClass
- Returns:
- the size of an instance of this class in bytes
- Since:
- 1.0
-
setHeapSizePerInstance
public void setHeapSizePerInstance(long size) Sets the size per instance for the class- Parameters:
size
- the size in bytes- Since:
- 1.0
-
getName
Description copied from interface:IClass
Returns the fully qualified class name of this class. The package components are separated by dots '.'. Inner classes use $ to separate the parts. -
setName
Sets the class name.- Parameters:
name
- the class name
-
getStaticFields
Description copied from interface:IClass
Returns 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:
getStaticFields
in interfaceIClass
- Returns:
- the static fields of this class
-
getSuperClassAddress
public long getSuperClassAddress()Gets the address of the superclass.- Returns:
- the superclass address
-
getSuperClassId
public int getSuperClassId()Description copied from interface:IClass
Returns the id of the super class. -1 if it has no super class, i.e. if it is java.lang.Object.- Specified by:
getSuperClassId
in interfaceIClass
- Returns:
- the super class ID
-
getSuperClass
Description copied from interface:IClass
Returns the super class.- Specified by:
getSuperClass
in interfaceIClass
- Returns:
- the super class
-
getTotalSize
public long getTotalSize()The size of all the instances of this class.- Returns:
- the size in bytes
-
hasSuperClass
public boolean hasSuperClass()Description copied from interface:IClass
Does the class have a super class?- Specified by:
hasSuperClass
in interfaceIClass
- Returns:
- true if the class has a super class.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ClassImpl>
-
addInstance
public void addInstance(long usedHeapSize) Note another instance to this class.- Parameters:
usedHeapSize
- the size in bytes of this instance- Since:
- 1.0
-
removeInstance
public void removeInstance(long heapSizePerInstance) Remove an instance of this class. Reverses the effect ofaddInstance(long)
- Parameters:
heapSizePerInstance
- the size in bytes of this instance- Since:
- 1.0
-
getSubclasses
Description copied from interface:IClass
Returns the direct sub-classes.- Specified by:
getSubclasses
in interfaceIClass
- Returns:
- a list of the immediate subclasses
-
getAllSubclasses
Description copied from interface:IClass
Returns all sub-classes including sub-classes of its sub-classes.- Specified by:
getAllSubclasses
in interfaceIClass
- Returns:
- a list of all the subclasses
-
isArrayType
public boolean isArrayType()Description copied from interface:IClass
Test if this class an array type.- Specified by:
isArrayType
in interfaceIClass
- Returns:
- true if the class is an array class.
-
getTechnicalName
Description copied from interface:IObject
Get technical name of this object which is something like class@address.- Specified by:
getTechnicalName
in interfaceIObject
- Overrides:
getTechnicalName
in classAbstractObjectImpl
- Returns:
- technical name of this object which is something like class@address
-
getClassLoaderId
public int getClassLoaderId()Description copied from interface:IClass
Returns the id of the class loader which loaded this class.- Specified by:
getClassLoaderId
in interfaceIClass
- Returns:
- the object ID of the class loader
-
addSubClass
Add a subclass of this class.- Parameters:
clazz
- the subclass
-
removeSubClass
Remove a subclass of this class. Reverses the effect ofaddSubClass(ClassImpl)
- Parameters:
clazz
- the subclass
-
setUsedHeapSize
public void setUsedHeapSize(long usedHeapSize) Sets the used heap size for this particular class. Does not include instances.- Parameters:
usedHeapSize
- the size in bytes- Since:
- 1.0
-
doesExtend
Description copied from interface:IClass
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.- Specified by:
doesExtend
in interfaceIClass
- Parameters:
className
- the candidate class name- Returns:
- true if it does extend
- Throws:
SnapshotException
- if there is a problem retrieving the information
-
setSnapshot
Description copied from class:AbstractObjectImpl
Set the snapshot for an object. Used once the entire snapshot has been built, or an object has been deserialized.- Overrides:
setSnapshot
in classAbstractObjectImpl
- Parameters:
dump
- the actual current snapshot
-