diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/FindLeaksQuery.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/FindLeaksQuery.java index 2b8a1f748..19e78269b 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/FindLeaksQuery.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/FindLeaksQuery.java @@ -165,22 +165,17 @@ private Histogram groupByClasses(int[] dominated, IProgressListener listener) th if (listener.isCanceled()) throw new IProgressListener.OperationCanceledException(); - Collection records = histogram.getClassHistogramRecords(); - ClassHistogramRecord[] arr = new ClassHistogramRecord[records.size()]; int i = 0; + Collection 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 loaderRecords = histogram.getClassLoaderHistogramRecords(); - ClassLoaderHistogramRecord[] loaderArr = new ClassLoaderHistogramRecord[loaderRecords.size()]; - i = 0; - for (ClassLoaderHistogramRecord record : loaderRecords) { long retainedSize = 0; @@ -190,7 +185,6 @@ private Histogram groupByClasses(int[] dominated, IProgressListener listener) th } record.setRetainedHeapSize(retainedSize); - loaderArr[i++] = record; } return histogram; diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/TopConsumersQuery.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/TopConsumersQuery.java index 62351c072..f8ef38516 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/TopConsumersQuery.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/TopConsumersQuery.java @@ -250,22 +250,15 @@ private Histogram groupByClasses(int[] dominated, IProgressListener listener) th throw new IProgressListener.OperationCanceledException(); Collection 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 loaderRecords = histogram.getClassLoaderHistogramRecords(); - ClassLoaderHistogramRecord[] loaderArr = new ClassLoaderHistogramRecord[loaderRecords.size()]; - i = 0; - for (ClassLoaderHistogramRecord record : loaderRecords) { if (listener.isCanceled()) @@ -278,7 +271,6 @@ private Histogram groupByClasses(int[] dominated, IProgressListener listener) th } record.setRetainedHeapSize(retainedSize); - loaderArr[i++] = record; } return histogram; diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/threads/ThreadInfoQuery.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/threads/ThreadInfoQuery.java index 63a2c27c3..7a96d358a 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/threads/ThreadInfoQuery.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/threads/ThreadInfoQuery.java @@ -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 infos = new ArrayList(); for (int[] ids : threadIds) { for (int id : ids) { - infos.add(processThread(id, spec, listener)); + processThread(id, spec, listener); } } diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/acquire/HeapDumpProviderRegistry.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/acquire/HeapDumpProviderRegistry.java index 420f60fd9..d9c841c01 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/acquire/HeapDumpProviderRegistry.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/acquire/HeapDumpProviderRegistry.java @@ -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) { diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/LinkedListCollectionExtractor.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/LinkedListCollectionExtractor.java index a7e8249ca..93c14ba55 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/LinkedListCollectionExtractor.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/LinkedListCollectionExtractor.java @@ -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; diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/MapCollectionExtractorBase.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/MapCollectionExtractorBase.java index b5398da92..0bd80fe8b 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/MapCollectionExtractorBase.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/internal/collectionextract/MapCollectionExtractorBase.java @@ -49,7 +49,7 @@ public Iterator> extractMapEntries(IObject coll) { try { - return new MapEntryIterator(coll.getSnapshot(), coll, extractEntryIds(coll)); + return new MapEntryIterator(coll.getSnapshot(), extractEntryIds(coll)); } catch (SnapshotException e) { @@ -62,14 +62,12 @@ private class MapEntryIterator implements Iterator> 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() diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/DominatorsSummary.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/DominatorsSummary.java index e004dbe24..30b09f6e7 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/DominatorsSummary.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/snapshot/DominatorsSummary.java @@ -97,8 +97,8 @@ public C[] getClassloaderDominatorRecords { classloaderDominatorRecords = load((Class) factoryClass); } + return (C[]) classloaderDominatorRecords; } - return (C[]) classloaderDominatorRecords; } private ClassloaderDominatorRecord[] load(Class factoryClass) diff --git a/plugins/org.eclipse.mat.hprof/src/io/nayuki/deflate/InflaterInputStream.java b/plugins/org.eclipse.mat.hprof/src/io/nayuki/deflate/InflaterInputStream.java index 9e1fb7a37..e88a1e164 100644 --- a/plugins/org.eclipse.mat.hprof/src/io/nayuki/deflate/InflaterInputStream.java +++ b/plugins/org.eclipse.mat.hprof/src/io/nayuki/deflate/InflaterInputStream.java @@ -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 ----*/ diff --git a/plugins/org.eclipse.mat.hprof/src/org/eclipse/mat/hprof/GZIPInputStream2.java b/plugins/org.eclipse.mat.hprof/src/org/eclipse/mat/hprof/GZIPInputStream2.java index 99723f1cf..918b91358 100644 --- a/plugins/org.eclipse.mat.hprof/src/org/eclipse/mat/hprof/GZIPInputStream2.java +++ b/plugins/org.eclipse.mat.hprof/src/org/eclipse/mat/hprof/GZIPInputStream2.java @@ -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) diff --git a/plugins/org.eclipse.mat.hprof/src/org/eclipse/mat/hprof/Pass1Parser.java b/plugins/org.eclipse.mat.hprof/src/org/eclipse/mat/hprof/Pass1Parser.java index 901a65232..002aee427 100644 --- a/plugins/org.eclipse.mat.hprof/src/org/eclipse/mat/hprof/Pass1Parser.java +++ b/plugins/org.eclipse.mat.hprof/src/org/eclipse/mat/hprof/Pass1Parser.java @@ -889,7 +889,7 @@ private void dumpThreads() throws IOException Long tid = thread2id.get(stack.threadSerialNr); if (tid == null) continue; - String threadId = tid == null ? "" : "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$ diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/index/IndexWriter.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/index/IndexWriter.java index 9130ebd68..e8ddc0512 100644 --- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/index/IndexWriter.java +++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/index/IndexWriter.java @@ -632,9 +632,9 @@ public boolean hasNext() */ public static class IntIndexCollector extends IntIndex 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 pages = new ConcurrentHashMap(); /** @@ -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 pages = new ConcurrentHashMap(); /** diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/SnapshotImplBuilder.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/SnapshotImplBuilder.java index 12c2dc624..4dd673093 100644 --- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/SnapshotImplBuilder.java +++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/SnapshotImplBuilder.java @@ -33,7 +33,6 @@ public class SnapshotImplBuilder { private XSnapshotInfo snapshotInfo; /* package */HashMapIntObject classCache; - /* package */Map> classCacheByName; private HashMapIntObject roots; private HashMapIntObject> rootsPerThread; diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/oql/OQLQueryImpl.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/oql/OQLQueryImpl.java index c36725085..0de8a3718 100644 --- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/oql/OQLQueryImpl.java +++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/oql/OQLQueryImpl.java @@ -189,12 +189,7 @@ 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) @@ -202,7 +197,6 @@ public RowMap(IStructuredResult irt, int index, int subindex) if (isr instanceof IResultTree) this.irtr = (IResultTree)irt; this.index = index; - this.subindex = subindex; } @Override @@ -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); diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/oql/compiler/PathExpression.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/oql/compiler/PathExpression.java index b6fd346b0..373ddc616 100644 --- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/oql/compiler/PathExpression.java +++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/oql/compiler/PathExpression.java @@ -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; @@ -263,7 +266,7 @@ else if (element instanceof Expression) return current; } - catch (Exception e) + catch (IntrospectionException | IllegalAccessException | InvocationTargetException e) { throw SnapshotException.rethrow(e); } @@ -271,24 +274,7 @@ else if (element instanceof Expression) protected static List asList(final Object element) { - int size = Array.getLength(element); - final boolean wrap = true; - List answer; - - if (wrap) - { - // Wrap the original array - answer = new ArrayWrapper(element); - } - else - { - // Make a copy of the array - answer = new ArrayList(size); - for (int ii = 0; ii < size; ii++) - answer.add(Array.get(element, ii)); - } - - return answer; + return new ArrayWrapper(element); } @Override diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/snapshot/ObjectMarker.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/snapshot/ObjectMarker.java index 089ef05bc..b3e156873 100644 --- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/snapshot/ObjectMarker.java +++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/internal/snapshot/ObjectMarker.java @@ -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) diff --git a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/collect/ArrayIntCompressed.java b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/collect/ArrayIntCompressed.java index 12768007f..983bc9439 100644 --- a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/collect/ArrayIntCompressed.java +++ b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/collect/ArrayIntCompressed.java @@ -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 diff --git a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/AnnotatedObjectDescriptor.java b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/AnnotatedObjectDescriptor.java index a03b8cfe9..547a2d5ea 100644 --- a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/AnnotatedObjectDescriptor.java +++ b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/AnnotatedObjectDescriptor.java @@ -79,7 +79,7 @@ public URL getIcon() return icon; } - public void setUsage(String usage) + public synchronized void setUsage(String usage) { this.usage = usage; } diff --git a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/CommandLine.java b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/CommandLine.java index acd552ab5..989595326 100644 --- a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/CommandLine.java +++ b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/CommandLine.java @@ -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 @@ -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 values = new ArrayList(arguments.size()); for (String arg : arguments) { diff --git a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/QueryRegistry.java b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/QueryRegistry.java index e16d8e967..871c35a83 100644 --- a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/QueryRegistry.java +++ b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/query/registry/QueryRegistry.java @@ -88,7 +88,7 @@ protected IQuery createDelegate(IConfigurationElement configElement) throws Core descriptor)); rootCategory = null; - return descriptor != null ? query : null; + return query; } catch (SnapshotException e) { diff --git a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/SectionSpec.java b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/SectionSpec.java index 82773a7d6..b85561217 100644 --- a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/SectionSpec.java +++ b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/SectionSpec.java @@ -48,12 +48,12 @@ public void setStatus(ITestResult.Status status) this.status = status; } - public List getChildren() + public synchronized List getChildren() { return children; } - public void add(Spec child) + public synchronized void add(Spec child) { this.children.add(child); } diff --git a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/SpecFactory.java b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/SpecFactory.java index 3b9804913..833e3dbf2 100644 --- a/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/SpecFactory.java +++ b/plugins/org.eclipse.mat.report/src/org/eclipse/mat/report/SpecFactory.java @@ -52,7 +52,7 @@ */ public final class SpecFactory extends RegistryReader { - public class Report + public static class Report { String name; String description; diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/CreateSampleDump.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/CreateSampleDump.java index 0e892111c..947fe26db 100644 --- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/CreateSampleDump.java +++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/CreateSampleDump.java @@ -16,6 +16,8 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + public class CreateSampleDump { @@ -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); @@ -191,6 +193,7 @@ static class ReferenceTestData clearedSoftReference = new SoftReference(lostSoftReference); lostSoftReference = null; + @SuppressFBWarnings("UC_UCELESS_OBJECT") ArrayList garbage = new ArrayList(); while (clearedSoftReference.get() != null) { diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/TestSnapshots.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/TestSnapshots.java index f2b45815d..7dcd80a6d 100644 --- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/TestSnapshots.java +++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/TestSnapshots.java @@ -193,7 +193,7 @@ public static ISnapshot getSnapshot(String dumpname, Map options } return answer; } - catch (Exception e) + catch (SnapshotException | IOException e) { throw new RuntimeException(e); } diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ConcurrentBitFieldTest.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ConcurrentBitFieldTest.java index 02b646f4a..d21327cc8 100644 --- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ConcurrentBitFieldTest.java +++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ConcurrentBitFieldTest.java @@ -220,18 +220,17 @@ public void randomizedAgainstBitSet() { break; case 2: - { - boolean exp = bs.get(idx); - boolean ret = bf.compareAndSet(idx, exp, !exp); - if (ret) bs.flip(idx); - } + boolean exp = bs.get(idx); + boolean ret = bf.compareAndSet(idx, exp, !exp); + if (ret) bs.flip(idx); break; case 3: - { - assertEquals(bs.get(idx), bf.get(idx)); - } + assertEquals(bs.get(idx), bf.get(idx)); break; + + default: + throw new IllegalStateException("rnd.nextInt returned >= 4"); } } diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ExtractCollectionEntriesTest2.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ExtractCollectionEntriesTest2.java index 3f942af17..cd811cf89 100644 --- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ExtractCollectionEntriesTest2.java +++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ExtractCollectionEntriesTest2.java @@ -83,7 +83,7 @@ public void testCollections1(ISnapshot snapshot, String onlyClass) throws Snapsh } if (onlyClass != null) { - assertThat("At least 1 object found"+(onlyClass != null ? " of type "+onlyClass : ""), objectsFound, greaterThanOrEqualTo(1)); + assertThat("At least 1 object found of type "+onlyClass, objectsFound, greaterThanOrEqualTo(1)); } } @@ -193,7 +193,7 @@ public void testCollections2(ISnapshot snapshot, String onlyClass) throws Snapsh } if (onlyClass != null) { - assertThat("At least 1 object found"+(onlyClass != null ? " of type "+onlyClass : ""), objectsFound, greaterThanOrEqualTo(1)); + assertThat("At least 1 object found of type "+onlyClass, objectsFound, greaterThanOrEqualTo(1)); } } @@ -225,7 +225,7 @@ public void testCollections3(ISnapshot snapshot, String onlyClass) throws Snapsh } if (onlyClass != null) { - assertThat("At least 1 object found"+(onlyClass != null ? " of type "+onlyClass : ""), objectsFound, greaterThanOrEqualTo(1)); + assertThat("At least 1 object found of type "+onlyClass, objectsFound, greaterThanOrEqualTo(1)); } } @@ -278,7 +278,7 @@ public void testCollections4(ISnapshot snapshot, String onlyClass) throws Snapsh } if (onlyClass != null) { - assertThat("At least 1 object found"+(onlyClass != null ? " of type "+onlyClass : ""), objectsFound, greaterThanOrEqualTo(1)); + assertThat("At least 1 object found of type "+onlyClass, objectsFound, greaterThanOrEqualTo(1)); } } @@ -367,7 +367,7 @@ public void testCollections6(ISnapshot snapshot, String onlyClass) throws Snapsh } if (onlyClass != null) { - assertThat("At least 1 object found"+(onlyClass != null ? " of type "+onlyClass : ""), objectsFound, greaterThanOrEqualTo(1)); + assertThat("At least 1 object found of type "+onlyClass, objectsFound, greaterThanOrEqualTo(1)); } } } diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/PrimitiveMapTests.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/PrimitiveMapTests.java index b3af8ba24..a68bbca28 100644 --- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/PrimitiveMapTests.java +++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/PrimitiveMapTests.java @@ -1063,7 +1063,7 @@ public void testObjectLongMapN() throws ClassNotFoundException, IOException * @param v the Integer to clone * @return probably a different Integer but equal to v */ - @SuppressFBWarnings("RC_REF_COMPARISON") + @SuppressFBWarnings(value = { "RC_REF_COMPARISON", "BX_UNBOXING_IMMEDIATELY_REBOXED" }) static Integer cloneInteger(Integer v) { Integer v1 = Integer.valueOf(v); @@ -1085,7 +1085,7 @@ static Integer cloneInteger(Integer v) * @param v the Long to clone * @return probably a different Long but equal to v */ - @SuppressFBWarnings("RC_REF_COMPARISON") + @SuppressFBWarnings(value = { "RC_REF_COMPARISON", "BX_UNBOXING_IMMEDIATELY_REBOXED" }) static Long cloneLong(Long v) { Long v1 = Long.valueOf(v); diff --git a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/panes/QueryResultPane.java b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/panes/QueryResultPane.java index cc82ff8dc..e049384a9 100644 --- a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/panes/QueryResultPane.java +++ b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/panes/QueryResultPane.java @@ -18,6 +18,7 @@ import java.util.Iterator; import java.util.List; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; @@ -265,7 +266,8 @@ protected void deactivateViewer() { boolean arrowKeyDown = false; int[] count = new int[1]; - + + @SuppressFBWarnings("SF_SWITCH_FALLTHROUGH") public void handleEvent(final Event e) { switch (e.type) diff --git a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/ArgumentsTable.java b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/ArgumentsTable.java index a78641f75..c5090dbbf 100644 --- a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/ArgumentsTable.java +++ b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/ArgumentsTable.java @@ -603,7 +603,7 @@ private void createHeapObjectRow(ArgumentDescriptor descriptor, String value, Te ISnapshot snapshot = (ISnapshot) context.get(ISnapshot.class, null); long addr = new BigInteger(value.substring(2), 16).longValue(); // Check address is valid - Integer ival = Integer.valueOf(snapshot.mapAddressToId(addr)); + Integer.valueOf(snapshot.mapAddressToId(addr)); // but set the hex value aec.setValue(value); } diff --git a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/LinkEditor.java b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/LinkEditor.java index b5c762bd2..d03113827 100644 --- a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/LinkEditor.java +++ b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/LinkEditor.java @@ -44,13 +44,11 @@ public String getModeType() } } - private Composite parent; private Mode mode; public LinkEditor(Composite parent, IQueryContext context, ArgumentDescriptor descriptor, TableItem item, Mode mode) { super(parent, context, descriptor, item); - this.parent = parent; this.mode = mode; createContents(); } diff --git a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/TextEditor.java b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/TextEditor.java index 10568654f..2f3667b01 100644 --- a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/TextEditor.java +++ b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/query/arguments/TextEditor.java @@ -36,7 +36,6 @@ public class TextEditor extends ArgumentEditor { protected Object value; protected Text text; - protected Composite parent; protected DecoratorType decorator; public enum DecoratorType @@ -82,7 +81,6 @@ public TextEditor(Composite parent, IQueryContext context, ArgumentDescriptor de { super(parent, context, descriptor, item); this.setBackground(parent.getBackground()); - this.parent = parent; this.decorator = decorator; createContents(); } diff --git a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/viewer/RefinedTreeViewer.java b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/viewer/RefinedTreeViewer.java index 6997544f5..248634d8f 100644 --- a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/viewer/RefinedTreeViewer.java +++ b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/viewer/RefinedTreeViewer.java @@ -198,8 +198,7 @@ private void doExpand(TreeItem parentItem) { if (parentCtrl.children == null) { - Thread t = new ReadDataThread(RefinedTreeViewer.this, parentCtrl, parentItem, parentItem.getData(), - false); + Thread t = new ReadDataThread(RefinedTreeViewer.this, parentCtrl, parentItem, parentItem.getData()); t.start(); try { @@ -234,15 +233,13 @@ static class ReadDataThread extends Thread ControlItem ctrl; TreeItem item; Object data; - boolean initial; - public ReadDataThread(RefinedResultViewer viewer, ControlItem ctrl, TreeItem item, Object data, boolean initial) + public ReadDataThread(RefinedResultViewer viewer, ControlItem ctrl, TreeItem item, Object data) { this.viewer = viewer; this.ctrl = ctrl; this.item = item; this.data = data; - this.initial = initial; } @Override diff --git a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/editor/HeapEditorContributions.java b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/editor/HeapEditorContributions.java index 6efb15be3..8d44bea24 100644 --- a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/editor/HeapEditorContributions.java +++ b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/editor/HeapEditorContributions.java @@ -29,7 +29,6 @@ public class HeapEditorContributions implements IMultiPaneEditorContributor { - HeapEditor editor; Action openOverview; Action openHistogram; Action openDominatorTree; @@ -63,7 +62,6 @@ public void dispose() public void init(MultiPaneEditor editor) { - this.editor = (HeapEditor) editor; openOverview = new OpenPaneAction(editor, "OverviewPane"); //$NON-NLS-1$ openOverview.setImageDescriptor(MemoryAnalyserPlugin .getImageDescriptor(MemoryAnalyserPlugin.ISharedImages.INFO)); diff --git a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/inspector/LazyFields.java b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/inspector/LazyFields.java index 9d13ee966..63a347ff9 100644 --- a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/inspector/LazyFields.java +++ b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/inspector/LazyFields.java @@ -34,7 +34,6 @@ private WeakReference snapshot; private WeakReference array; - private int objectId; private long objectAddr; protected List cache = new ArrayList();