tmf: Switch tmf.core to Java 7 + fix warnings
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 17 Dec 2013 21:44:44 +0000 (16:44 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 19 Dec 2013 20:16:37 +0000 (15:16 -0500)
Change-Id: I32fb093edb6bf70fdbe9a5ad1a9c8239a1e9ed05
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/19927
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Hudson CI
IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com>

52 files changed:
org.eclipse.linuxtools.tmf.core/.classpath
org.eclipse.linuxtools.tmf.core/.settings/org.eclipse.jdt.core.prefs
org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/analysis/TmfAnalysisType.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/component/TmfProviderManager.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedEventRequest.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfRequestExecutor.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/Attribute.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/AttributeTree.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/StateSystem.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/TransientState.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/InMemoryBackend.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HTNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HistoryTree.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/ThreadedHistoryTreeBackend.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/mipmap/AbstractTmfMipmapStateProvider.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/mipmap/TmfMipmapFeature.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/indexer/BTreeNodeCache.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/indexer/TmfMemoryIndex.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisManager.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfEventProvider.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIteratorManager.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventFactory.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventTypeManager.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/matching/TmfEventMatches.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/matching/TmfEventMatching.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/matching/TmfNetworkEventMatching.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterCompareNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEventTypeNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterMatchesNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/xml/TmfFilterContentHandler.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/signal/TmfSignalManager.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/AbstractTmfStateProvider.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/TmfStateSystemAnalysisModule.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/TmfStateSystemOperations.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statistics/TmfEventsStatistics.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statistics/TmfStateStatistics.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/synchronization/SyncAlgorithmFullyIncremental.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/synchronization/SynchronizationBackend.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimePreferences.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimestampFormat.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTraceManager.java

index ad32c83a7885b8953a938b41df3b4fd4fe1aae01..098194ca4b7d8f45177f94e735506ae3a26b5c94 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="output" path="bin"/>
index 4a0ac9dbf405132dc1ff2a51202cc9b027a7cf9b..ca286c1897fb75dd2376b9b24edd76d55794fc45 100644 (file)
@@ -6,9 +6,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota
 org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
 org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.compliance=1.7
 org.eclipse.jdt.core.compiler.debug.lineNumber=generate
 org.eclipse.jdt.core.compiler.debug.localVariable=generate
 org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -24,7 +24,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=
 org.eclipse.jdt.core.compiler.problem.discouragedReference=error
 org.eclipse.jdt.core.compiler.problem.emptyStatement=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=error
 org.eclipse.jdt.core.compiler.problem.fallthroughCase=error
 org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
 org.eclipse.jdt.core.compiler.problem.fieldHiding=error
@@ -75,7 +75,7 @@ org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
 org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
 org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
 org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=error
 org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
 org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
 org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=error
@@ -110,7 +110,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
 org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
 org.eclipse.jdt.core.compiler.problem.unusedWarningToken=error
 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.7
 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
index 151937282e3fd73a9e6ec289e54260f1833eed95..1ce0fe7d67ac8cd46323a5213b948f294fc429cd 100644 (file)
@@ -7,7 +7,7 @@ Bundle-Localization: plugin
 Bundle-SymbolicName: org.eclipse.linuxtools.tmf.core;singleton:=true
 Bundle-Activator: org.eclipse.linuxtools.internal.tmf.core.Activator
 Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.core.resources,
  org.eclipse.linuxtools.ctf.core;bundle-version="3.0.0"
index 3a5a78aace3b914dca599c06ae8b5020ce5eebc7..757d90786cebba47a679e1742779485dbb45279a 100644 (file)
@@ -71,7 +71,7 @@ public final class TmfAnalysisType {
      * The mapping of available trace type IDs to their corresponding
      * configuration element
      */
-    private final Map<String, IAnalysisModuleHelper> fAnalysisTypeAttributes = new HashMap<String, IAnalysisModuleHelper>();
+    private final Map<String, IAnalysisModuleHelper> fAnalysisTypeAttributes = new HashMap<>();
 
     private static TmfAnalysisType fInstance = null;
 
@@ -84,7 +84,7 @@ public final class TmfAnalysisType {
     public static IConfigurationElement[] getTypeElements() {
         IConfigurationElement[] elements =
                 Platform.getExtensionRegistry().getConfigurationElementsFor(TMF_ANALYSIS_TYPE_ID);
-        List<IConfigurationElement> typeElements = new LinkedList<IConfigurationElement>();
+        List<IConfigurationElement> typeElements = new LinkedList<>();
         for (IConfigurationElement element : elements) {
             if (element.getName().equals(MODULE_ELEM)) {
                 typeElements.add(element);
index 63d7d4376d85297f6dd66418e703f48c93012714..b07783dea126c5c38a493a31df0312100824e2ba 100644 (file)
@@ -40,7 +40,7 @@ public class TmfProviderManager {
     // ------------------------------------------------------------------------
 
     private static Map<Class<? extends ITmfEvent>, List<TmfEventProvider>> fProviders =
-            new HashMap<Class<? extends ITmfEvent>, List<TmfEventProvider>>();
+            new HashMap<>();
 
     /**
      * Registers [provider] as a provider of [eventType]
@@ -85,7 +85,7 @@ public class TmfProviderManager {
     public static TmfEventProvider[] getProviders(Class<? extends ITmfEvent> eventType) {
         List<TmfEventProvider> list = fProviders.get(eventType);
         if (list == null) {
-            list = new ArrayList<TmfEventProvider>();
+            list = new ArrayList<>();
         }
         TmfEventProvider[] result = new TmfEventProvider[list.size()];
         return list.toArray(result);
@@ -107,7 +107,7 @@ public class TmfProviderManager {
             return getProviders(eventType);
         }
         TmfEventProvider[] list = getProviders(eventType);
-        List<TmfEventProvider> result = new ArrayList<TmfEventProvider>();
+        List<TmfEventProvider> result = new ArrayList<>();
         if (list != null) {
             for (TmfEventProvider provider : list) {
                 if (provider.getClass() == providerType) {
index 5b1c5688cbde9dc53cfa86be4f9351a589b23431..91d787cdffcb0ea2a7d2cf838d6063638e1ba7a1 100644 (file)
@@ -36,7 +36,7 @@ public class TmfCoalescedEventRequest extends TmfEventRequest {
     // ------------------------------------------------------------------------
 
     /** The list of coalesced requests */
-    private final List<ITmfEventRequest> fRequests = new ArrayList<ITmfEventRequest>();
+    private final List<ITmfEventRequest> fRequests = new ArrayList<>();
 
     /**
      * We do not use super.fRange, because in the case of coalesced requests,
index d62fcb7d1ae54edad80d2632dc8f5b28ccce49ee..b3d9028942306ad5c9fabd2b79e756c80032874d 100644 (file)
@@ -56,8 +56,8 @@ public class TmfRequestExecutor implements Executor {
     private final String fExecutorName;
 
     // The request queues
-    private final Queue<TmfEventThread> fForegroundTasks = new ArrayBlockingQueue<TmfEventThread>(100);
-    private final Queue<TmfEventThread> fBackgroundTasks = new ArrayBlockingQueue<TmfEventThread>(100);
+    private final Queue<TmfEventThread> fForegroundTasks = new ArrayBlockingQueue<>(100);
+    private final Queue<TmfEventThread> fBackgroundTasks = new ArrayBlockingQueue<>(100);
 
     // The tasks
     private TmfEventThread fActiveTask;
index 093615b481b089d49552ad441a3075f237079305..fec8dc4c1fe416b17a329c31cf927f25b13c6b0a 100644 (file)
@@ -44,7 +44,7 @@ abstract class Attribute {
         this.parent = parent;
         this.quark = quark;
         this.name = name;
-        this.subAttributes = new ArrayList<Attribute>();
+        this.subAttributes = new ArrayList<>();
     }
 
     /**
@@ -118,7 +118,7 @@ abstract class Attribute {
      * @return
      */
     String[] getFullAttribute() {
-        LinkedList<String> list = new LinkedList<String>();
+        LinkedList<String> list = new LinkedList<>();
         Attribute curNode = this;
 
         /* Add recursive parents to the list, but stop at the root node */
@@ -200,7 +200,7 @@ final class AlphaNumAttribute extends Attribute {
 
     AlphaNumAttribute(Attribute parent, String name, int quark) {
         super(parent, name, quark);
-        this.subAttributesMap = new HashMap<String, Integer>();
+        this.subAttributesMap = new HashMap<>();
     }
 
     @Override
index 88f9c5f5faea56959a0afc1b62d5ecf2687ae725..73ced1eec2a04bb98cea4f3e5adf83881568cafc 100644 (file)
@@ -70,7 +70,7 @@ public final class AttributeTree {
         /* Message for exceptions, shouldn't be externalized */
         final String errorMessage = "The attribute tree file section is either invalid or corrupted."; //$NON-NLS-1$
 
-        ArrayList<String[]> list = new ArrayList<String[]>();
+        ArrayList<String[]> list = new ArrayList<>();
         byte[] curByteArray;
         String curFullString;
         String[] curStringArray;
@@ -143,12 +143,10 @@ public final class AttributeTree {
      * @return The total number of bytes written.
      */
     int writeSelf(File file, long pos) {
-        RandomAccessFile raf = null;
         int total = 0;
         byte[] curByteArray;
 
-        try {
-            raf = new RandomAccessFile(file, "rw"); //$NON-NLS-1$
+        try (RandomAccessFile raf = new RandomAccessFile(file, "rw");) { //$NON-NLS-1$
             raf.seek(pos);
 
             /* Write the almost-magic number */
@@ -186,14 +184,6 @@ public final class AttributeTree {
 
         } catch (IOException e) {
             e.printStackTrace();
-        } finally {
-            if (raf != null) {
-                try {
-                    raf.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
         }
         return total;
     }
@@ -329,7 +319,7 @@ public final class AttributeTree {
      */
     List<Integer> getSubAttributes(int attributeQuark, boolean recursive)
             throws AttributeNotFoundException {
-        List<Integer> listOfChildren = new ArrayList<Integer>();
+        List<Integer> listOfChildren = new ArrayList<>();
         Attribute startingAttribute;
 
         /* Check if the quark is valid */
index eb368500ca0d3efacb8d7ba97f0d59389e939e11..4a27539e688f383e5b2366d885404f31bcccd989 100644 (file)
@@ -235,9 +235,9 @@ public class StateSystem implements ITmfStateSystemBuilder {
 
     @Override
     public List<Integer> getQuarks(String... pattern) {
-        List<Integer> quarks = new LinkedList<Integer>();
-        List<String> prefix = new LinkedList<String>();
-        List<String> suffix = new LinkedList<String>();
+        List<Integer> quarks = new LinkedList<>();
+        List<String> prefix = new LinkedList<>();
+        List<String> suffix = new LinkedList<>();
         boolean split = false;
         String[] prefixStr;
         String[] suffixStr;
@@ -506,7 +506,7 @@ public class StateSystem implements ITmfStateSystemBuilder {
             throw new StateSystemDisposedException();
         }
 
-        List<ITmfStateInterval> stateInfo = new ArrayList<ITmfStateInterval>(getNbAttributes());
+        List<ITmfStateInterval> stateInfo = new ArrayList<>(getNbAttributes());
 
         /* Bring the size of the array to the current number of attributes */
         for (int i = 0; i < getNbAttributes(); i++) {
@@ -611,7 +611,7 @@ public class StateSystem implements ITmfStateSystemBuilder {
         }
 
         /* Get the initial state at time T1 */
-        intervals = new ArrayList<ITmfStateInterval>();
+        intervals = new ArrayList<>();
         currentInterval = querySingleState(t1, attributeQuark);
         intervals.add(currentInterval);
 
@@ -657,7 +657,7 @@ public class StateSystem implements ITmfStateSystemBuilder {
         }
 
         /* Get the initial state at time T1 */
-        intervals = new ArrayList<ITmfStateInterval>();
+        intervals = new ArrayList<>();
         currentInterval = querySingleState(t1, attributeQuark);
         intervals.add(currentInterval);
 
index 276446c80c5198c1731df6b674dc1f5036089c13..84bfb247473483351b0d3d3b6b123e88cbf64715 100644 (file)
@@ -54,9 +54,9 @@ class TransientState {
     TransientState(IStateHistoryBackend backend) {
         this.backend = backend;
         isActive = true;
-        ongoingStateInfo = new ArrayList<ITmfStateValue>();
-        ongoingStateStartTimes = new ArrayList<Long>();
-        stateValueTypes = new ArrayList<Type>();
+        ongoingStateInfo = new ArrayList<>();
+        ongoingStateStartTimes = new ArrayList<>();
+        stateValueTypes = new ArrayList<>();
 
         if (backend != null) {
             latestTime = backend.getStartTime();
@@ -117,9 +117,9 @@ class TransientState {
      */
     synchronized void replaceOngoingState(List<ITmfStateInterval> newStateIntervals) {
         int size = newStateIntervals.size();
-        ongoingStateInfo = new ArrayList<ITmfStateValue>(size);
-        ongoingStateStartTimes = new ArrayList<Long>(size);
-        stateValueTypes = new ArrayList<Type>(size);
+        ongoingStateInfo = new ArrayList<>(size);
+        ongoingStateStartTimes = new ArrayList<>(size);
+        stateValueTypes = new ArrayList<>(size);
 
         for (ITmfStateInterval interval : newStateIntervals) {
             ongoingStateInfo.add(interval.getStateValue());
index 61d999613e8d0f33bb00d98f4fea8129e4366596..5777826c7518c4067aef1687d984f8b027c72f46 100644 (file)
@@ -83,7 +83,7 @@ public class InMemoryBackend implements IStateHistoryBackend {
     public InMemoryBackend(long startTime) {
         this.startTime = startTime;
         this.latestTime = startTime;
-        this.intervals = new TreeSet<ITmfStateInterval>(END_COMPARATOR);
+        this.intervals = new TreeSet<>(END_COMPARATOR);
     }
 
     @Override
index 2a06d2d116800cf67f90ce632fb59aad2dd77169..d2eca6af6af918bb1bc882bf9410c8ad9ef9e723 100644 (file)
@@ -70,7 +70,7 @@ abstract class HTNode {
 
         this.stringSectionOffset = config.getBlockSize();
         this.isDone = false;
-        this.intervals = new ArrayList<HTInterval>();
+        this.intervals = new ArrayList<>();
     }
 
     /**
index 9faa62b36bd77e21244e3abb16972104da19b87c..576a2d4e7b989998114e0442e96c102ad62bf785 100644 (file)
@@ -91,7 +91,7 @@ class HistoryTree {
         config = conf;
         treeEnd = conf.getTreeStart();
         nodeCount = 0;
-        latestBranch = new ArrayList<CoreNode>();
+        latestBranch = new ArrayList<>();
 
         /* Prepare the IO object */
         treeIO = new HT_IO(config, true);
@@ -128,57 +128,53 @@ class HistoryTree {
             throw new IOException("Empty target file"); //$NON-NLS-1$
         }
 
-        FileInputStream fis = new FileInputStream(existingStateFile);
-        ByteBuffer buffer = ByteBuffer.allocate(TREE_HEADER_SIZE);
-        FileChannel fc = fis.getChannel();
-        buffer.order(ByteOrder.LITTLE_ENDIAN);
-        buffer.clear();
-        fc.read(buffer);
-        buffer.flip();
+        try (FileInputStream fis = new FileInputStream(existingStateFile);
+                FileChannel fc = fis.getChannel();) {
 
-        /*
-         * Check the magic number to make sure we're opening the right type of
-         * file
-         */
-        res = buffer.getInt();
-        if (res != HISTORY_FILE_MAGIC_NUMBER) {
-            fc.close();
-            fis.close();
-            throw new IOException("Wrong magic number"); //$NON-NLS-1$
-        }
+            ByteBuffer buffer = ByteBuffer.allocate(TREE_HEADER_SIZE);
 
-        res = buffer.getInt(); /* File format version number */
-        if (res != FILE_VERSION) {
-            fc.close();
-            fis.close();
-            throw new IOException("Mismatching History Tree file format versions"); //$NON-NLS-1$
-        }
+            buffer.order(ByteOrder.LITTLE_ENDIAN);
+            buffer.clear();
+            fc.read(buffer);
+            buffer.flip();
 
-        res = buffer.getInt(); /* Event handler's version number */
-        if (res != expProviderVersion &&
-                expProviderVersion != ITmfStateProvider.IGNORE_PROVIDER_VERSION) {
             /*
-             * The existing history was built using an event handler that doesn't
-             * match the current one in the framework.
-             *
-             * Information could be all wrong. Instead of keeping an incorrect
-             * history file, a rebuild is done.
+             * Check the magic number to make sure we're opening the right type
+             * of file
              */
-            fc.close();
-            fis.close();
-            throw new IOException("Mismatching event handler versions"); //$NON-NLS-1$
-        }
+            res = buffer.getInt();
+            if (res != HISTORY_FILE_MAGIC_NUMBER) {
+                throw new IOException("Wrong magic number"); //$NON-NLS-1$
+            }
 
-        bs = buffer.getInt(); /* Block Size */
-        maxc = buffer.getInt(); /* Max nb of children per node */
+            res = buffer.getInt(); /* File format version number */
+            if (res != FILE_VERSION) {
+                throw new IOException("Mismatching History Tree file format versions"); //$NON-NLS-1$
+            }
 
-        this.nodeCount = buffer.getInt();
-        rootNodeSeqNb = buffer.getInt();
-        startTime = buffer.getLong();
+            res = buffer.getInt(); /* Event handler's version number */
+            if (res != expProviderVersion &&
+                    expProviderVersion != ITmfStateProvider.IGNORE_PROVIDER_VERSION) {
+                /*
+                 * The existing history was built using an event handler that
+                 * doesn't match the current one in the framework.
+                 *
+                 * Information could be all wrong. Instead of keeping an
+                 * incorrect history file, a rebuild is done.
+                 */
+                throw new IOException("Mismatching event handler versions"); //$NON-NLS-1$
+            }
+
+            bs = buffer.getInt(); /* Block Size */
+            maxc = buffer.getInt(); /* Max nb of children per node */
+
+            this.nodeCount = buffer.getInt();
+            rootNodeSeqNb = buffer.getInt();
+            startTime = buffer.getLong();
+
+            this.config = new HTConfig(existingStateFile, bs, maxc, expProviderVersion, startTime);
+        }
 
-        this.config = new HTConfig(existingStateFile, bs, maxc, expProviderVersion, startTime);
-        fc.close();
-        fis.close();
         /*
          * FIXME We close fis here and the TreeIO will then reopen the same
          * file, not extremely elegant. But how to pass the information here to
@@ -194,8 +190,6 @@ class HistoryTree {
          * with was is actually in the root node.
          */
         if (startTime != latestBranch.get(0).getNodeStart()) {
-            fc.close();
-            fis.close();
             throw new IOException("Inconsistent start times in the" + //$NON-NLS-1$
                     "history file, it might be corrupted."); //$NON-NLS-1$
         }
@@ -211,7 +205,6 @@ class HistoryTree {
      *            The greatest timestamp present in the history tree
      */
     void closeTree(long requestedEndTime) {
-        FileChannel fc;
         ByteBuffer buffer;
         int i, res;
 
@@ -230,13 +223,12 @@ class HistoryTree {
             treeIO.writeNode(latestBranch.get(i));
         }
 
-        fc = treeIO.getFcOut();
-        buffer = ByteBuffer.allocate(TREE_HEADER_SIZE);
-        buffer.order(ByteOrder.LITTLE_ENDIAN);
-        buffer.clear();
+        try (FileChannel fc = treeIO.getFcOut();) {
+            buffer = ByteBuffer.allocate(TREE_HEADER_SIZE);
+            buffer.order(ByteOrder.LITTLE_ENDIAN);
+            buffer.clear();
 
-        /* Save the config of the tree to the header of the file */
-        try {
+            /* Save the config of the tree to the header of the file */
             fc.position(0);
 
             buffer.putInt(HISTORY_FILE_MAGIC_NUMBER);
@@ -261,12 +253,12 @@ class HistoryTree {
             /* done writing the file header */
 
         } catch (IOException e) {
-            /* We should not have any problems at this point... */
-        } finally {
-            try {
-                fc.close();
-            } catch (IOException e) {
-            }
+            /*
+             * If we were able to write so far, there should not be any problem
+             * at this point...
+             */
+            // FIXME still, the IOException should be propagated upwards
+            throw new RuntimeException();
         }
         return;
     }
@@ -353,7 +345,7 @@ class HistoryTree {
     private void rebuildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException {
         HTNode nextChildNode;
 
-        this.latestBranch = new ArrayList<CoreNode>();
+        this.latestBranch = new ArrayList<>();
 
         nextChildNode = treeIO.readNode(rootNodeSeqNb);
         latestBranch.add((CoreNode) nextChildNode);
@@ -486,7 +478,7 @@ class HistoryTree {
 
         /* Rebuild a new latestBranch */
         depth = latestBranch.size();
-        latestBranch = new ArrayList<CoreNode>();
+        latestBranch = new ArrayList<>();
         latestBranch.add(newRootNode);
         for (i = 1; i < depth + 1; i++) {
             prevNode = latestBranch.get(i - 1);
index fd3e939cee96c47c7df578efd1966ae00294176e..4c1695fcc98e4065c038fa1591d3cf734e25dbdf 100644 (file)
@@ -66,7 +66,7 @@ public final class ThreadedHistoryTreeBackend extends HistoryTreeBackend
                     throws IOException {
         super(newStateFile, blockSize, maxChildren, providerVersion, startTime);
 
-        intervalQueue = new ArrayBlockingQueue<HTInterval>(queueSize);
+        intervalQueue = new ArrayBlockingQueue<>(queueSize);
         shtThread = new Thread(this, "History Tree Thread"); //$NON-NLS-1$
         shtThread.start();
     }
@@ -94,7 +94,7 @@ public final class ThreadedHistoryTreeBackend extends HistoryTreeBackend
             int providerVersion, int queueSize) throws IOException {
         super(newStateFile, providerVersion, startTime);
 
-        intervalQueue = new ArrayBlockingQueue<HTInterval>(queueSize);
+        intervalQueue = new ArrayBlockingQueue<>(queueSize);
         shtThread = new Thread(this, "History Tree Thread"); //$NON-NLS-1$
         shtThread.start();
     }
index 4a978b17e0a4033a81f1989b2fa663e234cbe832..bd379548090345508d18e16236963b51719c4c8f 100644 (file)
@@ -70,8 +70,7 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
     private final IStateHistoryBackend innerHistory;
 
     /** Checkpoints map, <Timestamp, Rank in the trace> */
-    private final TreeMap<Long, Long> checkpoints =
-            new TreeMap<Long, Long>();
+    private final TreeMap<Long, Long> checkpoints = new TreeMap<>();
 
     /** Latch tracking if the initial checkpoint registration is done */
     private final CountDownLatch checkpointsReady = new CountDownLatch(1);
index a83d6bb981c764231cc25b46d06fd875b098a650..859bb933afb77d57468a210160fbdbe2b7874dbf 100644 (file)
@@ -75,7 +75,7 @@ public abstract class AbstractTmfMipmapStateProvider extends AbstractTmfStatePro
     /**
      * Map of mipmap features per attribute. The map's key is the base attribute quark.
      */
-    private Map<Integer, Set<ITmfMipmapFeature>> featureMap = new HashMap<Integer, Set<ITmfMipmapFeature>>();
+    private Map<Integer, Set<ITmfMipmapFeature>> featureMap = new HashMap<>();
 
     // ------------------------------------------------------------------------
     // Constructor
@@ -161,7 +161,7 @@ public abstract class AbstractTmfMipmapStateProvider extends AbstractTmfStatePro
         if (features != null) {
             return features;
         }
-        features = new LinkedHashSet<ITmfMipmapFeature>();
+        features = new LinkedHashSet<>();
         if (value.isNull()) {
             return features;
         }
index d687e7cd2ed0bd54ff2235ffb9000cff798972eb..8942f40e668b5ea8cf22221aa580bc0592b56bd3 100644 (file)
@@ -38,13 +38,13 @@ public abstract class TmfMipmapFeature implements ITmfMipmapFeature {
     /** The current start time for the state value */
     protected long currentStartTime;
     /** The list of ongoing state intervals per mipmap level */
-    protected List<List<ITmfStateInterval>> intervals = new ArrayList<List<ITmfStateInterval>>();
+    protected List<List<ITmfStateInterval>> intervals = new ArrayList<>();
     /** The state system used to store the mipmap attributes */
     protected ITmfStateSystemBuilder ss;
 
     private int mipmapResolution;
     private int mipmapQuark;
-    private List<Integer> levelQuarks = new ArrayList<Integer>();
+    private List<Integer> levelQuarks = new ArrayList<>();
 
     /**
      * Constructor
index c03ba077cf9b51fe7ba245fbcef03ce66c79d611..a0b8488564fb1547b646f7c2f90a7d0fcbd4f57f 100644 (file)
@@ -42,7 +42,7 @@ public class BTreeNodeCache {
      * kept at the front of the double-ended queue and the least recently used
      * node is kept at the back.
      */
-    private final Deque<BTreeNode> fCachedNodes = new ArrayDeque<BTreeNode>(CACHE_SIZE);
+    private final Deque<BTreeNode> fCachedNodes = new ArrayDeque<>(CACHE_SIZE);
 
     private int fCcheMisses = 0;
 
index 03fbcb29721265987de05e5ad776acd8c5bbf0e4..62ad4ff762ff82af7cfcf53ddf5870fbe23e6093 100644 (file)
@@ -37,7 +37,7 @@ public class TmfMemoryIndex implements ITmfCheckpointIndex, ICheckpointCollectio
      * @param trace the trace
      */
     public TmfMemoryIndex(ITmfTrace trace) {
-        fCheckpoints = new ArrayList<ITmfCheckpoint>();
+        fCheckpoints = new ArrayList<>();
     }
 
     @Override
index 1e35af30731d69e36c0da9cae9b09542a181c333..116f268825aaedbf9402f98c112f2b853821c4c7 100644 (file)
@@ -46,10 +46,10 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
     private String fName, fId;
     private boolean fAutomatic = false, fStarted = false;
     private ITmfTrace fTrace;
-    private final Map<String, Object> fParameters = new HashMap<String, Object>();
-    private final List<String> fParameterNames = new ArrayList<String>();
-    private final List<IAnalysisOutput> fOutputs = new ArrayList<IAnalysisOutput>();
-    private List<IAnalysisParameterProvider> fParameterProviders = new ArrayList<IAnalysisParameterProvider>();
+    private final Map<String, Object> fParameters = new HashMap<>();
+    private final List<String> fParameterNames = new ArrayList<>();
+    private final List<IAnalysisOutput> fOutputs = new ArrayList<>();
+    private List<IAnalysisParameterProvider> fParameterProviders = new ArrayList<>();
     private Job fJob = null;
 
     private final Object syncObj = new Object();
index 9569bdae400b9fa6d09d96f1cd9c6a3a96f052a5..20fdfe421a60327a05260915b11786f8eddc8e4e 100644 (file)
@@ -34,9 +34,9 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
  */
 public class TmfAnalysisManager {
 
-    private static final Map<String, IAnalysisModuleHelper> fAnalysisModules = new HashMap<String, IAnalysisModuleHelper>();
-    private static final Map<String, List<Class<? extends IAnalysisParameterProvider>>> fParameterProviders = new HashMap<String, List<Class<? extends IAnalysisParameterProvider>>>();
-    private static final Map<Class<? extends IAnalysisParameterProvider>, IAnalysisParameterProvider> fParamProviderInstances = new HashMap<Class<? extends IAnalysisParameterProvider>, IAnalysisParameterProvider>();
+    private static final Map<String, IAnalysisModuleHelper> fAnalysisModules = new HashMap<>();
+    private static final Map<String, List<Class<? extends IAnalysisParameterProvider>>> fParameterProviders = new HashMap<>();
+    private static final Map<Class<? extends IAnalysisParameterProvider>, IAnalysisParameterProvider> fParamProviderInstances = new HashMap<>();
 
     /**
      * Gets all available analysis module helpers
@@ -66,7 +66,7 @@ public class TmfAnalysisManager {
      */
     public static Map<String, IAnalysisModuleHelper> getAnalysisModules(Class<? extends ITmfTrace> traceclass) {
         Map<String, IAnalysisModuleHelper> allModules = getAnalysisModules();
-        Map<String, IAnalysisModuleHelper> map = new HashMap<String, IAnalysisModuleHelper>();
+        Map<String, IAnalysisModuleHelper> map = new HashMap<>();
         for (IAnalysisModuleHelper module : allModules.values()) {
             if (module.appliesToTraceType(traceclass)) {
                 map.put(module.getId(), module);
@@ -114,7 +114,7 @@ public class TmfAnalysisManager {
      * @return A parameter provider if one applies to the trace, null otherwise
      */
     public static List<IAnalysisParameterProvider> getParameterProviders(IAnalysisModule module, ITmfTrace trace) {
-        List<IAnalysisParameterProvider> providerList = new ArrayList<IAnalysisParameterProvider>();
+        List<IAnalysisParameterProvider> providerList = new ArrayList<>();
         synchronized (fParameterProviders) {
             if (!fParameterProviders.containsKey(module.getId())) {
                 return providerList;
index 5d1a6783d7fd1140cbb59a9ae4c41bafbfa32a10..0716386a1d7487137a86ecc24693843b124e9d58 100644 (file)
@@ -64,8 +64,7 @@ public abstract class TmfEventProvider extends TmfComponent implements ITmfEvent
 
     /** List of coalesced requests
      * @since 3.0*/
-    protected final List<TmfCoalescedEventRequest> fPendingCoalescedRequests =
-            new ArrayList<TmfCoalescedEventRequest>();
+    protected final List<TmfCoalescedEventRequest> fPendingCoalescedRequests = new ArrayList<>();
 
     /** The type of event handled by this provider
      * @since 3.0*/
@@ -97,7 +96,7 @@ public abstract class TmfEventProvider extends TmfComponent implements ITmfEvent
     public TmfEventProvider() {
         super();
         fQueueSize = DEFAULT_QUEUE_SIZE;
-        fDataQueue = new LinkedBlockingQueue<ITmfEvent>(fQueueSize);
+        fDataQueue = new LinkedBlockingQueue<>(fQueueSize);
         fExecutor = new TmfRequestExecutor();
     }
 
index afe436d121147c2250679ceb75ee3c5233ed8b20..5ebd93406eedd1be1c91f63ce117fda47d1db498 100644 (file)
@@ -33,7 +33,7 @@ public abstract class CtfIteratorManager {
     /*
      * The map of traces to trace managers.
      */
-    private static HashMap<CtfTmfTrace, CtfTraceManager> map = new HashMap<CtfTmfTrace, CtfTraceManager>();
+    private static HashMap<CtfTmfTrace, CtfTraceManager> map = new HashMap<>();
 
     /**
      * Registers a trace to the iterator manager, the trace can now get
@@ -120,8 +120,8 @@ class CtfTraceManager {
     private final Random fRnd;
 
     public CtfTraceManager(CtfTmfTrace trace) {
-        fMap = new HashMap<CtfTmfContext, CtfIterator>();
-        fRandomAccess = new ArrayList<CtfTmfContext>();
+        fMap = new HashMap<>();
+        fRandomAccess = new ArrayList<>();
         fRnd = new Random(System.nanoTime());
         fTrace = trace;
     }
index 2265ce91e7f341e5db2d372e0145483a0a9362d0..59423d37be0e26525316809cebe48e3080a1716e 100644 (file)
@@ -158,7 +158,7 @@ public class CtfTmfEvent extends TmfEvent
     @Override
     public Set<String> listCustomAttributes() {
         if (fDeclaration == null) {
-            return new HashSet<String>();
+            return new HashSet<>();
         }
         return fDeclaration.getCustomAttributes();
     }
index fc8b905f31b55bc6358d11a747023c833c26e7ab..a7832ca99616d4c5e1bbfcd8223b86e6bfa8cbd4 100644 (file)
@@ -130,7 +130,7 @@ public final class CtfTmfEventFactory {
      * mess, and put them into something ITmfEventField can cope with.
      */
     private static CtfTmfEventField[] parseFields(EventDefinition eventDef) {
-        List<CtfTmfEventField> fields = new ArrayList<CtfTmfEventField>();
+        List<CtfTmfEventField> fields = new ArrayList<>();
 
         StructDefinition structFields = eventDef.getFields();
         for (Map.Entry<String, Definition> entry : structFields.getDefinitions().entrySet()) {
index 242731eef12aadb9e43c1a21921b94d074611325..77b6276a14a8aaa8251431a3b292d202fade882d 100644 (file)
@@ -153,7 +153,7 @@ public abstract class CtfTmfEventField extends TmfEventField {
             String curFieldName = null;
             Definition curFieldDef;
             CtfTmfEventField curField;
-            List<ITmfEventField> list = new ArrayList<ITmfEventField>();
+            List<ITmfEventField> list = new ArrayList<>();
             /* Recursively parse the fields */
             for (Entry<String, Definition> entry : strDef.getDefinitions().entrySet()) {
                 curFieldName = entry.getKey();
@@ -293,7 +293,7 @@ final class CTFIntegerArrayField extends CtfTmfEventField {
     @Override
     public synchronized String getFormattedValue() {
         if (formattedValue == null) {
-            List<String> strings = new ArrayList<String>();
+            List<String> strings = new ArrayList<>();
             for (long value : getValue()) {
                 strings.add(IntegerDefinition.formatNumber(value, base, signed));
             }
@@ -333,7 +333,7 @@ final class CTFArrayField extends CtfTmfEventField {
     @Override
     public synchronized String getFormattedValue() {
         if (formattedValue == null) {
-            List<String> strings = new ArrayList<String>();
+            List<String> strings = new ArrayList<>();
             for (CtfTmfEventField element : getValue()) {
                 strings.add(element.getFormattedValue());
             }
index 4123369cc07c41ea19918d7766ee43cde178db78..3e1d9b8cfee31593ceae40fb5b336347e1ed4d49 100644 (file)
@@ -64,7 +64,7 @@ public class TmfEventField implements ITmfEventField {
         /* Fill the fFieldNames and fNameMapping structures */
         final int nbFields = (fFields != null) ? fFields.length : 0;
         fFieldNames = new String[nbFields];
-        fNameMapping = new HashMap<String, ITmfEventField>();
+        fNameMapping = new HashMap<>();
 
         for (int i = 0; i < nbFields; i++) {
             final String curName = fFields[i].getName();
index f89fc5dd82a9d65ef0aec99341bbd32f3a2f7e72..b2c3f8e0f6d03cca6e0f3f3047bfa2d58e9bd4d7 100644 (file)
@@ -44,7 +44,7 @@ public final class TmfEventTypeManager {
      * The singleton constructor
      */
     private TmfEventTypeManager() {
-        fEventTypes = new HashMap<String, HashMap<String, ITmfEventType>>();
+        fEventTypes = new HashMap<>();
     }
 
     /**
@@ -70,7 +70,7 @@ public final class TmfEventTypeManager {
     public synchronized void add(final String context, final ITmfEventType type) {
         HashMap<String, ITmfEventType> types = fEventTypes.get(context);
         if (types == null) {
-            types = new HashMap<String, ITmfEventType>();
+            types = new HashMap<>();
         }
         types.put(type.getName(), type);
         fEventTypes.put(context, types);
index 8cf3e5ec243d4c2ab14cb7145422bfae4f66eeba..1eb0bfdacccb0e91f1d34a0e1b947eb5c0b29f7e 100644 (file)
@@ -36,7 +36,7 @@ public class TmfEventMatches implements IMatchProcessingUnit {
      * Constructor
      */
     public TmfEventMatches() {
-        fMatches = new ArrayList<TmfEventDependency>();
+        fMatches = new ArrayList<>();
     }
 
     /**
index ec5d1e95318279f21dd599ab34e4b2bc5dd02a06..a7fcf7377d465222a6f986bbdb5368e13569d303 100644 (file)
@@ -56,9 +56,9 @@ public abstract class TmfEventMatching implements ITmfEventMatching {
      */
     private final IMatchProcessingUnit fMatches;
 
-    private static final Map<MatchingType, List<ITmfMatchEventDefinition>> fMatchDefinitions = new HashMap<MatchingType, List<ITmfMatchEventDefinition>>();
+    private static final Map<MatchingType, List<ITmfMatchEventDefinition>> fMatchDefinitions = new HashMap<>();
 
-    private final Map<ITmfTrace, ITmfMatchEventDefinition> fMatchMap = new HashMap<ITmfTrace, ITmfMatchEventDefinition>();
+    private final Map<ITmfTrace, ITmfMatchEventDefinition> fMatchMap = new HashMap<>();
 
     /**
      * Constructor with multiple traces and a match processing object
index f26ac73f8fa3599dae7fd4d2c36240300de8fc93..5e75c7d6cc4c142ed9e927d9f78dbd46a60cadff 100644 (file)
@@ -35,12 +35,12 @@ public class TmfNetworkEventMatching extends TmfEventMatching {
     /**
      * Hashtables for unmatches incoming events
      */
-    private final List<Map<List<Object>, ITmfEvent>> fUnmatchedIn = new ArrayList<Map<List<Object>, ITmfEvent>>();
+    private final List<Map<List<Object>, ITmfEvent>> fUnmatchedIn = new ArrayList<>();
 
     /**
      * Hashtables for unmatches outgoing events
      */
-    private final List<Map<List<Object>, ITmfEvent>> fUnmatchedOut = new ArrayList<Map<List<Object>, ITmfEvent>>();
+    private final List<Map<List<Object>, ITmfEvent>> fUnmatchedOut = new ArrayList<>();
 
     /**
      * Enum for in and out types
index 781268236a3880e14851c074b0f595f3bf8f29d4..af24a6b9a08d5ff3cd8b33d3b9eee806e7124be0 100644 (file)
@@ -201,7 +201,7 @@ public class TmfFilterCompareNode extends TmfFilterTreeNode {
 
        @Override
        public List<String> getValidChildren() {
-               return new ArrayList<String>(0);
+               return new ArrayList<>(0);
        }
 
        @Override
index c0dd25342e5c947d4db524263611ac6c4e004f89..d75708e8c0376c204f86facee6d5fe606c62b906 100644 (file)
@@ -124,7 +124,7 @@ public class TmfFilterContainsNode extends TmfFilterTreeNode {
 
        @Override
        public List<String> getValidChildren() {
-               return new ArrayList<String>(0);
+               return new ArrayList<>(0);
        }
 
        @Override
index 586b13b2ab879bed227b3cf142834882700d8dc8..27ce8df54911fd2906333c1e90624201882552d3 100644 (file)
@@ -124,7 +124,7 @@ public class TmfFilterEqualsNode extends TmfFilterTreeNode {
 
        @Override
        public List<String> getValidChildren() {
-               return new ArrayList<String>(0);
+               return new ArrayList<>(0);
        }
 
        @Override
index ff0791ed255fcd777b49d593fb7c0aa8f0462ed9..9134bd1d1fc1ac711487f12612621f5220ad0b53 100644 (file)
@@ -105,7 +105,7 @@ public class TmfFilterEventTypeNode extends TmfFilterTreeNode {
                if (getChildrenCount() == 0) {
                        return super.getValidChildren();
                }
-        return new ArrayList<String>(0); // only one child allowed
+        return new ArrayList<>(0); // only one child allowed
        }
 
        @Override
index aad75a02358308c03d2a54ed4048d7b762085730..fc8b918dd97dca240715e26bf806eef167b8d65d 100644 (file)
@@ -120,7 +120,7 @@ public class TmfFilterMatchesNode extends TmfFilterTreeNode {
 
     @Override
     public List<String> getValidChildren() {
-        return new ArrayList<String>(0);
+        return new ArrayList<>(0);
     }
 
     @Override
index fdd1137dd8d642b61be9e6a7e669e2f553cc9dd6..ab3eeb6aa90783360b90909dd6ffae572b713f27 100644 (file)
@@ -83,7 +83,7 @@ public class TmfFilterNode extends TmfFilterTreeNode {
                if (getChildrenCount() == 0) {
                        return super.getValidChildren();
                }
-        return new ArrayList<String>(0); // only one child allowed
+        return new ArrayList<>(0); // only one child allowed
        }
 
        @Override
index b0f4cdc05c7434c6593429e6e10e1afd4bd3b845..d6e90d9524a48843950cb0d259057040b3e9c517 100644 (file)
@@ -40,7 +40,7 @@ public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable
     };
 
     private ITmfFilterTreeNode parent = null;
-    private ArrayList<ITmfFilterTreeNode> children = new ArrayList<ITmfFilterTreeNode>();
+    private ArrayList<ITmfFilterTreeNode> children = new ArrayList<>();
 
     /**
      * @param parent
@@ -159,7 +159,7 @@ public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable
         try {
             TmfFilterTreeNode clone = (TmfFilterTreeNode) super.clone();
             clone.parent = null;
-            clone.children = new ArrayList<ITmfFilterTreeNode>(children.size());
+            clone.children = new ArrayList<>(children.size());
             for (ITmfFilterTreeNode child : getChildren()) {
                 clone.addChild(child.clone());
             }
index 9cc87af79ef7dbe98d4171843d16f8a11fcf58dd..cff55a609d64a568d4c41f201725f85e71466c87 100644 (file)
@@ -49,7 +49,7 @@ public class TmfFilterContentHandler extends DefaultHandler {
         */
        public TmfFilterContentHandler() {
                super();
-               fFilterTreeStack = new Stack<ITmfFilterTreeNode>();
+               fFilterTreeStack = new Stack<>();
        }
 
        /**
index 1ad50f745597893ff24c9139fa7874703e73320d..2ec18a84bf4149f5d88e74876617246ef1f9a394 100644 (file)
@@ -37,8 +37,8 @@ public class TmfSignalManager {
     // Note: listeners could be restricted to ITmfComponents but there is no
     // harm in letting anyone use this since it is not tied to anything but
     // the signal data type.
-    private static Map<Object, Method[]> fListeners = new HashMap<Object, Method[]>();
-    private static Map<Object, Method[]> fVIPListeners = new HashMap<Object, Method[]>();
+    private static Map<Object, Method[]> fListeners = new HashMap<>();
+    private static Map<Object, Method[]> fVIPListeners = new HashMap<>();
 
     // If requested, add universal signal tracer
     // TODO: Temporary solution: should be enabled/disabled dynamically
@@ -104,7 +104,7 @@ public class TmfSignalManager {
      * @return
      */
     private static Method[] getSignalHandlerMethods(Object listener) {
-        List<Method> handlers = new ArrayList<Method>();
+        List<Method> handlers = new ArrayList<>();
         Method[] methods = listener.getClass().getMethods();
         for (Method method : methods) {
             if (method.isAnnotationPresent(TmfSignalHandler.class)) {
@@ -151,10 +151,10 @@ public class TmfSignalManager {
 
         // Build the list of listener methods that are registered for this signal
         Class<?> signalClass = signal.getClass();
-        Map<Object, List<Method>> targets = new HashMap<Object, List<Method>>();
+        Map<Object, List<Method>> targets = new HashMap<>();
         targets.clear();
         for (Map.Entry<Object, Method[]> entry : listeners.entrySet()) {
-            List<Method> matchingMethods = new ArrayList<Method>();
+            List<Method> matchingMethods = new ArrayList<>();
             for (Method method : entry.getValue()) {
                 if (method.getParameterTypes()[0].isAssignableFrom(signalClass)) {
                     matchingMethods.add(method);
index 36eb476cd2bb4693d28555982c3713f3d706e4c8..bf48c6066110db0dec82700f26021cf962182672 100644 (file)
@@ -67,7 +67,7 @@ public abstract class AbstractTmfStateProvider implements ITmfStateProvider {
             Class<? extends ITmfEvent> eventType, String id) {
         this.trace = trace;
         this.eventType = eventType;
-        eventsQueue = new ArrayBlockingQueue<ITmfEvent>(DEFAULT_EVENTS_QUEUE_SIZE);
+        eventsQueue = new ArrayBlockingQueue<>(DEFAULT_EVENTS_QUEUE_SIZE);
         ssAssigned = false;
 
         String id2 = (id == null ? "Unamed" : id); //$NON-NLS-1$
index e480656f2b2bc8f7a4e7f0dc859b726022c909f6..6f4b11fe52d14c8415d17000cbcbc419dcdc3740 100644 (file)
@@ -138,7 +138,7 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
 
     @Override
     public Map<String, ITmfStateSystem> getStateSystems() {
-        Map<String, ITmfStateSystem> map = new HashMap<String, ITmfStateSystem>();
+        Map<String, ITmfStateSystem> map = new HashMap<>();
         map.put(getId(), fStateSystem);
         return map;
     }
index c74f1ec08721c3a9dac238cf07beae16e9566104..1de8409012b78d048b67f73295236e1727fcc3c3 100644 (file)
@@ -199,9 +199,9 @@ public final class TmfStateSystemOperations {
     private static List<ITmfStateInterval> queryAttributeRange(ITmfStateSystem ss,
             long t1, long t2, int baseQuark, String featureString)
                     throws AttributeNotFoundException, TimeRangeException, StateValueTypeException {
-        Pair<Long, Long> timeRange = new Pair<Long, Long>(t1, t2);
+        Pair<Long, Long> timeRange = new Pair<>(t1, t2);
         int mipmapQuark = -1;
-        List<ITmfStateInterval> intervals = new ArrayList<ITmfStateInterval>();
+        List<ITmfStateInterval> intervals = new ArrayList<>();
         try {
             try {
                 mipmapQuark = ss.getQuarkRelative(baseQuark, featureString);
@@ -314,7 +314,7 @@ public final class TmfStateSystemOperations {
         }
         long startTime = Math.max(timeRange.getFirst(),
                 Math.min(currentLevelInterval.getEndTime() + 1, timeRange.getSecond()));
-        return new Pair<Long, Long>(startTime, timeRange.getSecond());
+        return new Pair<>(startTime, timeRange.getSecond());
     }
 
     private static boolean isFullyOverlapped(Pair<Long, Long> range,
index a3673a0431192ddb420b8cd234bf33593963a86c..ad2bfbea50a3f63e5c59ec770f2e4ad1c92c7d43 100644 (file)
@@ -146,7 +146,7 @@ public class TmfEventsStatistics implements ITmfStatistics {
         HistogramQueryRequest req = new HistogramQueryRequest(borders, end);
         sendAndWait(req);
 
-        List<Long> results = new LinkedList<Long>(req.getResults());
+        List<Long> results = new LinkedList<>(req.getResults());
         return results;
 
     }
@@ -253,7 +253,7 @@ public class TmfEventsStatistics implements ITmfStatistics {
         public StatsPerTypeRequest(ITmfTrace trace, TmfTimeRange range) {
             super(trace.getEventType(), range, 0, ITmfEventRequest.ALL_DATA,
                     ITmfEventRequest.ExecutionType.BACKGROUND);
-            this.stats = new HashMap<String, Long>();
+            this.stats = new HashMap<>();
         }
 
         public Map<String, Long> getResults() {
@@ -320,7 +320,7 @@ public class TmfEventsStatistics implements ITmfStatistics {
                     ITmfEventRequest.ExecutionType.BACKGROUND);
 
             /* Prepare the results map, with all counts at 0 */
-            results = new TreeMap<Long, Long>();
+            results = new TreeMap<>();
             for (long border : borders) {
                 results.put(border, 0L);
             }
index e8d48b39b4a7619f91b62722482b339756136ff3..76ae92c2e7ce1bc1c1e63e2b58cb0d4de6f329fe 100644 (file)
@@ -211,7 +211,7 @@ public class TmfStateStatistics implements ITmfStatistics {
 
     @Override
     public List<Long> histogramQuery(final long start, final long end, final int nb) {
-        final List<Long> list = new LinkedList<Long>();
+        final List<Long> list = new LinkedList<>();
         final long increment = (end - start) / nb;
 
         if (!totalsStats.waitUntilBuilt()) {
@@ -277,7 +277,7 @@ public class TmfStateStatistics implements ITmfStatistics {
         /* We need the complete state history to be built to answer this. */
         typesStats.waitUntilBuilt();
 
-        Map<String, Long> map = new HashMap<String, Long>();
+        Map<String, Long> map = new HashMap<>();
         long endTime = typesStats.getCurrentEndTime();
 
         try {
@@ -335,7 +335,7 @@ public class TmfStateStatistics implements ITmfStatistics {
         // end time, and answer as soon as possible...
         typesStats.waitUntilBuilt();
 
-        Map<String, Long> map = new HashMap<String, Long>();
+        Map<String, Long> map = new HashMap<>();
 
         /* Make sure the start/end times are within the state history, so we
          * don't get TimeRange exceptions.
index 7360e7f85fa89025ae75943bd47bfe5d2bcfdca5..6cb695ab3f22873a51f637b99fb5cb3ec86f5327 100644 (file)
@@ -56,7 +56,7 @@ public class SyncAlgorithmFullyIncremental extends SynchronizationAlgorithm {
      * Initialization of the attributes
      */
     public SyncAlgorithmFullyIncremental() {
-        fSyncs = new LinkedList<ConvexHull>();
+        fSyncs = new LinkedList<>();
     }
 
     /**
@@ -162,7 +162,7 @@ public class SyncAlgorithmFullyIncremental extends SynchronizationAlgorithm {
 
     @Override
     public Map<String, Map<String, Object>> getStats() {
-        Map<String, Map<String, Object>> statmap = new LinkedHashMap<String, Map<String, Object>>();
+        Map<String, Map<String, Object>> statmap = new LinkedHashMap<>();
         for (ConvexHull traceSync : fSyncs) {
             statmap.put(traceSync.getReferenceTrace() + " <==> " + traceSync.getOtherTrace(), traceSync.getStats()); //$NON-NLS-1$
         }
@@ -189,13 +189,13 @@ public class SyncAlgorithmFullyIncremental extends SynchronizationAlgorithm {
          * The list of meaningful points on the upper hull (received by the
          * reference trace, below in a graph)
          */
-        private final LinkedList<SyncPoint> fUpperBoundList = new LinkedList<SyncPoint>();
+        private final LinkedList<SyncPoint> fUpperBoundList = new LinkedList<>();
 
         /**
          * The list of meaninful points on the lower hull (sent by the reference
          * trace, above in a graph)
          */
-        private final LinkedList<SyncPoint> fLowerBoundList = new LinkedList<SyncPoint>();
+        private final LinkedList<SyncPoint> fLowerBoundList = new LinkedList<>();
 
         /** Points forming the line with maximum slope */
         private final SyncPoint[] fLmax;
@@ -213,7 +213,7 @@ public class SyncAlgorithmFullyIncremental extends SynchronizationAlgorithm {
         private String fReferenceTrace = "", fOtherTrace = ""; //$NON-NLS-1$//$NON-NLS-2$
         private SyncQuality fQuality;
 
-        private Map<String, Object> fStats = new LinkedHashMap<String, Object>();
+        private Map<String, Object> fStats = new LinkedHashMap<>();
 
         /**
          * Initialization of the attributes
index 1950b3aa73c1a0043691a446912063995aba974f..534410a77940c5caa39fed8ef46e2495920c4073 100644 (file)
@@ -90,37 +90,31 @@ public class SynchronizationBackend {
             return;
         }
 
-        FileInputStream fis = new FileInputStream(syncFile);
-        ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE);
-        FileChannel fc = fis.getChannel();
-        buffer.clear();
-        fc.read(buffer);
-        buffer.flip();
-
-        /*
-         * Check the magic number,to make sure we're opening the right type of
-         * file
-         */
-        res = buffer.getInt();
-        if (res != SYNC_FILE_MAGIC_NUMBER) {
-            fc.close();
-            fis.close();
-            throw new IOException("Selected file does not" + //$NON-NLS-1$
-                    "look like a synchronization file"); //$NON-NLS-1$
-        }
+        try (FileInputStream fis = new FileInputStream(syncFile);
+                FileChannel fc = fis.getChannel();) {
+            ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE);
+            buffer.clear();
+            fc.read(buffer);
+            buffer.flip();
 
-        res = buffer.getInt(); /* Major version number */
-        if (res != FILE_VERSION) {
-            fc.close();
-            fis.close();
-            throw new IOException("Select synchronization file is of an older " //$NON-NLS-1$
-                    + "format. Synchronization will have to be computed again."); //$NON-NLS-1$
-        }
+            /*
+             * Check the magic number,to make sure we're opening the right type
+             * of file
+             */
+            res = buffer.getInt();
+            if (res != SYNC_FILE_MAGIC_NUMBER) {
+                throw new IOException("Selected file does not" + //$NON-NLS-1$
+                        "look like a synchronization file"); //$NON-NLS-1$
+            }
 
-        res = buffer.getInt(); /* Minor version number */
+            res = buffer.getInt(); /* Major version number */
+            if (res != FILE_VERSION) {
+                throw new IOException("Select synchronization file is of an older " //$NON-NLS-1$
+                        + "format. Synchronization will have to be computed again."); //$NON-NLS-1$
+            }
 
-        fc.close();
-        fis.close();
+            res = buffer.getInt(); /* Minor version number */
+        }
     }
 
     /**
@@ -136,24 +130,18 @@ public class SynchronizationBackend {
             return null;
         }
 
-        /* Set the position after the header */
-        FileInputStream fis = new FileInputStream(fSyncFile);
-        FileChannel fc = fis.getChannel().position(HEADER_SIZE);
+        try (/* Set the position after the header */
+                FileInputStream fis = new FileInputStream(fSyncFile);
+                FileChannel fc = fis.getChannel().position(HEADER_SIZE);
+                /* Read the input stream */
+                ObjectInputStream ois = new ObjectInputStream(fis);) {
 
-        /* Read the input stream */
-        ObjectInputStream ois = new ObjectInputStream(fis);
-        SyncAlgorithmFullyIncremental syncAlgo = null;
-        try {
-            syncAlgo = (SyncAlgorithmFullyIncremental) ois.readObject();
+            return (SynchronizationAlgorithm) ois.readObject();
         } catch (ClassNotFoundException e) {
-
+            return null;
         }
-        ois.close();
-        fc.close();
 
-        fis.close();
 
-        return syncAlgo;
     }
 
     /**
@@ -170,20 +158,13 @@ public class SynchronizationBackend {
             return;
         }
 
-        FileChannel fc;
-        FileOutputStream fos;
-        ObjectOutputStream oos;
-        ByteBuffer buffer;
-        int res;
-
-        fos = new FileOutputStream(fSyncFile, false);
-        fc = fos.getChannel();
+        /* Save the header of the file */
+        try (FileOutputStream fos = new FileOutputStream(fSyncFile, false);
+                FileChannel fc = fos.getChannel();) {
 
-        buffer = ByteBuffer.allocate(HEADER_SIZE);
-        buffer.clear();
+            ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE);
+            buffer.clear();
 
-        /* Save the header of the file */
-        try {
             fc.position(0);
 
             buffer.putInt(SYNC_FILE_MAGIC_NUMBER);
@@ -191,26 +172,22 @@ public class SynchronizationBackend {
             buffer.putInt(FILE_VERSION);
 
             buffer.flip();
-            res = fc.write(buffer);
+            int res = fc.write(buffer);
             assert (res <= HEADER_SIZE);
             /* done writing the file header */
 
             fc.position(HEADER_SIZE);
 
-            oos = new ObjectOutputStream(fos);
-            oos.writeObject(syncAlgo);
-            oos.close();
+            try (ObjectOutputStream oos = new ObjectOutputStream(fos);) {
+                oos.writeObject(syncAlgo);
+            }
 
+        } catch (FileNotFoundException e) {
+            /* Send this upwards */
+            throw e;
         } catch (IOException e) {
-            /* We should not have any problems at this point... */
+            /* Handle other cases of IOException's */
             Activator.logError("Error saving trace synchronization data", e); //$NON-NLS-1$
-        } finally {
-            try {
-                fc.close();
-                fos.close();
-            } catch (IOException e) {
-                Activator.logError("Error closing synchronization file", e); //$NON-NLS-1$
-            }
         }
         return;
 
index 900208ab9a53919bee2d9fe2b016cca3f2f66e88..be8e17d31fdd8e3e70abcf0c2de924624c00aff7 100644 (file)
@@ -137,7 +137,7 @@ public class TmfTimePreferences {
     }
 
     private static Map<String, String> getPreferenceMap(boolean defaultValues) {
-        Map<String, String> prefsMap = new HashMap<String, String>();
+        Map<String, String> prefsMap = new HashMap<>();
         IEclipsePreferences prefs = defaultValues ? DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID) : InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
         prefToMap(prefs, prefsMap, ITmfTimePreferencesConstants.SUBSEC, SUBSEC_DEFAULT);
         prefToMap(prefs, prefsMap, ITmfTimePreferencesConstants.TIME_DELIMITER, TIME_DELIMITER_DEFAULT);
index bbf2d342909b7b82136790f8899905f032d32d68..efb9d9108cf55924bed1eb631c9c2f8b6da985fd 100644 (file)
@@ -222,7 +222,7 @@ public class TmfTimestampFormat extends SimpleDateFormat {
     private String fPattern;
 
     // The timestamp pattern
-    private List<String> fSupplPatterns = new ArrayList<String>();
+    private List<String> fSupplPatterns = new ArrayList<>();
 
     /**
      * The supplementary pattern letters. Can be redefined by sub-classes
index 5dcd7574eba95e0b6bcf423f87700f3ca8d47a9c..a60b55b2d7c68f4f470609ab0f8cc70c362bc796 100644 (file)
@@ -18,7 +18,6 @@ package org.eclipse.linuxtools.tmf.core.trace;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
@@ -133,12 +132,12 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
      * @since 2.0
      */
     protected final Map<String, ITmfStateSystem> fStateSystems =
-            new LinkedHashMap<String, ITmfStateSystem>();
+            new LinkedHashMap<>();
 
     private ITmfTimestampTransform fTsTransform;
 
     private final Map<String, IAnalysisModule> fAnalysisModules =
-            new LinkedHashMap<String, IAnalysisModule>();
+            new LinkedHashMap<>();
 
     private static final String SYNCHRONIZATION_FORMULA_FILE = "sync_formula"; //$NON-NLS-1$
 
@@ -358,7 +357,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
      */
     @Override
     public <T> Map<String, T> getAnalysisModules(Class<T> moduleclass) {
-        Map<String, T> modules = new HashMap<String, T>();
+        Map<String, T> modules = new HashMap<>();
         for (Entry<String, IAnalysisModule> entry : fAnalysisModules.entrySet()) {
             if (moduleclass.isAssignableFrom(entry.getValue().getClass())) {
                 modules.put(entry.getKey(), moduleclass.cast(entry.getValue()));
@@ -882,18 +881,12 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
             File sync_file = getSyncFormulaFile();
             if (sync_file != null && sync_file.exists()) {
 
-                try {
-                    FileInputStream fis = new FileInputStream(sync_file);
-                    ObjectInputStream ois = new ObjectInputStream(fis);
+                try (FileInputStream fis = new FileInputStream(sync_file);
+                        ObjectInputStream ois = new ObjectInputStream(fis);) {
+
                     fTsTransform = (ITmfTimestampTransform) ois.readObject();
 
-                    ois.close();
-                    fis.close();
-                } catch (ClassNotFoundException e1) {
-                    fTsTransform = TmfTimestampTransform.IDENTITY;
-                } catch (FileNotFoundException e1) {
-                    fTsTransform = TmfTimestampTransform.IDENTITY;
-                } catch (IOException e1) {
+                } catch (ClassNotFoundException | IOException e) {
                     fTsTransform = TmfTimestampTransform.IDENTITY;
                 }
             } else {
index affd091bd24008c93ddbabc9ee28f4550adee611..257539beebcf2510be3948cfd5a5cf2a91d6d7b0 100644 (file)
@@ -64,7 +64,7 @@ public final class TmfTraceManager {
     // ------------------------------------------------------------------------
 
     private TmfTraceManager() {
-        fTraces = new LinkedHashMap<ITmfTrace, TmfTraceContext>();
+        fTraces = new LinkedHashMap<>();
         TmfSignalManager.registerVIP(this);
     }
 
This page took 0.058247 seconds and 5 git commands to generate.