Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Johnson2022-11-09 13:30:38 +0000
committerAndrew Johnson2022-11-09 13:41:40 +0000
commit7cd65a495493e38f80001dcd766db2eb21fa24d4 (patch)
tree826135675ff0267b9b36fc86a0a0d816dc6534cb
parentf9284c694319586038bbe92ad66caa037bc3db00 (diff)
downloadorg.eclipse.mat-7cd65a495493e38f80001dcd766db2eb21fa24d4.tar.gz
org.eclipse.mat-7cd65a495493e38f80001dcd766db2eb21fa24d4.tar.xz
org.eclipse.mat-7cd65a495493e38f80001dcd766db2eb21fa24d4.zip
Bug 327129 Make it easier to write extensions
Update some javadoc and add some error checking for object IDs Change-Id: I89b70d85b1be958816b6ca650ef507c912fd8469
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/ISnapshot.java32
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/SnapshotInfo.java8
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/extension/IClassSpecificNameResolver.java4
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/extension/IThreadDetailsResolver.java6
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IArray.java3
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IClass.java32
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IClassLoader.java4
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IInstance.java5
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IObject.java14
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IObjectArray.java7
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IPrimitiveArray.java8
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/ObjectComparators.java34
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/ObjectReference.java6
-rw-r--r--plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/PrettyPrinter.java6
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/IIndexBuilder.java20
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/SnapshotImpl.java225
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/AbstractArrayImpl.java7
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/AbstractObjectImpl.java17
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ClassImpl.java63
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ClassLoaderImpl.java8
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/InstanceImpl.java4
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ObjectArrayImpl.java6
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/PrimitiveArrayImpl.java7
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XClassHistogramRecord.java4
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XGCRootInfo.java7
-rw-r--r--plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XSnapshotInfo.java42
-rw-r--r--plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/OQLTest.java174
-rw-r--r--plugins/org.eclipse.mat.ui.help/javadoc/dtfj/package-list1
28 files changed, 641 insertions, 113 deletions
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/ISnapshot.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/ISnapshot.java
index 65616dda..7bcf2b1d 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/ISnapshot.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/ISnapshot.java
@@ -347,7 +347,7 @@ public interface ISnapshot
* progress listener informing about the current state of
* execution
* @return retained set of objects for the given objects
- * @throws SnapshotException
+ * @throws SnapshotException if there was a problem, such as on cancellation
*/
public int[] getRetainedSet(int[] objectIds, String[] fieldNames, IProgressListener progressMonitor)
throws SnapshotException;
@@ -372,7 +372,7 @@ public interface ISnapshot
* progress listener informing about the current state of
* execution
* @return retained set of objects for the given objects
- * @throws SnapshotException
+ * @throws SnapshotException if there was a problem, such as on cancellation
*/
public int[] getRetainedSet(int[] objectIds, ExcludedReferencesDescriptor[] excludedReferences,
IProgressListener progressMonitor) throws SnapshotException;
@@ -402,7 +402,7 @@ public interface ISnapshot
* progress listener informing about the current state of
* execution
* @return the minimum retained set of objects for the given objects
- * @throws SnapshotException
+ * @throws SnapshotException if there was a problem, such as on cancellation
*/
public int[] getMinRetainedSet(int[] objectIds, IProgressListener progressListener) throws SnapshotException;
@@ -417,7 +417,7 @@ public interface ISnapshot
* progress listener informing about the current state of
* execution
* @return the minimum retained set of objects for the given objects
- * @throws SnapshotException
+ * @throws SnapshotException if there was a problem, such as on cancellation
*/
public long getMinRetainedSize(int[] objectIds, IProgressListener listener) throws SnapshotException;
@@ -431,7 +431,7 @@ public interface ISnapshot
* object for which the directly dominated objects should be
* returned
* @return objects the given object directly dominates
- * @throws SnapshotException
+ * @throws SnapshotException if the dominator tree has not been calculated
*/
public int[] getImmediateDominatedIds(int objectId) throws SnapshotException;
@@ -447,7 +447,7 @@ public interface ISnapshot
* returned
* @return Object id of the dominator. -1 if the object is dominated by the
* root of the dominator tree.
- * @throws SnapshotException
+ * @throws SnapshotException if the dominator tree has not been calculated
*/
public int getImmediateDominatorId(int objectId) throws SnapshotException;
@@ -472,7 +472,7 @@ public interface ISnapshot
* execution
* @return DominatorsSummary the returned DominatorSummary contains the
* summary of the dominators grouped by classes or class loaders
- * @throws SnapshotException
+ * @throws SnapshotException if the dominator tree has not been calculated
*/
public DominatorsSummary getDominatorsOf(int[] objectIds, Pattern excludePattern, IProgressListener progressListener)
throws SnapshotException;
@@ -493,7 +493,7 @@ public interface ISnapshot
* execution
* @return int[] the objects which not in a parent/child relation in the
* dominator tree
- * @throws SnapshotException
+ * @throws SnapshotException if the dominator tree has not been calculated
*/
public int[] getTopAncestorsInDominatorTree(int[] objectIds, IProgressListener listener) throws SnapshotException;
@@ -507,7 +507,7 @@ public interface ISnapshot
* id of object you want a convenient object abstraction for
* @return object abstracting the real Java Object from the heap dump
* identified by the given id
- * @throws SnapshotException
+ * @throws SnapshotException if there is a problem, such as perhaps an invalid objectId
*/
public IObject getObject(int objectId) throws SnapshotException;
@@ -523,7 +523,7 @@ public interface ISnapshot
* @param objectId
* id of object you want the GC root info for
* @return null if this object is no GC root or GCRootInfo[] if it is
- * @throws SnapshotException
+ * @throws SnapshotException on an unexpected problem
*/
public GCRootInfo[] getGCRootInfo(int objectId) throws SnapshotException;
@@ -537,7 +537,7 @@ public interface ISnapshot
* id of object you want the convenient class abstraction for
* @return object abstracting the real Java Class this object was an
* instance of in the heap dump identified by the given id
- * @throws SnapshotException
+ * @throws SnapshotException if there is an unexpected problem
*/
public IClass getClassOf(int objectId) throws SnapshotException;
@@ -553,7 +553,7 @@ public interface ISnapshot
* @param objectId
* id of object for which you want the heap size for
* @return heap size for the given object.
- * @throws SnapshotException
+ * @throws SnapshotException on an unexpected problem
* @since 1.0
*/
public long getHeapSize(int objectId) throws SnapshotException;
@@ -568,7 +568,7 @@ public interface ISnapshot
* @param objectIds
* ids of the objects for which you want the heap size for
* @return total heap size for the given object set
- * @throws SnapshotException
+ * @throws SnapshotException on an unexpected problem
*/
public long getHeapSize(int[] objectIds) throws SnapshotException;
@@ -586,7 +586,7 @@ public interface ISnapshot
* id of object for which you want the retained heap size for
* @return retained heap size for the given object or 0 if no dominator tree
* was calculated
- * @throws SnapshotException
+ * @throws SnapshotException on an unexpected problem
*/
public long getRetainedHeapSize(int objectId) throws SnapshotException;
@@ -683,6 +683,8 @@ public interface ISnapshot
* <p>
* For example, from the supplied snapshot implementation {@link org.eclipse.mat.parser.internal.SnapshotImpl}
* the extra information is obtained via {@link org.eclipse.mat.parser.IObjectReader#getAddon(Class)}.
+ * @param addon the type of the additional information required
+ * @param <A> the type of the result
* @return SnapshotAddons - extended information, e.g. perm info, OoM stack
* trace info, JVM arguments, etc.
* returns null if the information is not present
@@ -694,7 +696,7 @@ public interface ISnapshot
* Get a the stack trace information for a given thread object, if thread
* stack information is available in this snapshot.
* <p>
- *
+ * @param objectId the object ID of the thread
* @return IThreadStack - an object representing the call stack of the
* thread. Returns null if no info is available for the object, or
* no stack info is available at all
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/SnapshotInfo.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/SnapshotInfo.java
index 183972b6..1ff807ac 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/SnapshotInfo.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/SnapshotInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG.
+ * Copyright (c) 2008, 2022 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -46,6 +46,8 @@ public class SnapshotInfo implements Serializable
*
* @param path
* path from where the snapshot was acquired
+ * @param prefix
+ * the base of the path for all indexes
* @param jvmInfo
* version of the JVM from which it was acquired
* @param identifierSize
@@ -112,8 +114,8 @@ public class SnapshotInfo implements Serializable
/**
* Store extra information about the snapshot
- * @param name
- * @param value
+ * @param name the name/key for the property
+ * @param value the object to be associated with the name
* keep_unreachable_objects - mark as {@link Type}
* hprof.version
* org.eclipse.mat.snapshot.UnreachableObjectsHistogram
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/extension/IClassSpecificNameResolver.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/extension/IClassSpecificNameResolver.java
index 4e28f3ae..740a561e 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/extension/IClassSpecificNameResolver.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/extension/IClassSpecificNameResolver.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 SAP AG.
+ * Copyright (c) 2008, 2022 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -33,7 +33,7 @@ public interface IClassSpecificNameResolver
* @param object
* object for which the name should be resolved
* @return name for snapshot object
- * @throws SnapshotException
+ * @throws SnapshotException problem retrieving the name
*/
public String resolve(IObject object) throws SnapshotException;
}
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/extension/IThreadDetailsResolver.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/extension/IThreadDetailsResolver.java
index cf71f6e5..12ac4295 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/extension/IThreadDetailsResolver.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/extension/IThreadDetailsResolver.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -34,7 +34,7 @@ public interface IThreadDetailsResolver
* Extract basic information about a thread, for example for ThreadOverviewQuery.
* @param thread to extract the information from and to attach the information
* @param listener to log progress and report errors
- * @throws SnapshotException
+ * @throws SnapshotException problem retrieving or converting the data
*/
void complementShallow(IThreadInfo thread, IProgressListener listener) throws SnapshotException;
@@ -42,7 +42,7 @@ public interface IThreadDetailsResolver
* Extract detailed information about a thread, for example for ThreadInfoQuery.
* @param thread to extract the information from and to attach the information
* @param listener to log progress and report errors
- * @throws SnapshotException
+ * @throws SnapshotException problem retrieving or converting the data
*/
void complementDeep(IThreadInfo thread, IProgressListener listener) throws SnapshotException;
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IArray.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IArray.java
index ebd8c20e..b272cac7 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IArray.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IArray.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -21,6 +21,7 @@ public interface IArray extends IObject
{
/**
* Returns the length of the array in elements.
+ * @return the length
*/
public int getLength();
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IClass.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IClass.java
index 33a913dc..2415f4d2 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IClass.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IClass.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG and IBM Corporation.
+ * Copyright (c) 2008, 2022 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -25,33 +25,41 @@ import org.eclipse.mat.util.IProgressListener;
*/
public interface IClass extends IObject
{
+ /** Name of java.lang.Class */
String JAVA_LANG_CLASS = "java.lang.Class"; //$NON-NLS-1$
+ /** Name of java.lang.ClassLoader */
String JAVA_LANG_CLASSLOADER = "java.lang.ClassLoader"; //$NON-NLS-1$
/**
* Returns the fully qualified class name of this class.
* The package components are separated by dots '.'.
* Inner classes use $ to separate the parts.
+ * @return the name of the class
*/
public String getName();
/**
* Returns the number of instances of this class present in the heap dump.
+ * @return the number of instances
*/
public int getNumberOfObjects();
/**
* Ids of all instances of this class (an empty array if there are no instances of the class)
+ * @return an array of all the object IDs of instances of this class
+ * @throws SnapshotException if there is a problem retrieving the data
*/
public int[] getObjectIds() throws SnapshotException;
/**
* Returns the id of the class loader which loaded this class.
+ * @return the object ID of the class loader
*/
public int getClassLoaderId();
/**
* Returns the address of the class loader which loaded this class.
+ * @return the address of the class loader
*/
public long getClassLoaderAddress();
@@ -60,6 +68,7 @@ public interface IClass extends IObject
* class.
* If the snapshot data format does not contain field data then this will be an
* empty list.
+ * @return the field descriptors for this class
*/
public List<FieldDescriptor> getFieldDescriptors();
@@ -67,6 +76,7 @@ public interface IClass extends IObject
* Returns the static fields and it values.
* If the snapshot data format does not contain field data then this will be an
* empty list.
+ * @return the static fields of this class
*/
public List<Field> getStaticFields();
@@ -74,12 +84,18 @@ public interface IClass extends IObject
* Returns the heap size of one instance of this class. Not valid if this
* class represents an array.
* @since 1.0
+ * @return the size of an instance of this class in bytes
*/
public long getHeapSizePerInstance();
/**
* Returns the retained size of all objects of this instance including the
* class instance.
+ * @param calculateIfNotAvailable whether to calculate
+ * @param calculateMinRetainedSize whether an approximate calculation is sufficient
+ * @param listener for reporting progress or for the user to cancel the calculation
+ * @return the total retained size in bytes, negative if an approximation
+ * @throws SnapshotException if there is a problem
*/
public long getRetainedHeapSizeOfObjects(boolean calculateIfNotAvailable, boolean calculateMinRetainedSize,
IProgressListener listener) throws SnapshotException;
@@ -87,26 +103,31 @@ public interface IClass extends IObject
/**
* Returns the id of the super class. -1 if it has no super class, i.e. if
* it is java.lang.Object.
+ * @return the super class ID
*/
public int getSuperClassId();
/**
* Returns the super class.
+ * @return the super class
*/
public IClass getSuperClass();
/**
- * Returns true if the class has a super class.
+ * Does the class have a super class?
+ * @return true if the class has a super class.
*/
public boolean hasSuperClass();
/**
* Returns the direct sub-classes.
+ * @return a list of the immediate subclasses
*/
public List<IClass> getSubclasses();
/**
* Returns all sub-classes including sub-classes of its sub-classes.
+ * @return a list of all the subclasses
*/
public List<IClass> getAllSubclasses();
@@ -114,14 +135,15 @@ public interface IClass extends IObject
* 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.
- * @param className
+ * @param className the candidate class name
* @return true if it does extend
- * @throws SnapshotException
+ * @throws SnapshotException if there is a problem retrieving the information
*/
public boolean doesExtend(String className) throws SnapshotException;
/**
- * Returns true if the class is an array class.
+ * Test if this class an array type.
+ * @return true if the class is an array class.
*/
public boolean isArrayType();
}
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IClassLoader.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IClassLoader.java
index 3c87ad8d..85f659fe 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IClassLoader.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IClassLoader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -38,6 +38,8 @@ public interface IClassLoader extends IInstance
/**
* Returns the classes defined by this class loader instance.
+ * @return a list of classes defined by this class loader
+ * @throws SnapshotException if there is a problem retrieving the information
*/
List<IClass> getDefinedClasses() throws SnapshotException;
}
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IInstance.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IInstance.java
index da2e9d54..5481cb11 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IInstance.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IInstance.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 SAP AG.
+ * Copyright (c) 2008,2022 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -28,6 +28,7 @@ public interface IInstance extends IObject
* current class and then fields of the super class and its super classes
* are returned. This order is important to know, if a class declares a
* field by the same name as the class it inherits from.
+ * @return a list of the fields
*/
public List<Field> getFields();
@@ -36,6 +37,8 @@ public interface IInstance extends IObject
* <p>
* If declares a member variable by the same name as the parent class does,
* then the result of this method is undefined.
+ * @param name the name of the field
+ * @return the field
*/
public Field getField(String name);
}
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IObject.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IObject.java
index aa8de1af..69616a02 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IObject.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IObject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG and IBM Corporation.
+ * Copyright (c) 2008, 2022 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -33,15 +33,23 @@ public interface IObject extends Serializable
*/
public interface Type
{
+ /** An object array/field */
int OBJECT = 2;
-
+ /** A array of booleans or boolean field */
int BOOLEAN = 4;
+ /** A array of char or char field */
int CHAR = 5;
+ /** A array of float or float field */
int FLOAT = 6;
+ /** A array of double or double field */
int DOUBLE = 7;
+ /** A array of byte or byte field */
int BYTE = 8;
+ /** A array of short or short field */
int SHORT = 9;
+ /** A array of int or int field */
int INT = 10;
+ /** A array of long or long field */
int LONG = 11;
}
@@ -139,6 +147,7 @@ public interface IObject extends Serializable
* @param field
* the field name in dot notation
* @return the value of the field
+ * @throws SnapshotException when there is a problem retrieving the field
*/
public Object resolveValue(String field) throws SnapshotException;
@@ -150,6 +159,7 @@ public interface IObject extends Serializable
*
* @return {@link GCRootInfo} if the object is a garbage collection root or
* null otherwise
+ * @throws SnapshotException when there is a problem retrieving the information
*/
public GCRootInfo[] getGCRootInfo() throws SnapshotException;
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IObjectArray.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IObjectArray.java
index 969800e8..c773600a 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IObjectArray.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IObjectArray.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -22,12 +22,17 @@ public interface IObjectArray extends IArray
/**
* Get an array with the object addresses. 0 indicates <code>null</code>
* values in the array.
+ * @return the addresses of the objects held in the array, in index order
*/
long[] getReferenceArray();
/**
* Get an array with the object addresses, beginning at <code>offset</code>
* and <code>length</code> number of elements.
+ * @param offset where to start
+ * @param length how many entries to return
+ * @return the addresses of the objects held in the array, in index order
+ * from the index starting at offset, with length entries
*/
long[] getReferenceArray(int offset, int length);
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IPrimitiveArray.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IPrimitiveArray.java
index 5b529615..7a12767e 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IPrimitiveArray.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/IPrimitiveArray.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -54,11 +54,13 @@ public interface IPrimitiveArray extends IArray
/**
* Returns the {@link IObject.Type} of the primitive array.
+ * @return the type
*/
public int getType();
/**
* Returns the component type of the array.
+ * @return the Java class of the component type
*/
public Class<?> getComponentType();
@@ -92,6 +94,7 @@ public interface IPrimitiveArray extends IArray
* The return value must not be modified because it is cached by the heap
* dump adapter. This method does not return a copy of the array for
* performance reasons.
+ * @return the contents of the primitive array
*/
public Object getValueArray();
@@ -102,6 +105,9 @@ public interface IPrimitiveArray extends IArray
* The return value must not be modified because it is cached by the heap
* dump adapter. This method does not return a copy of the array for
* performance reasons.
+ * @param offset the starting index
+ * @param length the number of entries
+ * @return the contents of the primitive array starting at the index for length entries
*/
public Object getValueArray(int offset, int length);
}
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/ObjectComparators.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/ObjectComparators.java
index 563cc0b8..1a0887a1 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/ObjectComparators.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/ObjectComparators.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 SAP AG.
+ * Copyright (c) 2008, 2022 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -19,6 +19,10 @@ import java.util.Comparator;
*/
public class ObjectComparators
{
+ /**
+ * Compare by technical name ascending.
+ * @return the comparator
+ */
public static Comparator<IObject> getComparatorForTechnicalNameAscending()
{
return new Comparator<IObject>()
@@ -30,6 +34,10 @@ public class ObjectComparators
};
}
+ /**
+ * Compare by technical name descending.
+ * @return the comparator
+ */
public static Comparator<IObject> getComparatorForTechnicalNameDescending()
{
return new Comparator<IObject>()
@@ -41,6 +49,10 @@ public class ObjectComparators
};
}
+ /**
+ * Compare by class specific name ascending.
+ * @return the comparator
+ */
public static Comparator<IObject> getComparatorForClassSpecificNameAscending()
{
return new Comparator<IObject>()
@@ -60,6 +72,10 @@ public class ObjectComparators
};
}
+ /**
+ * Compare by class specific name descending.
+ * @return the comparator
+ */
public static Comparator<IObject> getComparatorForClassSpecificNameDescending()
{
return new Comparator<IObject>()
@@ -78,6 +94,10 @@ public class ObjectComparators
};
}
+ /**
+ * Compare by used heap size ascending.
+ * @return the comparator
+ */
public static Comparator<IObject> getComparatorForUsedHeapSizeAscending()
{
return new Comparator<IObject>()
@@ -93,6 +113,10 @@ public class ObjectComparators
};
}
+ /**
+ * Compare by user heap size descending.
+ * @return the comparator
+ */
public static Comparator<IObject> getComparatorForUsedHeapSizeDescending()
{
return new Comparator<IObject>()
@@ -108,6 +132,10 @@ public class ObjectComparators
};
}
+ /**
+ * Compare by retained heap size ascending.
+ * @return the comparator
+ */
public static Comparator<IObject> getComparatorForRetainedHeapSizeAscending()
{
return new Comparator<IObject>()
@@ -123,6 +151,10 @@ public class ObjectComparators
};
}
+ /**
+ * Compare by retained heap size descending.
+ * @return the comparator
+ */
public static Comparator<IObject> getComparatorForRetainedHeapSizeDescending()
{
return new Comparator<IObject>()
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/ObjectReference.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/ObjectReference.java
index 1c0368b0..fd306122 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/ObjectReference.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/ObjectReference.java
@@ -36,8 +36,8 @@ public class ObjectReference implements Serializable
/**
* Create a reference to an object based on its address but in a form
* where the object id can be found.
- * @param snapshot
- * @param address
+ * @param snapshot the snapshot
+ * @param address the address of the object
*/
public ObjectReference(ISnapshot snapshot, long address)
{
@@ -71,7 +71,7 @@ public class ObjectReference implements Serializable
* Can be used to find an unindexed object by its addresss
* if the snapshot parser supports that.
* @return the object detail
- * @throws SnapshotException
+ * @throws SnapshotException if there is a problem retrieving the object
*/
public IObject getObject() throws SnapshotException
{
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/PrettyPrinter.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/PrettyPrinter.java
index b6a0a3d6..0d1a4b41 100644
--- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/PrettyPrinter.java
+++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/model/PrettyPrinter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2020 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -27,7 +27,7 @@ public final class PrettyPrinter
* @param stringObject the String object in the dump
* @param limit maximum number of characters to return
* @return the value of the string from the dump, as a String
- * @throws SnapshotException
+ * @throws SnapshotException if there is a problem with the conversion
*/
public static String objectAsString(IObject stringObject, int limit) throws SnapshotException
{
@@ -113,7 +113,7 @@ public final class PrettyPrinter
/**
* Convert a <code>char[]</code> object into a String.
* Unprintable characters are returned as \\unnnn values
- * @param charArray
+ * @param charArray the character array
* @param offset where to start
* @param count how many characters to read
* @param limit the maximum number of characters to read
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/IIndexBuilder.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/IIndexBuilder.java
index b913be0a..d963aa50 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/IIndexBuilder.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/IIndexBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -24,29 +24,29 @@ import org.eclipse.mat.util.IProgressListener;
public interface IIndexBuilder
{
/**
- * initialize with file and prefix (needed for naming conventions)
+ * Initialize with file and prefix (needed for naming conventions).
* @param file the dump file
* @param prefix used to build index files
- * @throws SnapshotException
- * @throws IOException
+ * @throws SnapshotException for example, some problem with the dump file
+ * @throws IOException for example, problem reading the dump file
*/
void init(File file, String prefix) throws SnapshotException, IOException;
/**
- * pass1 and pass2 parsing
+ * Pass1 and pass2 parsing.
* @param index
* @param listener for progress and error reporting
- * @throws SnapshotException
- * @throws IOException
+ * @throws SnapshotException major problem parsing the dump
+ * @throws IOException for example, problem reading the dump file or wrong file type
*/
void fill(IPreliminaryIndex index, IProgressListener listener) throws SnapshotException, IOException;
/**
- * Memory Analyzer has discard unreachable objects, so the parser may need to known
- * the discarded objects
+ * Memory Analyzer has discarded unreachable objects, so the parser may need to know
+ * the discarded objects.
* @param purgedMapping mapping from old id to new id, -1 indicates object has been discarded
* @param listener for progress and error reporting
- * @throws IOException
+ * @throws IOException for example, problem writing a new index
*/
void clean(final int[] purgedMapping, IProgressListener listener) throws IOException;
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/SnapshotImpl.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/SnapshotImpl.java
index 06cb3b92..28d6b689 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/SnapshotImpl.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/SnapshotImpl.java
@@ -87,6 +87,9 @@ import org.eclipse.mat.util.IProgressListener.OperationCanceledException;
import org.eclipse.mat.util.MessageUtil;
import org.eclipse.mat.util.VoidProgressListener;
+/**
+ * The implementation of the {@link ISnapshot} representing the entire heap dump.
+ */
public final class SnapshotImpl implements ISnapshot
{
@@ -96,6 +99,15 @@ public final class SnapshotImpl implements ISnapshot
private static final String VERSION = "MAT_01";//$NON-NLS-1$
+ /**
+ * Read the snapshot from an already indexed dump.
+ * @param file the dump file
+ * @param prefix the prefix of the path to find the index files
+ * @param listener to report progress
+ * @return the {@link ISnapshot}
+ * @throws SnapshotException problem reading index files
+ * @throws IOException file I/O problem
+ */
@SuppressWarnings("unchecked")
public static SnapshotImpl readFromFile(File file, String prefix, IProgressListener listener)
throws SnapshotException, IOException
@@ -266,6 +278,21 @@ public final class SnapshotImpl implements ISnapshot
}
}
+ /**
+ * Create the snapshot after a fresh parse.
+ * @param snapshotInfo the basic data about the snapshot
+ * @param objectReaderUniqueIdentifier the type of the snapshot from the parser
+ * @param heapObjectReader how to read objects from the file
+ * @param classCache all the classes
+ * @param roots all the GC roots
+ * @param rootsPerThread the GC roots per thread
+ * @param arrayObjects which objects are arrays
+ * @param indexManager all the indexes
+ * @param listener to report progress
+ * @return the new {@link ISnapshot}
+ * @throws IOException a file I/O problem
+ * @throws SnapshotException another problem
+ */
public static SnapshotImpl create(XSnapshotInfo snapshotInfo, //
String objectReaderUniqueIdentifier, //
IObjectReader heapObjectReader, //
@@ -448,9 +475,9 @@ public final class SnapshotImpl implements ISnapshot
}
snapshotInfo.setUsedHeapSize(usedHeapSize);
- // numberOfObjects was previously calculated by summing getNumberOfObjects() for
- // each class. Sometimes there was a mismatch. See bug 294311
- snapshotInfo.setNumberOfObjects(indexManager.idx.size());
+ // numberOfObjects was previously calculated by summing getNumberOfObjects() for
+ // each class. Sometimes there was a mismatch. See bug 294311
+ snapshotInfo.setNumberOfObjects(indexManager.idx.size());
snapshotInfo.setNumberOfClassLoaders(loaderLabels.size());
snapshotInfo.setNumberOfGCRoots(roots.size());
snapshotInfo.setNumberOfClasses(classCache.size());
@@ -467,11 +494,13 @@ public final class SnapshotImpl implements ISnapshot
// interface implementation
// //////////////////////////////////////////////////////////////
+ @Override
public XSnapshotInfo getSnapshotInfo()
{
return snapshotInfo;
}
+ @Override
public int[] getGCRoots() throws SnapshotException
{
return roots.getAllKeys();
@@ -479,11 +508,13 @@ public final class SnapshotImpl implements ISnapshot
// GCRootInfo[roots.size()]));
}
+ @Override
public Collection<IClass> getClasses() throws SnapshotException
{
return Arrays.asList(classCache.getAllValues(new IClass[classCache.size()]));
}
+ @Override
public Collection<IClass> getClassesByName(String name, boolean includeSubClasses) throws SnapshotException
{
List<IClass> list = this.classCacheByName.get(name);
@@ -501,6 +532,7 @@ public final class SnapshotImpl implements ISnapshot
return answer;
}
+ @Override
public Collection<IClass> getClassesByName(Pattern namePattern, boolean includeSubClasses) throws SnapshotException
{
Set<IClass> result = new HashSet<IClass>();
@@ -520,6 +552,7 @@ public final class SnapshotImpl implements ISnapshot
return result;
}
+ @Override
public Histogram getHistogram(IProgressListener listener) throws SnapshotException
{
if (listener == null)
@@ -539,6 +572,7 @@ public final class SnapshotImpl implements ISnapshot
return histogramBuilder.toHistogram(this, true);
}
+ @Override
public Histogram getHistogram(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
{
if (progressMonitor == null)
@@ -573,16 +607,31 @@ public final class SnapshotImpl implements ISnapshot
return histogramBuilder.toHistogram(this, false);
}
+ @Override
public int[] getInboundRefererIds(int objectId) throws SnapshotException
{
+ // Add a useful error message
+ int nobjs = indexManager.inbound().size();
+ if (objectId >= nobjs || objectId < 0)
+ {
+ throw new SnapshotException(MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, objectId));
+ }
return indexManager.inbound().get(objectId);
}
+ @Override
public int[] getOutboundReferentIds(int objectId) throws SnapshotException
{
+ // Add a useful error message
+ int nobjs = indexManager.outbound().size();
+ if (objectId >= nobjs || objectId < 0)
+ {
+ throw new SnapshotException(MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, objectId));
+ }
return indexManager.outbound().get(objectId);
}
+ @Override
public int[] getInboundRefererIds(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
{
if (progressMonitor == null)
@@ -593,9 +642,16 @@ public final class SnapshotImpl implements ISnapshot
SetInt result = new SetInt();
progressMonitor.beginTask(Messages.SnapshotImpl_ReadingInboundReferrers, objectIds.length / 100);
+ // Add a useful error message
+ int nobjs = indexManager.inbound().size();
for (int ii = 0; ii < objectIds.length; ii++)
{
- int[] referees = inbound.get(objectIds[ii]);
+ int objectId = objectIds[ii];
+ if (objectId >= nobjs || objectId < 0)
+ {
+ throw new SnapshotException(MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, objectId));
+ }
+ int[] referees = inbound.get(objectId);
for (int refereeId : referees)
result.add(refereeId);
@@ -617,6 +673,7 @@ public final class SnapshotImpl implements ISnapshot
return endResult;
}
+ @Override
public int[] getOutboundReferentIds(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
{
if (progressMonitor == null)
@@ -627,9 +684,16 @@ public final class SnapshotImpl implements ISnapshot
SetInt result = new SetInt();
progressMonitor.beginTask(Messages.SnapshotImpl_ReadingOutboundReferrers, objectIds.length / 100);
+ // Add a useful error message
+ int nobjs = indexManager.outbound().size();
for (int ii = 0; ii < objectIds.length; ii++)
{
- int[] referees = outbound.get(objectIds[ii]);
+ int objectId = objectIds[ii];
+ if (objectId >= nobjs || objectId < 0)
+ {
+ throw new SnapshotException(MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, objectId));
+ }
+ int[] referees = outbound.get(objectId);
for (int refereeId : referees)
result.add(refereeId);
@@ -648,12 +712,14 @@ public final class SnapshotImpl implements ISnapshot
return endResult;
}
+ @Override
public IPathsFromGCRootsComputer getPathsFromGCRoots(int objectId, Map<IClass, Set<String>> excludeList)
throws SnapshotException
{
return new PathsFromGCRootsComputerImpl(objectId, excludeList);
}
+ @Override
public IMultiplePathsFromGCRootsComputer getMultiplePathsFromGCRoots(int[] objectIds,
Map<IClass, Set<String>> excludeList) throws SnapshotException
{
@@ -812,6 +878,7 @@ public final class SnapshotImpl implements ISnapshot
}
+ @Override
public int[] getRetainedSet(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
{
int availableProcessors = Runtime.getRuntime().availableProcessors();
@@ -825,6 +892,7 @@ public final class SnapshotImpl implements ISnapshot
}
}
+ @Override
public int[] getRetainedSet(int[] objectIds, String[] fieldNames, IProgressListener listener)
throws SnapshotException
{
@@ -859,6 +927,7 @@ public final class SnapshotImpl implements ISnapshot
return retained;
}
+ @Override
public int[] getRetainedSet(int[] objectIds, ExcludedReferencesDescriptor[] excludedReferences,
IProgressListener progressMonitor) throws SnapshotException
{
@@ -917,6 +986,7 @@ public final class SnapshotImpl implements ISnapshot
return retainedSet.toArray();
}
+ @Override
public long getMinRetainedSize(int[] objectIds, IProgressListener progressMonitor)
throws UnsupportedOperationException, SnapshotException
{
@@ -936,6 +1006,7 @@ public final class SnapshotImpl implements ISnapshot
return result;
}
+ @Override
public int[] getMinRetainedSet(int[] objectIds, IProgressListener progressMonitor)
throws UnsupportedOperationException, SnapshotException
{
@@ -1069,6 +1140,7 @@ public final class SnapshotImpl implements ISnapshot
}
+ @Override
public int[] getTopAncestorsInDominatorTree(int[] objectIds, IProgressListener listener) throws SnapshotException
{
// Used by the dominator_tree query to allow a missing dominator tree to be built
@@ -1306,6 +1378,12 @@ public final class SnapshotImpl implements ISnapshot
return dominatorTreeCalculated;
}
+ /**
+ * Calculates the dominator tree after a parse
+ * @param listener to report progress
+ * @throws SnapshotException if a problem occurred
+ * @throws OperationCanceledException if the calculation was cancelled by user via the listener
+ */
public void calculateDominatorTree(IProgressListener listener) throws SnapshotException,
IProgressListener.OperationCanceledException
{
@@ -1321,20 +1399,36 @@ public final class SnapshotImpl implements ISnapshot
}
}
+ @Override
public int[] getImmediateDominatedIds(int objectId) throws SnapshotException
{
if (!isDominatorTreeCalculated())
throw new SnapshotException(Messages.SnapshotImpl_Error_DomTreeNotAvailable);
+ // Add a useful error message
+ int nobjs = indexManager.dominated().size() - 1;
+ // -1 is the root node, so is allowed
+ if (objectId >= nobjs || objectId < -1)
+ {
+ throw new SnapshotException(MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, objectId));
+ }
return indexManager.dominated().get(objectId + 1);
}
+ @Override
public int getImmediateDominatorId(int objectId) throws SnapshotException
{
if (!isDominatorTreeCalculated())
throw new SnapshotException(Messages.SnapshotImpl_Error_DomTreeNotAvailable);
+ // Add a useful error message
+ int nobjs = indexManager.dominator().size();
+ if (objectId >= nobjs || objectId < 0)
+ {
+ throw new SnapshotException(MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, objectId));
+ }
return indexManager.dominator().get(objectId) - 2;
}
+ @Override
public DominatorsSummary getDominatorsOf(int[] objectIds, Pattern excludePattern, IProgressListener progressListener)
throws SnapshotException
{
@@ -1455,35 +1549,68 @@ public final class SnapshotImpl implements ISnapshot
return new DominatorsSummary(records, this);
}
+ @Override
public IObject getObject(int objectId) throws SnapshotException
{
IObject answer = this.classCache.get(objectId);
if (answer != null)
return answer;
- return this.objectCache.get(objectId);
+ try
+ {
+ return this.objectCache.get(objectId);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw SnapshotException.rethrow(e);
+ }
}
+ @Override
public GCRootInfo[] getGCRootInfo(int objectId) throws SnapshotException
{
return roots.get(objectId);
}
+ @Override
public IClass getClassOf(int objectId) throws SnapshotException
{
if (isClass(objectId))
return getObject(objectId).getClazz();
else
+ {
+ // Add a useful error message
+ int nobjs = indexManager.o2class().size();
+ if (objectId >= nobjs || objectId < 0)
+ {
+ throw new SnapshotException(MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, objectId));
+ }
return (IClass) getObject(indexManager.o2class().get(objectId));
+ }
}
+ @Override
public long mapIdToAddress(int objectId) throws SnapshotException
{
+ // Add a useful error message
+ int nobjs = indexManager.o2address().size();
+ if (objectId >= nobjs || objectId < 0)
+ {
+ throw new SnapshotException(MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound,
+ new Object[] { objectId }));
+ }
return indexManager.o2address().get(objectId);
}
+ @Override
public long getHeapSize(int objectId) throws SnapshotException
{
+ // Add a useful error message
+ int nobjs = indexManager.idx.size();
+ if (objectId >= nobjs || objectId < 0)
+ {
+ throw new SnapshotException(MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, objectId));
+ }
if (arrayObjects.get(objectId))
{
return indexManager.a2size().getSize(objectId);
@@ -1507,13 +1634,20 @@ public final class SnapshotImpl implements ISnapshot
}
}
+ @Override
public long getHeapSize(int[] objectIds) throws UnsupportedOperationException, SnapshotException
{
long total = 0;
IOne2OneIndex o2class = indexManager.o2class();
IOne2SizeIndex a2size = indexManager.a2size();
+ // Add a useful error message
+ int nobjs = indexManager.idx.size();
for (int objectId : objectIds)
{
+ if (objectId >= nobjs || objectId < 0)
+ {
+ throw new SnapshotException(MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, objectId));
+ }
if (arrayObjects.get(objectId)) // take array sizes from another
// index
{
@@ -1539,6 +1673,12 @@ public final class SnapshotImpl implements ISnapshot
return total;
}
+ /**
+ * Calculate for each class an approximation for the retained size of all instances
+ * of that class.
+ * @param listener for reporting progress
+ * @throws SnapshotException if there is a problem
+ */
public void calculateMinRetainedHeapSizeForClasses(IProgressListener listener) throws SnapshotException {
listener.subTask(Messages.SnapshotImpl_CalculatingRetainedHeapSizeForClasses);
@@ -1558,23 +1698,31 @@ public final class SnapshotImpl implements ISnapshot
}
}
+ @Override
public long getRetainedHeapSize(int objectId) throws SnapshotException
{
+ // Add a useful error message
+ int nobjs = indexManager.idx.size();
+ if (objectId >= nobjs || objectId < 0)
+ {
+ throw new SnapshotException(MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, objectId));
+ }
if (this.isDominatorTreeCalculated())
return indexManager.o2retained().get(objectId);
else
return 0;
}
+ @Override
public boolean isArray(int objectId)
{
// Add a useful error message - snapshotInfo.getNumberOfObjects
// isn't set early on
int nobjs = indexManager.idx.size();
- if (objectId > nobjs || objectId < 0)
+ if (objectId >= nobjs || objectId < 0)
{
SnapshotException e = new SnapshotException(
- MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, new Object[] { objectId }));
+ MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, objectId));
throw new IllegalArgumentException(e);
}
if (arrayObjects.get(objectId))
@@ -1591,16 +1739,19 @@ public final class SnapshotImpl implements ISnapshot
return false;
}
+ @Override
public boolean isClass(int objectId)
{
return classCache.containsKey(objectId);
}
+ @Override
public boolean isGCRoot(int objectId)
{
return roots.containsKey(objectId);
}
+ @Override
public int mapAddressToId(long objectAddress) throws SnapshotException
{
int objectId = indexManager.o2address().reverse(objectAddress);
@@ -1611,6 +1762,7 @@ public final class SnapshotImpl implements ISnapshot
return objectId;
}
+ @Override
public void dispose()
{
IOException error = null;
@@ -1654,6 +1806,11 @@ public final class SnapshotImpl implements ISnapshot
// internal stuff
// //////////////////////////////////////////////////////////////
+ /**
+ * Finds the class and all its superclasses.
+ * @param classIndex the class ID
+ * @return all the classes
+ */
public List<IClass> resolveClassHierarchy(int classIndex)
{
IClass clazz = classCache.get(classIndex);
@@ -1674,16 +1831,27 @@ public final class SnapshotImpl implements ISnapshot
}
/** performance improved check if the object is a class loader */
+ @Override
public boolean isClassLoader(int objectId)
{
return loaderLabels.containsKey(objectId);
}
+ /**
+ * Finds the name associated with a class loader.
+ * @param objectId the class loader
+ * @return the name
+ */
public String getClassLoaderLabel(int objectId)
{
return loaderLabels.get(objectId);
}
+ /**
+ * Associates a class loader with a name
+ * @param objectId the class loader
+ * @param label the name
+ */
public void setClassLoaderLabel(int objectId, String label)
{
if (label == null)
@@ -2121,21 +2289,38 @@ public final class SnapshotImpl implements ISnapshot
}
+ /**
+ * Gets all the indexes for the snapshot.
+ * @return the manager of the indexes
+ */
public IndexManager getIndexManager()
{
return indexManager;
}
+ /**
+ * Gets the reader for the particular snapshot type to read
+ * individual objects.
+ * @return the reader
+ */
public IObjectReader getHeapObjectReader()
{
return heapObjectReader;
}
+ /**
+ * The cache to speed the finding of the retained size for each object.
+ * @return the cache
+ */
public RetainedSizeCache getRetainedSizeCache()
{
return indexManager.i2sv2;
}
+ /**
+ * Gets the roots per thread from the variables on the stack frames.
+ * @return a map between the thread ID and the GC root information
+ */
public HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> getRootsPerThread()
{
return rootsPerThread;
@@ -2150,6 +2335,7 @@ public final class SnapshotImpl implements ISnapshot
* @return the extra data
*/
@SuppressWarnings("unchecked")
+ @Override
public <A> A getSnapshotAddons(Class<A> addon) throws SnapshotException
{
if (addon == UnreachableObjectsHistogram.class)
@@ -2162,19 +2348,20 @@ public final class SnapshotImpl implements ISnapshot
}
}
+ @Override
public IThreadStack getThreadStack(int objectId) throws SnapshotException
{
- if (!parsedThreads)
- {
- threadId2stack = ThreadStackHelper.loadThreadsData(this);
- parsedThreads = true;
- }
-
- if (threadId2stack != null)
- {
- return threadId2stack.get(objectId);
- }
- return null;
+ if (!parsedThreads)
+ {
+ threadId2stack = ThreadStackHelper.loadThreadsData(this);
+ parsedThreads = true;
+ }
+
+ if (threadId2stack != null)
+ {
+ return threadId2stack.get(objectId);
+ }
+ return null;
}
// //////////////////////////////////////////////////////////////
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/AbstractArrayImpl.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/AbstractArrayImpl.java
index de4dd4d8..9ef9ea75 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/AbstractArrayImpl.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/AbstractArrayImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2021 SAP AG, IBM Corporation and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -17,6 +17,7 @@ import java.io.IOException;
import java.io.UncheckedIOException;
import org.eclipse.mat.SnapshotException;
+import org.eclipse.mat.parser.IObjectReader;
import org.eclipse.mat.snapshot.model.IArray;
/**
@@ -57,12 +58,14 @@ public abstract class AbstractArrayImpl extends AbstractObjectImpl implements IA
/**
* Sets the cached information about the contents of the array.
+ * @param content from the {@link IObjectReader}
*/
public void setInfo(Object content)
{
this.info = content;
}
+ @Override
public int getLength()
{
if (length == -1)
@@ -79,11 +82,13 @@ public abstract class AbstractArrayImpl extends AbstractObjectImpl implements IA
length = i;
}
+ @Override
protected StringBuffer appendFields(StringBuffer buf)
{
return super.appendFields(buf).append(";length=").append(length);//$NON-NLS-1$
}
+ @Override
public String getTechnicalName()
{
StringBuilder builder = new StringBuilder(256);
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/AbstractObjectImpl.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/AbstractObjectImpl.java
index f8828698..0f5782f9 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/AbstractObjectImpl.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/AbstractObjectImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2021 SAP AG, IBM Corporation and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -55,11 +55,13 @@ public abstract class AbstractObjectImpl implements IObject, Serializable
this.classInstance = classInstance;
}
+ @Override
public long getObjectAddress()
{
return address;
}
+ @Override
public int getObjectId()
{
return objectId;
@@ -67,7 +69,7 @@ public abstract class AbstractObjectImpl implements IObject, Serializable
/**
* Used to set the address, for example after reconstructing an object from a file.
- * @param address
+ * @param address the actual address
*/
public void setObjectAddress(long address)
{
@@ -83,6 +85,7 @@ public abstract class AbstractObjectImpl implements IObject, Serializable
this.objectId = objectId;
}
+ @Override
public ClassImpl getClazz()
{
return classInstance;
@@ -109,7 +112,7 @@ public abstract class AbstractObjectImpl implements IObject, Serializable
/**
* Changes the type of the object.
* Used when constructing a ClassImpl for java.lang.Class.
- * @param classInstance
+ * @param classInstance the type
*/
public void setClassInstance(ClassImpl classInstance)
{
@@ -126,6 +129,7 @@ public abstract class AbstractObjectImpl implements IObject, Serializable
this.source = (SnapshotImpl) dump;
}
+ @Override
public ISnapshot getSnapshot()
{
return this.source;
@@ -134,8 +138,10 @@ public abstract class AbstractObjectImpl implements IObject, Serializable
/**
* @since 1.0
*/
+ @Override
abstract public long getUsedHeapSize();
+ @Override
public long getRetainedHeapSize()
{
try
@@ -188,11 +194,13 @@ public abstract class AbstractObjectImpl implements IObject, Serializable
return buf.append("id=0x").append(Long.toHexString(getObjectAddress()));//$NON-NLS-1$
}
+ @Override
public String getClassSpecificName()
{
return ClassSpecificNameResolverRegistry.resolve(this);
}
+ @Override
public String getTechnicalName()
{
StringBuilder builder = new StringBuilder(256);
@@ -202,6 +210,7 @@ public abstract class AbstractObjectImpl implements IObject, Serializable
return builder.toString();
}
+ @Override
public String getDisplayName()
{
String label = getClassSpecificName();
@@ -225,6 +234,7 @@ public abstract class AbstractObjectImpl implements IObject, Serializable
// If the name is in the form <FIELD>{.<FIELD>}
// the fields are transiently followed
+ @Override
public final Object resolveValue(String name) throws SnapshotException
{
int p = name.indexOf('.');
@@ -301,6 +311,7 @@ public abstract class AbstractObjectImpl implements IObject, Serializable
*/
protected abstract Field internalGetField(String name);
+ @Override
public GCRootInfo[] getGCRootInfo() throws SnapshotException
{
int objId;
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ClassImpl.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ClassImpl.java
index 98f165df..0870c6c8 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ClassImpl.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ClassImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2021 SAP AG, IBM Corporation and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -51,6 +51,7 @@ public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<
private static final transient AtomicLongFieldUpdater<ClassImpl> totalSizeUpdater =
AtomicLongFieldUpdater.newUpdater(ClassImpl.class, "totalSize"); //$NON-NLS-1$
+ /** Shortcut for java.lang.Class */
public static final String JAVA_LANG_CLASS = IClass.JAVA_LANG_CLASS;
protected String name;
@@ -194,6 +195,7 @@ public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<
return usedHeapSize;
}
+ @Override
public ArrayLong getReferences()
{
ArrayLong answer = new ArrayLong(staticFields.length);
@@ -239,21 +241,28 @@ public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<
return answer;
}
+ @Override
public long getClassLoaderAddress()
{
return classLoaderAddress;
}
+ /**
+ * Sets the class loader for this class.
+ * @param address the address of the loader
+ */
public void setClassLoaderAddress(long address)
{
this.classLoaderAddress = address;
}
+ @Override
public List<FieldDescriptor> getFieldDescriptors()
{
return Arrays.asList(fields);
}
+ @Override
public int getNumberOfObjects()
{
return instanceCount;
@@ -262,44 +271,59 @@ public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<
/**
* @since 1.0
*/
+ @Override
public long getHeapSizePerInstance()
{
return instanceSize;
}
/**
- * @since 1.0
+ * Sets the size per instance for the class
+ * @param size the size in bytes
+ * @since 1.0
*/
public void setHeapSizePerInstance(long size)
{
instanceSize = (int)Math.min(size, Integer.MAX_VALUE);
}
+ @Override
public String getName()
{
return name;
}
+ /**
+ * Sets the class name.
+ * @param name the class name
+ */
public void setName(String name)
{
this.name = name;
}
+ @Override
public List<Field> getStaticFields()
{
return Arrays.asList(staticFields);
}
+ /**
+ * Gets the address of the superclass.
+ * @return the superclass address
+ */
public long getSuperClassAddress()
{
return superClassAddress;
}
+ @Override
public int getSuperClassId()
{
return superClassId;
}
+ @Override
public ClassImpl getSuperClass()
{
try
@@ -312,16 +336,22 @@ public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<
}
}
+ /**
+ * The size of all the instances of this class.
+ * @return the size in bytes
+ */
public long getTotalSize()
{
return totalSize;
}
+ @Override
public boolean hasSuperClass()
{
return this.superClassAddress != 0;
}
+ @Override
public int compareTo(ClassImpl other)
{
final long myAddress = getObjectAddress();
@@ -330,7 +360,9 @@ public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<
}
/**
- * @since 1.0
+ * Note another instance to this class.
+ * @param usedHeapSize the size in bytes of this instance
+ * @since 1.0
*/
public void addInstance(long usedHeapSize)
{
@@ -339,7 +371,10 @@ public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<
}
/**
- * @since 1.0
+ * Remove an instance of this class.
+ * Reverses the effect of {@link #addInstance(long)}
+ * @param heapSizePerInstance the size in bytes of this instance
+ * @since 1.0
*/
public void removeInstance(long heapSizePerInstance)
{
@@ -353,12 +388,14 @@ public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<
totalSizeUpdater.getAndAdd(this, heapSize);
}
+ @Override
@SuppressWarnings("unchecked")
public List<IClass> getSubclasses()
{
return subClasses != null ? subClasses : Collections.EMPTY_LIST;
}
+ @Override
public List<IClass> getAllSubclasses()
{
if (subClasses == null || subClasses.isEmpty())
@@ -377,11 +414,13 @@ public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<
return super.appendFields(buf).append(";name=").append(getName());//$NON-NLS-1$
}
+ @Override
public boolean isArrayType()
{
return isArrayType;
}
+ @Override
public String getTechnicalName()
{
StringBuilder builder = new StringBuilder(256);
@@ -401,11 +440,16 @@ public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<
return null;
}
+ @Override
public int getClassLoaderId()
{
return classLoaderId;
}
+ /**
+ * Add a subclass of this class.
+ * @param clazz the subclass
+ */
public void addSubClass(ClassImpl clazz)
{
if (subClasses == null)
@@ -413,19 +457,28 @@ public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<
subClasses.add(clazz);
}
+ /**
+ * Remove a subclass of this class.
+ * Reverses the effect of {@link #addSubClass(ClassImpl)}
+ * @param clazz the subclass
+ */
public void removeSubClass(ClassImpl clazz)
{
subClasses.remove(clazz);
}
/**
- * @since 1.0
+ * Sets the used heap size for this particular class.
+ * Does not include instances.
+ * @param usedHeapSize the size in bytes
+ * @since 1.0
*/
public void setUsedHeapSize(long usedHeapSize)
{
this.usedHeapSize = (int)Math.min(usedHeapSize, Integer.MAX_VALUE);
}
+ @Override
public boolean doesExtend(String className) throws SnapshotException
{
if (className.equals(this.name))
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ClassLoaderImpl.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ClassLoaderImpl.java
index ef5192fe..86b88b41 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ClassLoaderImpl.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ClassLoaderImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2021 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -36,6 +36,7 @@ public class ClassLoaderImpl extends InstanceImpl implements IClassLoader
{
private static final long serialVersionUID = 1L;
+ /** If the class loader has no name */
public static final String NO_LABEL = "__none__";//$NON-NLS-1$
private volatile transient List<IClass> definedClasses = null;
@@ -110,6 +111,7 @@ public class ClassLoaderImpl extends InstanceImpl implements IClassLoader
return result;
}
+ @Override
public long getRetainedHeapSizeOfObjects(boolean calculateIfNotAvailable, boolean calculateMinRetainedSize,
IProgressListener listener) throws SnapshotException
{
@@ -122,7 +124,7 @@ public class ClassLoaderImpl extends InstanceImpl implements IClassLoader
* @param dump the snapshot
* @param classLoaderId the class loader to look for
* @return a list of classes
- * @throws SnapshotException
+ * @throws SnapshotException problem retrieving the information
*/
public static final List<IClass> doGetDefinedClasses(ISnapshot dump, int classLoaderId) throws SnapshotException
{
@@ -144,7 +146,7 @@ public class ClassLoaderImpl extends InstanceImpl implements IClassLoader
* @param calculateMinRetainedSize true if to make an approximate calculation
* @param listener to indicate progress, errors and to cancel
* @return the size, negative if approximate
- * @throws SnapshotException
+ * @throws SnapshotException problem retrieving the information
*/
public static final long doGetRetainedHeapSizeOfObjects(ISnapshot dump, int classLoaderId,
boolean calculateIfNotAvailable, boolean calculateMinRetainedSize, IProgressListener listener)
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/InstanceImpl.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/InstanceImpl.java
index 16e09dc7..8816b783 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/InstanceImpl.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/InstanceImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2021 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -106,6 +106,7 @@ public class InstanceImpl extends AbstractObjectImpl implements IInstance
return fields;
}
+ @Override
public Field getField(String name)
{
return internalGetField(name);
@@ -175,6 +176,7 @@ public class InstanceImpl extends AbstractObjectImpl implements IInstance
}
}
+ @Override
public ArrayLong getReferences()
{
List<Field> fields = getFields();
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ObjectArrayImpl.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ObjectArrayImpl.java
index 254a0813..047572d3 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ObjectArrayImpl.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/ObjectArrayImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2021 SAP AG, IBM Corporation and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -103,6 +103,7 @@ public class ObjectArrayImpl extends AbstractArrayImpl implements IObjectArray
}
}
+ @Override
public long[] getReferenceArray(int offset, int length)
{
try
@@ -119,6 +120,7 @@ public class ObjectArrayImpl extends AbstractArrayImpl implements IObjectArray
}
}
+ @Override
public ArrayLong getReferences()
{
ArrayLong answer = new ArrayLong(getLength() + 1);
@@ -137,6 +139,7 @@ public class ObjectArrayImpl extends AbstractArrayImpl implements IObjectArray
return answer;
}
+ @Override
protected Field internalGetField(String name)
{
if (name.charAt(0) != '[' || name.charAt(name.length() - 1) != ']')
@@ -162,6 +165,7 @@ public class ObjectArrayImpl extends AbstractArrayImpl implements IObjectArray
}
}
+ @Override
public List<NamedReference> getOutboundReferences()
{
List<NamedReference> answer = new ArrayList<NamedReference>(getLength() + 1);
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/PrimitiveArrayImpl.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/PrimitiveArrayImpl.java
index 8e5cd8c3..d41909ba 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/PrimitiveArrayImpl.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/PrimitiveArrayImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2021 SAP AG, IBM Corporation and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -62,12 +62,14 @@ public class PrimitiveArrayImpl extends AbstractArrayImpl implements IPrimitiveA
return COMPONENT_TYPE[type];
}
+ @Override
public Object getValueAt(int index)
{
Object data = getValueArray(index, 1);
return data != null ? Array.get(data, 0) : null;
}
+ @Override
public Object getValueArray()
{
try
@@ -84,6 +86,7 @@ public class PrimitiveArrayImpl extends AbstractArrayImpl implements IPrimitiveA
}
}
+ @Override
public Object getValueArray(int offset, int length)
{
try
@@ -100,6 +103,7 @@ public class PrimitiveArrayImpl extends AbstractArrayImpl implements IPrimitiveA
}
}
+ @Override
protected Field internalGetField(String name)
{
return null;
@@ -113,6 +117,7 @@ public class PrimitiveArrayImpl extends AbstractArrayImpl implements IPrimitiveA
return references;
}
+ @Override
public List<NamedReference> getOutboundReferences()
{
List<NamedReference> references = new ArrayList<NamedReference>(1);
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XClassHistogramRecord.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XClassHistogramRecord.java
index 3b5c6914..b06fa93f 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XClassHistogramRecord.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XClassHistogramRecord.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2021 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -45,11 +45,13 @@ public final class XClassHistogramRecord extends ClassHistogramRecord
this.classInstance = classInstance;
}
+ @Override
public int getClassId()
{
return classInstance.getObjectId();
}
+ @Override
public int[] getObjectIds()
{
try
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XGCRootInfo.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XGCRootInfo.java
index 990092d0..12df75f7 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XGCRootInfo.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XGCRootInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -35,6 +35,7 @@ public final class XGCRootInfo extends GCRootInfo
}
/**
+ * Sets the object ID associated with the object address.
* @param objectId the object
* @see #getObjectId()
*/
@@ -44,8 +45,8 @@ public final class XGCRootInfo extends GCRootInfo
}
/**
- *
- * @param objectId
+ * Set the object which retains this object.
+ * @param objectId the object ID associated with the content address
* @see #getContextId()
*/
public void setContextId(int objectId)
diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XSnapshotInfo.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XSnapshotInfo.java
index b4cfaeed..28d65d0f 100644
--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XSnapshotInfo.java
+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/model/XSnapshotInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 SAP AG and others.
+ * Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -33,8 +33,8 @@ public final class XSnapshotInfo extends SnapshotInfo
}
/**
- *
- * @param prefix
+ * Set the prefix used for index files.
+ * @param prefix the path prefix
* @see #getPrefix()
*/
public void setPrefix(String prefix)
@@ -43,8 +43,8 @@ public final class XSnapshotInfo extends SnapshotInfo
}
/**
- *
- * @param path
+ * Sets the path to the snapshot file.
+ * @param path the file path
* @see #getPath()
*/
public void setPath(String path)
@@ -53,8 +53,8 @@ public final class XSnapshotInfo extends SnapshotInfo
}
/**
- *
- * @param creationDate
+ * Sets the creation date of the snapshot
+ * @param creationDate the date of creation
* @see #getCreationDate()
*/
public void setCreationDate(Date creationDate)
@@ -63,8 +63,8 @@ public final class XSnapshotInfo extends SnapshotInfo
}
/**
- *
- * @param identifierSize
+ * Sets the identifier size for the snapshot.
+ * @param identifierSize the size in bits
* @see #getIdentifierSize()
*/
public void setIdentifierSize(int identifierSize)
@@ -73,8 +73,8 @@ public final class XSnapshotInfo extends SnapshotInfo
}
/**
- *
- * @param jvmInfo
+ * Sets information about the JVM.
+ * @param jvmInfo a short description of the JVM
* @see #getJvmInfo()
*/
public void setJvmInfo(String jvmInfo)
@@ -83,8 +83,8 @@ public final class XSnapshotInfo extends SnapshotInfo
}
/**
- *
- * @param numberOfClasses
+ * Sets the total number of classes.
+ * @param numberOfClasses how many classes
* @see #getNumberOfClasses()
*/
public void setNumberOfClasses(int numberOfClasses)
@@ -93,8 +93,8 @@ public final class XSnapshotInfo extends SnapshotInfo
}
/**
- *
- * @param numberOfClassLoaders
+ * Sets the total number of class loaders.
+ * @param numberOfClassLoaders how many class loaders
* @see #getNumberOfClassLoaders()
*/
public void setNumberOfClassLoaders(int numberOfClassLoaders)
@@ -103,8 +103,8 @@ public final class XSnapshotInfo extends SnapshotInfo
}
/**
- *
- * @param numberOfGCRoots
+ * Sets the number of GC roots.
+ * @param numberOfGCRoots the number of GC roots
* @see #getNumberOfGCRoots()
*/
public void setNumberOfGCRoots(int numberOfGCRoots)
@@ -113,8 +113,8 @@ public final class XSnapshotInfo extends SnapshotInfo
}
/**
- *
- * @param numberOfObjects
+ * Sets the number of objects.
+ * @param numberOfObjects the total number of objects
* @see #getNumberOfObjects()
*/
public void setNumberOfObjects(int numberOfObjects)
@@ -123,8 +123,8 @@ public final class XSnapshotInfo extends SnapshotInfo
}
/**
- *
- * @param usedHeapSize
+ * Sets the total used heap size.
+ * @param usedHeapSize the total heap size in bytes
* @see #getUsedHeapSize()
*/
public void setUsedHeapSize(long usedHeapSize)
diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/OQLTest.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/OQLTest.java
index cb71d0a1..16512eb8 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/OQLTest.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/OQLTest.java
@@ -33,6 +33,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -2171,6 +2172,175 @@ public class OQLTest
}
/**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testBadObject() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT u FROM OBJECTS 1234567890 u");
+ assertThat(irt, nullValue());
+ }
+
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testBadObjectClassof() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT classof(u) FROM OBJECTS (1234567890) u");
+ assertThat(irt, nullValue());
+ }
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testBadObjectInbounds() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT inbounds(u) FROM OBJECTS (1234567890) u");
+ assertThat(irt, nullValue());
+ }
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testBadObjectOutbounds() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT outbounds(u) FROM OBJECTS (1234567890) u");
+ assertThat(irt, nullValue());
+ }
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testBadObjectDominatorof() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT dominatorof(u) FROM OBJECTS (1234567890) u");
+ assertThat(irt, nullValue());
+ }
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testBadObjectDominators() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT dominators(u) FROM OBJECTS (1234567890) u");
+ assertThat(irt, nullValue());
+ }
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testBadObjectRetainedSet() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT AS RETAINED SET u FROM OBJECTS (1234567890) u");
+ assertThat(irt, nullValue());
+ }
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testInboundRefererIds() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT ${snapshot}.getInboundRefererIds((SELECT * FROM OBJECTS 1,1234567890 ),null) FROM OBJECTS 1");
+ assertThat(irt, nullValue());
+ }
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testOutboundReferentIds() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT ${snapshot}.getOutboundReferentIds((SELECT * FROM OBJECTS 1,1234567890 ),null) FROM OBJECTS 1");
+ assertThat(irt, nullValue());
+ }
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testRetainedSet1() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT ${snapshot}.getRetainedSet((SELECT * FROM OBJECTS 1234567890 ),null) FROM OBJECTS 1");
+ assertThat(irt, nullValue());
+ }
+
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testRetainedSet2() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT ${snapshot}.getRetainedSet((SELECT * FROM OBJECTS 1,1234567890 ),null) FROM OBJECTS 1");
+ assertThat(irt, nullValue());
+ }
+
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testGetHeapSize() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT ${snapshot}.getHeapSize((SELECT * FROM OBJECTS 1,1234567890 ),null) FROM OBJECTS 1");
+ assertThat(irt, nullValue());
+ }
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testBadObjectGetRetainedHeapSize() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT ${snapshot}.getRetainedHeapSize(u) FROM OBJECTS (1234567890) u");
+ assertThat(irt, nullValue());
+ }
+
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testBadObjectGetHeapSize() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT ${snapshot}.getHeapSize(u) FROM OBJECTS (1234567890) u");
+ assertThat(irt, nullValue());
+ }
+
+ /**
+ * Check error message for bad object ID
+ * @throws SnapshotException
+ */
+ @Test(expected = SnapshotException.class)
+ public void testBadObjectMapIdToAddress() throws SnapshotException
+ {
+ IResultTable irt = (IResultTable)execute("SELECT ${snapshot}.mapIdToAddress(u) FROM OBJECTS (1234567890) u");
+ assertThat(irt, nullValue());
+ }
+
+ /**
* Check all getOQL() from contexts from the result are sensible.
* @param rt ResultTable
* @throws SnapshotException
@@ -3039,7 +3209,7 @@ public class OQLTest
buildAddr(sb, dups);
sb.append(" s)");
IResultTable result = (IResultTable)execute(sb.toString());
- System.out.println(sb.toString());
+ //System.out.println(sb.toString());
checkGetOQL(result);
}
@@ -3059,7 +3229,7 @@ public class OQLTest
OQL.union(sb, s1);
OQL.union(sb, "SELECT s FROM OBJECTS 2 s");
IResultTable result = (IResultTable)execute(sb.toString());
- System.out.println(sb.toString());
+ //System.out.println(sb.toString());
checkGetOQL(result);
}
// //////////////////////////////////////////////////////////////
diff --git a/plugins/org.eclipse.mat.ui.help/javadoc/dtfj/package-list b/plugins/org.eclipse.mat.ui.help/javadoc/dtfj/package-list
index 49635632..789e11ad 100644
--- a/plugins/org.eclipse.mat.ui.help/javadoc/dtfj/package-list
+++ b/plugins/org.eclipse.mat.ui.help/javadoc/dtfj/package-list
@@ -1,3 +1,4 @@
com.ibm.dtfj.image
com.ibm.dtfj.java
com.ibm.dtfj.runtime
+com.ibm.j9ddr.tools.ddrinteractive

Back to the top