diff options
| author | Andrew Johnson | 2019-11-16 11:56:04 +0000 |
|---|---|---|
| committer | Andrew Johnson | 2019-11-16 12:04:25 +0000 |
| commit | cca4cae44ab5e6d6a6b4ca1ba8b2bbfa968b12d0 (patch) | |
| tree | a329ae726180108d2db715cb04672978aaadf8cc | |
| parent | 15db89cfa4a1813b08291cf234a225ef443df324 (diff) | |
| download | org.eclipse.mat-cca4cae44ab5e6d6a6b4ca1ba8b2bbfa968b12d0.tar.gz org.eclipse.mat-cca4cae44ab5e6d6a6b4ca1ba8b2bbfa968b12d0.tar.xz org.eclipse.mat-cca4cae44ab5e6d6a6b4ca1ba8b2bbfa968b12d0.zip | |
552879: OQL enhancements for sub-selects, maps, context providers
More fixes for ProcessEnvironment collection classes only used on Unix
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=552879
Change-Id: Ia7739e35184b5d39675edb11723a76fbe13d372e
9 files changed, 216 insertions, 23 deletions
diff --git a/plugins/org.eclipse.mat.api/plugin.xml b/plugins/org.eclipse.mat.api/plugin.xml index 6ecf1d74..55b72b36 100644 --- a/plugins/org.eclipse.mat.api/plugin.xml +++ b/plugins/org.eclipse.mat.api/plugin.xml @@ -114,6 +114,7 @@ <resolver impl="org.eclipse.mat.inspections.CommonNameResolver$ClassTypeResolver" />
<resolver impl="org.eclipse.mat.inspections.CommonNameResolver$StackTraceElementResolver" />
<resolver impl="org.eclipse.mat.inspections.CommonNameResolver$EnumResolver" />
+ <resolver impl="org.eclipse.mat.inspections.CommonNameResolver$ExternalDataResolver" />
<!-- eclipse -->
<resolver impl="org.eclipse.mat.inspections.eclipse.EclipseNameResolver$EclipseClassLoaderResolver" />
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/CommonNameResolver.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/CommonNameResolver.java index 88559778..716df5c5 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/CommonNameResolver.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/CommonNameResolver.java @@ -1,5 +1,5 @@ /*******************************************************************************
- * Copyright (c) 2008, 2018 SAP AG and IBM Corporation.
+ * Copyright (c) 2008, 2019 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 v1.0
* which accompanies this distribution, and is available at
@@ -471,7 +471,18 @@ public class CommonNameResolver public String resolve(IObject heapObject) throws SnapshotException
{
IObject value = (IObject) heapObject.resolveValue("name"); //$NON-NLS-1$
- return value != null ? ClassSpecificNameResolverRegistry.resolve(value) : null;
+ return value != null ? ClassSpecificNameResolverRegistry.resolve(value) : null;
+ }
+ }
+
+ @Subject("java.lang.ProcessEnvironment$ExternalData")
+ public static class ExternalDataResolver implements IClassSpecificNameResolver
+ {
+ public String resolve(IObject heapObject) throws SnapshotException
+ {
+ IObject value = (IObject) heapObject.resolveValue("str"); //$NON-NLS-1$
+ return value != null ? ClassSpecificNameResolverRegistry.resolve(value) : null;
}
}
+
}
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/collections/ExtractListValuesQuery.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/collections/ExtractListValuesQuery.java index 589dbb56..65b2962f 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/collections/ExtractListValuesQuery.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/collections/ExtractListValuesQuery.java @@ -46,13 +46,15 @@ import org.eclipse.mat.util.MessageUtil; "java.util.Collections$UnmodifiableList",
"java.util.Collections$CheckedList",
"java.util.Collections$CheckedQueue",
-
+
"java.util.ImmutableCollections$AbstractImmutableList",
"java.util.ImmutableCollect0ions$List0",
"java.util.concurrent.CopyOnWriteArrayList",
"java.util.concurrent.ConcurrentLinkedDeque",
-
+
"java.util.EnumMap$Values",
+ "java.lang.ProcessEnvironment$CheckedValues",
+ "java.lang.ProcessEnvironment$StringValues",
})
public class ExtractListValuesQuery implements IQuery
{
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/KeySetCollectionExtractor.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/KeySetCollectionExtractor.java index 94907e8a..fc555ec9 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/KeySetCollectionExtractor.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/KeySetCollectionExtractor.java @@ -1,5 +1,5 @@ /*******************************************************************************
- * Copyright (c) 2018 IBM Corporation.
+ * Copyright (c) 2018, 2019 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,7 @@ import java.util.Map.Entry; import org.eclipse.mat.SnapshotException;
import org.eclipse.mat.collect.ArrayInt;
import org.eclipse.mat.inspections.collectionextract.ExtractedMap;
-import org.eclipse.mat.inspections.collectionextract.IMapExtractor;
+import org.eclipse.mat.inspections.collectionextract.ICollectionExtractor;
import org.eclipse.mat.snapshot.model.IObject;
import org.eclipse.mat.snapshot.model.IObjectArray;
@@ -23,7 +23,12 @@ public class KeySetCollectionExtractor extends WrapperMapExtractor {
public KeySetCollectionExtractor(String field)
{
- super(field);
+ this(field, null);
+ }
+
+ public KeySetCollectionExtractor(String field, ICollectionExtractor extractor)
+ {
+ super(field, extractor);
}
public int[] extractEntryIds(IObject coll) throws SnapshotException
@@ -34,7 +39,9 @@ public class KeySetCollectionExtractor extends WrapperMapExtractor {
for (Entry<IObject,IObject>en : em)
{
- a.add(en.getKey().getObjectId());
+ IObject key = en.getKey();
+ if (key != null)
+ a.add(en.getKey().getObjectId());
}
}
return a.toArray();
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/KnownCollectionInfo.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/KnownCollectionInfo.java index 2182f4ce..f886f304 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/KnownCollectionInfo.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/KnownCollectionInfo.java @@ -157,10 +157,10 @@ public class KnownCollectionInfo implements ICollectionExtractorProvider new CollectionExtractionInfo("java.lang.ProcessEnvironment$CheckedEntrySet", new WrapperMapExtractor("s")), //$NON-NLS-1$ //$NON-NLS-2$ new CollectionExtractionInfo("java.lang.ProcessEnvironment$CheckedKeySet", new WrapperMapExtractor("s")), //$NON-NLS-1$ //$NON-NLS-2$ new CollectionExtractionInfo("java.lang.ProcessEnvironment$CheckedValues", new WrapperMapExtractor("c")), //$NON-NLS-1$ //$NON-NLS-2$ - new CollectionExtractionInfo("java.lang.ProcessEnvironment$StringEnvironment", new WrapperMapExtractor("m")), //$NON-NLS-1$ //$NON-NLS-2$ + new CollectionExtractionInfo("java.lang.ProcessEnvironment$StringEnvironment", new WrapperFieldMapExtractor("m", "str", "str")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ new CollectionExtractionInfo("java.lang.ProcessEnvironment$StringEntrySet", new WrapperMapExtractor("s")), //$NON-NLS-1$ //$NON-NLS-2$ - new CollectionExtractionInfo("java.lang.ProcessEnvironment$StringKeySet", new WrapperMapExtractor("s")), //$NON-NLS-1$ //$NON-NLS-2$ - new CollectionExtractionInfo("java.lang.ProcessEnvironment$StringValues", new WrapperMapExtractor("c")), //$NON-NLS-1$ //$NON-NLS-2$ + new CollectionExtractionInfo("java.lang.ProcessEnvironment$StringKeySet", new WrapperFieldMapExtractor("s", "str", "str")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + new CollectionExtractionInfo("java.lang.ProcessEnvironment$StringValues", new WrapperFieldCollectionExtractor("s", "str")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ new CollectionExtractionInfo("java.util.concurrent.ConcurrentHashMap$Segment", new HashMapCollectionExtractor("count", "table", "key", "value")), // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/ValuesCollectionExtractor.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/ValuesCollectionExtractor.java index 3214c069..93208016 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/ValuesCollectionExtractor.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/ValuesCollectionExtractor.java @@ -1,3 +1,13 @@ +/*******************************************************************************
+ * Copyright (c) 2018, 2019 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation/Andrew Johnson - initial API and implementation
+ *******************************************************************************/
package org.eclipse.mat.internal.collectionextract;
import java.util.Map.Entry;
@@ -9,16 +19,6 @@ import org.eclipse.mat.inspections.collectionextract.ICollectionExtractor; import org.eclipse.mat.snapshot.model.IObject;
import org.eclipse.mat.snapshot.model.IObjectArray;
-/*******************************************************************************
- * Copyright (c) 2018 IBM Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation/Andrew Johnson - initial API and implementation
- *******************************************************************************/
public class ValuesCollectionExtractor extends WrapperCollectionExtractor
{
public ValuesCollectionExtractor(String field)
@@ -39,7 +39,9 @@ public class ValuesCollectionExtractor extends WrapperCollectionExtractor {
for (Entry<IObject,IObject>en : em)
{
- a.add(en.getValue().getObjectId());
+ IObject value = en.getValue();
+ if (value != null)
+ a.add(value.getObjectId());
}
}
return a.toArray();
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/WrapperFieldCollectionExtractor.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/WrapperFieldCollectionExtractor.java new file mode 100644 index 00000000..4a0265f0 --- /dev/null +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/WrapperFieldCollectionExtractor.java @@ -0,0 +1,56 @@ +/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Johnson (IBM Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mat.internal.collectionextract;
+
+import org.eclipse.mat.SnapshotException;
+import org.eclipse.mat.collect.ArrayInt;
+import org.eclipse.mat.inspections.collectionextract.ICollectionExtractor;
+import org.eclipse.mat.snapshot.model.IObject;
+
+public class WrapperFieldCollectionExtractor extends WrapperCollectionExtractor
+{
+
+ String entryfield;
+ public WrapperFieldCollectionExtractor(String field, String entryfield)
+ {
+ this(field, entryfield, null);
+ }
+
+ public WrapperFieldCollectionExtractor(String field, String entryfield, ICollectionExtractor extractor)
+ {
+ super(field, extractor);
+ this.entryfield = entryfield;
+
+ }
+
+ @Override
+ public int[] extractEntryIds(IObject coll) throws SnapshotException
+ {
+ int r[] = super.extractEntryIds(coll);
+ ArrayInt a = new ArrayInt(r.length);
+ for (int i = 0; i < r.length; ++i)
+ {
+ IObject o = coll.getSnapshot().getObject(r[i]);
+ Object o2 = o.resolveValue(entryfield);
+ if (o2 instanceof IObject)
+ {
+ a.add(((IObject)o2).getObjectId());
+ }
+ }
+ return a.toArray();
+ }
+
+ @Override
+ public boolean hasExtractableArray()
+ {
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/WrapperFieldMapExtractor.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/WrapperFieldMapExtractor.java new file mode 100644 index 00000000..64b67f75 --- /dev/null +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/WrapperFieldMapExtractor.java @@ -0,0 +1,108 @@ +/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Johnson (IBM Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mat.internal.collectionextract;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.eclipse.mat.SnapshotException;
+import org.eclipse.mat.collect.ArrayInt;
+import org.eclipse.mat.inspections.collectionextract.ExtractedMap;
+import org.eclipse.mat.inspections.collectionextract.ICollectionExtractor;
+import org.eclipse.mat.snapshot.model.IObject;
+
+public class WrapperFieldMapExtractor extends WrapperMapExtractor
+{
+ String keyfield;
+ String valuefield;
+
+ public WrapperFieldMapExtractor(String field, String keyfield, String valuefield)
+ {
+ this(field, keyfield, valuefield, null);
+ }
+
+ public WrapperFieldMapExtractor(String field, String keyfield, String valuefield, ICollectionExtractor extractor)
+ {
+ super(field, extractor);
+ this.keyfield = keyfield;
+ this.valuefield = valuefield;
+ }
+
+ @Override
+ public int[] extractEntryIds(IObject coll) throws SnapshotException
+ {
+ int r[] = super.extractEntryIds(coll);
+ ArrayInt a = new ArrayInt(r.length);
+ for (int i = 0; i < r.length; ++i)
+ {
+ IObject o = coll.getSnapshot().getObject(r[i]);
+ Object o2 = o.resolveValue(keyfield);
+ if (o2 instanceof IObject)
+ {
+ a.add(((IObject)o2).getObjectId());
+ }
+ }
+ return a.toArray();
+ }
+
+ public Iterator<Entry<IObject, IObject>> extractMapEntries(final IObject coll)
+ {
+ // Wrap the returned object so the wrapper collection is the entry object
+ ExtractedMap em = extractMap(coll);
+ final Iterator<Entry<IObject, IObject>> it = em.iterator();
+ return new Iterator<Entry<IObject, IObject>>() {
+
+ public boolean hasNext()
+ {
+ return it.hasNext();
+ }
+
+ public Entry<IObject, IObject> next()
+ {
+ Entry<IObject, IObject> e = it.next();
+ // Unwrap the keys and values
+ IObject key = e.getKey();
+ if (key != null)
+ {
+ try
+ {
+ Object o = key.resolveValue(keyfield);
+ if (o instanceof IObject)
+ key = (IObject)o;
+ else
+ key = null;
+ }
+ catch (SnapshotException e1)
+ {
+ throw new RuntimeException(e1);
+ }
+ }
+ IObject value = e.getValue();
+ if (value != null)
+ {
+ try
+ {
+ Object o = value.resolveValue(valuefield);
+ if (o instanceof IObject)
+ value = (IObject)o;
+ else
+ value = null;
+ }
+ catch (SnapshotException e1)
+ {
+ throw new RuntimeException(e1);
+ }
+ }
+ return new EntryObject(coll, key, value);
+ }
+ };
+ }
+}
diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/WrapperMapExtractor.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/WrapperMapExtractor.java index 5f84297d..bb28ecbf 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/WrapperMapExtractor.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/WrapperMapExtractor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2018 SAP AG, IBM Corporation and others + * Copyright (c) 2008, 2019 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 v1.0 * which accompanies this distribution, and is available at @@ -17,6 +17,7 @@ import java.util.Map.Entry; import org.eclipse.mat.SnapshotException; import org.eclipse.mat.inspections.collectionextract.ExtractedMap; +import org.eclipse.mat.inspections.collectionextract.ICollectionExtractor; import org.eclipse.mat.inspections.collectionextract.IMapExtractor; import org.eclipse.mat.snapshot.model.IObject; @@ -27,6 +28,11 @@ public class WrapperMapExtractor extends WrapperCollectionExtractor implements I super(field); } + public WrapperMapExtractor(String field, ICollectionExtractor extractor) + { + super(field, extractor); + } + public boolean hasCollisionRatio() { return true; |
