Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,17 @@ private Histogram groupByClasses(int[] dominated, IProgressListener listener) th
if (listener.isCanceled())
throw new IProgressListener.OperationCanceledException();

Collection<ClassHistogramRecord> records = histogram.getClassHistogramRecords();
ClassHistogramRecord[] arr = new ClassHistogramRecord[records.size()];
int i = 0;

Collection<ClassHistogramRecord> records = histogram.getClassHistogramRecords();
for (ClassHistogramRecord record : records)
{
record.setRetainedHeapSize(sumRetainedSize(record.getObjectIds(), snapshot));
arr[i++] = record;
if (i % 10 == 0 && listener.isCanceled())
if (i++ % 10 == 0 && listener.isCanceled())
throw new IProgressListener.OperationCanceledException();
}

Collection<ClassLoaderHistogramRecord> loaderRecords = histogram.getClassLoaderHistogramRecords();
ClassLoaderHistogramRecord[] loaderArr = new ClassLoaderHistogramRecord[loaderRecords.size()];
i = 0;

for (ClassLoaderHistogramRecord record : loaderRecords)
{
long retainedSize = 0;
Expand All @@ -190,7 +185,6 @@ private Histogram groupByClasses(int[] dominated, IProgressListener listener) th
}

record.setRetainedHeapSize(retainedSize);
loaderArr[i++] = record;
}

return histogram;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,22 +250,15 @@ private Histogram groupByClasses(int[] dominated, IProgressListener listener) th
throw new IProgressListener.OperationCanceledException();

Collection<ClassHistogramRecord> records = histogram.getClassHistogramRecords();
ClassHistogramRecord[] arr = new ClassHistogramRecord[records.size()];
int i = 0;

for (ClassHistogramRecord record : records)
{
if (listener.isCanceled())
throw new IProgressListener.OperationCanceledException();

record.setRetainedHeapSize(sumRetainedSize(record.getObjectIds(), snapshot));
arr[i++] = record;
}

Collection<ClassLoaderHistogramRecord> loaderRecords = histogram.getClassLoaderHistogramRecords();
ClassLoaderHistogramRecord[] loaderArr = new ClassLoaderHistogramRecord[loaderRecords.size()];
i = 0;

for (ClassLoaderHistogramRecord record : loaderRecords)
{
if (listener.isCanceled())
Expand All @@ -278,7 +271,6 @@ private Histogram groupByClasses(int[] dominated, IProgressListener listener) th
}

record.setRetainedHeapSize(retainedSize);
loaderArr[i++] = record;
}

return histogram;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,12 @@ public Result execute(IProgressListener listener) throws Exception
InspectionAssert.heapFormatIsNot(snapshot, "phd"); //$NON-NLS-1$

Result spec = new Result(Messages.ThreadInfoQuery_ThreadDetails);
List<ThreadInfoImpl> infos = new ArrayList<ThreadInfoImpl>();

for (int[] ids : threadIds)
{
for (int id : ids)
{
infos.add(processThread(id, spec, listener));
processThread(id, spec, listener);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected IHeapDumpProvider createDelegate(IConfigurationElement configElement)
if (MATPlugin.getDefault().isDebugging())
MATPlugin.log(IStatus.INFO, MessageUtil.format("IHeapDumpProvider ''{0}'' registered.", descriptor.getName())); //$NON-NLS-1$

return descriptor != null ? dumpProvider : null;
return dumpProvider;
}
catch (SnapshotException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ else if (first.getClass().equals(o.getClass()) && second == null)
tail = second;
}
}
if (header == null)
return new int[0];

IObject previous = header;
IObject current = header;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Iterator<Entry<IObject, IObject>> extractMapEntries(IObject coll)
{
try
{
return new MapEntryIterator(coll.getSnapshot(), coll, extractEntryIds(coll));
return new MapEntryIterator(coll.getSnapshot(), extractEntryIds(coll));
}
catch (SnapshotException e)
{
Expand All @@ -62,14 +62,12 @@ private class MapEntryIterator implements Iterator<Entry<IObject, IObject>>
private final ISnapshot snapshot;
private final int[] ids;
private int idx;
private IObject coll;

public MapEntryIterator(ISnapshot snapshot, IObject coll, int[] ids)
public MapEntryIterator(ISnapshot snapshot, int[] ids)
{
this.snapshot = snapshot;
this.ids = ids;
this.idx = 0;
this.coll = coll;
}

public boolean hasNext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public <C extends ClassloaderDominatorRecord> C[] getClassloaderDominatorRecords
{
classloaderDominatorRecords = load((Class<ClassloaderDominatorRecord>) factoryClass);
}
return (C[]) classloaderDominatorRecords;
}
return (C[]) classloaderDominatorRecords;
}

private ClassloaderDominatorRecord[] load(Class<ClassloaderDominatorRecord> factoryClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
import java.util.Arrays;
import java.util.Objects;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

/**
* Decompresses a DEFLATE data stream (raw format without zlib or gzip headers or footers) into a byte stream.
*/
@SuppressFBWarnings(value = "DB_DUPLICATE_BRANCHES", justification = "vendored")
public final class InflaterInputStream extends FilterInputStream {

/*---- Fields ----*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ private InputStream readHeader(InputStream is, int b0) throws IOException
if (b7 < 0)
throw new ZipException(Messages.GZIPInputStream2_TruncatedHeader);
crc.update(b7);
int mtime = (b4 & 0xff) | (b5 & 0xff) << 8 | (b6 & 0xff) << 16 | (b7 & 0xff) << 24;
long mjtime = mtime * 1000L;
// Parsing code,, we do not need timestamp but leave here for completeness
// int mtime = (b4 & 0xff) | (b5 & 0xff) << 8 | (b6 & 0xff) << 16 | (b7 & 0xff) << 24;
// long mjtime = mtime * 1000L;
// Extra flags
int b8 = is.read();
if (b8 < 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ private void dumpThreads() throws IOException
Long tid = thread2id.get(stack.threadSerialNr);
if (tid == null)
continue;
String threadId = tid == null ? "<unknown>" : "0x" + Long.toHexString(tid); //$NON-NLS-1$ //$NON-NLS-2$
String threadId = "0x" + Long.toHexString(tid); //$NON-NLS-1$ //$NON-NLS-2$
out.println("Thread " + threadId); //$NON-NLS-1$
out.println(stack);
out.println(" locals:"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,9 @@ public boolean hasNext()
*/
public static class IntIndexCollector extends IntIndex<ArrayIntCompressed> implements IOne2OneIndex
{
static final int pageSize = IndexWriter.PAGE_SIZE_INT;
final int mostSignificantBit;
final int size;
final int pageSize = IndexWriter.PAGE_SIZE_INT;
final ConcurrentHashMap<Integer, ArrayIntCompressed> pages = new ConcurrentHashMap<Integer, ArrayIntCompressed>();

/**
Expand Down Expand Up @@ -2192,9 +2192,9 @@ public boolean hasNext()
*/
public static class LongIndexCollector extends LongIndex
{
static final int pageSize = IndexWriter.PAGE_SIZE_LONG;
final int mostSignificantBit;
final int size;
final int pageSize = IndexWriter.PAGE_SIZE_LONG;
final ConcurrentHashMap<Integer, ArrayLongCompressed> pages = new ConcurrentHashMap<Integer, ArrayLongCompressed>();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class SnapshotImplBuilder
{
private XSnapshotInfo snapshotInfo;
/* package */HashMapIntObject<ClassImpl> classCache;
/* package */Map<String, List<IClass>> classCacheByName;
private HashMapIntObject<XGCRootInfo[]> roots;
private HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> rootsPerThread;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,14 @@ public boolean equals(Object o)
IResultTable irtb;
IResultTree irtr;
int index;
int subindex;
public RowMap(IStructuredResult irt, int index)
{
this(irt, index, -1);
}
public RowMap(IStructuredResult irt, int index, int subindex)
{
this.isr = irt;
if (isr instanceof IResultTable)
this.irtb = (IResultTable)irt;
if (isr instanceof IResultTree)
this.irtr = (IResultTree)irt;
this.index = index;
this.subindex = subindex;
}

@Override
Expand Down Expand Up @@ -2586,7 +2580,7 @@ else if (v != null && v.getClass().isArray())
for (int i = 0; i < maxlen; ++i)
{
int ix = i;
AbstractCustomTableResultSet.RowMap rm2 = new AbstractCustomTableResultSet.RowMap(result, rowobj.index, i) {
AbstractCustomTableResultSet.RowMap rm2 = new AbstractCustomTableResultSet.RowMap(result, rowobj.index) {
public Object get(Object key)
{
Object v = rowobj.get(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
package org.eclipse.mat.parser.internal.oql.compiler;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.AbstractList;
import java.util.ArrayList;
import java.lang.IllegalAccessException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -263,32 +266,15 @@ else if (element instanceof Expression)

return current;
}
catch (Exception e)
catch (IntrospectionException | IllegalAccessException | InvocationTargetException e)
{
throw SnapshotException.rethrow(e);
}
}

protected static List<?> asList(final Object element)
{
int size = Array.getLength(element);
final boolean wrap = true;
List<Object> answer;

if (wrap)
{
// Wrap the original array
answer = new ArrayWrapper(element);
}
else
{
// Make a copy of the array
answer = new ArrayList<Object>(size);
for (int ii = 0; ii < size; ii++)
answer.add(Array.get(element, ii));
}

return answer;
return new ArrayWrapper(element);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class ObjectMarker implements IObjectMarker
// inline = 50: 3.0 sec
// (previous impl, for reference, 5.1 sec)

final int LEVELS_RUN_INLINE = 4;
static final int LEVELS_RUN_INLINE = 4;

public ObjectMarker(int[] roots, boolean[] bits, IIndexReader.IOne2ManyIndex outbound,
IProgressListener progressListener)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ public void set(int index, int value)
off -= 0x8;
// Mask off old data
data[idx] &= ~((1 << varyingBits - off) - 1);
data[idx++] |= (byte) (value >>> off);
data[idx++] |= (byte) ((value >>> off) & 0xff);
while (off > 0x8)
{
off -= 0x8;
data[idx++] = (byte) (value >>> off);
data[idx++] = (byte) ((value >>> off) & 0xff);
}
}
// Mask off old data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public URL getIcon()
return icon;
}

public void setUsage(String usage)
public synchronized void setUsage(String usage)
{
this.usage = usage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static IResult execute(IQueryContext context, String commandLine, IProgre

QueryResult result = set.execute(listener);

return result != null ? result.getSubject() : null;
return result.getSubject();
}

public static ArgumentSet parse(IQueryContext context, String line) throws SnapshotException
Expand Down Expand Up @@ -254,9 +254,6 @@ private static Object consumeMultipleArguments(IQueryContext context, ArgumentDe
if (descriptor.isMandatory() && arguments.isEmpty())
throw error(descriptor);

if (arguments == null)
return null;

List<Object> values = new ArrayList<Object>(arguments.size());
for (String arg : arguments)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected IQuery createDelegate(IConfigurationElement configElement) throws Core
descriptor));

rootCategory = null;
return descriptor != null ? query : null;
return query;
}
catch (SnapshotException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public void setStatus(ITestResult.Status status)
this.status = status;
}

public List<Spec> getChildren()
public synchronized List<Spec> getChildren()
{
return children;
}

public void add(Spec child)
public synchronized void add(Spec child)
{
this.children.add(child);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*/
public final class SpecFactory extends RegistryReader<SpecFactory.Report>
{
public class Report
public static class Report
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is a breaking API change, WDYT?
org.eclipse.mat.report is one of the exported packages.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation. I think if one sets the API Baseline in Eclipse and then loads up the new code, it should show if there's an API breakage or not due to this.

{
String name;
String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import java.lang.ref.WeakReference;
import java.util.ArrayList;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public class CreateSampleDump
{

Expand All @@ -30,7 +32,7 @@ public static void main(String[] args) throws Exception
// Control-break causes read to return early, so try again for another key to wait
// for the dump to complete
if (c == -1)
c = System.in.read();
System.in.read();

System.out.println(dominatorTestData);
System.out.println(referenceTestData);
Expand Down Expand Up @@ -191,6 +193,7 @@ static class ReferenceTestData
clearedSoftReference = new SoftReference<byte[]>(lostSoftReference);

lostSoftReference = null;
@SuppressFBWarnings("UC_UCELESS_OBJECT")
ArrayList<byte[]> garbage = new ArrayList<byte[]>();
while (clearedSoftReference.get() != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public static ISnapshot getSnapshot(String dumpname, Map<String, String> options
}
return answer;
}
catch (Exception e)
catch (SnapshotException | IOException e)
{
throw new RuntimeException(e);
}
Expand Down
Loading
Loading