releng: Transition to jdt.annotation 2.0
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 25 May 2015 16:38:29 +0000 (12:38 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 30 Oct 2015 00:24:12 +0000 (20:24 -0400)
The new o.e.jdt.annotation 2.0 annotations (based on Java 8
Type Annotations [1]) can now apply on generic type declarations,
allowing things like "List<@NonNull String>".

The @NonNullByDefault annotation, already in use, will now apply
to these locations. This required some code changes to eliminate
compilation errors, notably in places where null checks were
previously made and were not needed, or where some existing
declarations had to be specified as @Nullable.

Another relatively important change is the new syntax for []
arrays. Before, only "@NonNull String[]" was allowed, which meant
"a non-null reference to an array of unspecified Strings". Now, it
instead means "an unspecified reference to an array of non-null
Strings".

It is still possible to specify the array reference itself, but by
doing: "String @NonNull []". Both locations can be annotated
independently.

[1] See https://docs.oracle.com/javase/tutorial/java/annotations/type_annotations.html

Change-Id: I4cb0a3266928c24cfd7f8ed442c93556132f892c
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/57252
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
83 files changed:
analysis/org.eclipse.tracecompass.analysis.graph.core.tests/stubs/org/eclipse/tracecompass/analysis/graph/core/tests/stubs/GraphOps.java
analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelThreadInformationProvider.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/Messages.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/AbstractSegmentStoreStatisticsViewer.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/Messages.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/Messages.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/SegmentStoreContentProvider.java
common/org.eclipse.tracecompass.common.core/META-INF/MANIFEST.MF
common/org.eclipse.tracecompass.common.core/pom.xml
common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/NonNullUtils.java
common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/ObjectUtils.java
common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/collect/BufferedBlockingQueue.java
ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/io/BitBufferTest.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/io/BitBuffer.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/AbstractArrayDefinition.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/IDeclaration.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStream.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDeclaration.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/building/LttngKernelExecGraphProvider.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/Messages.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerExecutionGraph.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/model/LttngSystemModel.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/model/VirtualCPU.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineCpuAnalysis.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/matching/TcpLttngEventMatching.java
pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java
pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ipv4/IPv4Packet.java
pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/tcp/TCPPacket.java
pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/Messages.java
pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/TmfPacketStreamBuilder.java
pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/trace/PcapTrace.java
pcap/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/stream/StreamListView.java
pom.xml
releng/org.eclipse.tracecompass.target/tracecompass-e4.5.target
releng/org.eclipse.tracecompass.target/tracecompass-eStaging.target
statesystem/org.eclipse.tracecompass.segmentstore.core.tests/src/org/eclipse/tracecompass/segmentstore/core/tests/treemap/TreeMapStoreTest.java
statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/Attribute.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlCondition.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlEventHandler.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlLocation.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateChange.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateValue.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/IXmlStateSystemContainer.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/XmlUtils.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.tests/build.properties
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java
tmf/org.eclipse.tracecompass.tmf.core.tests/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/text/TextTraceTest.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/analysis/TmfAnalysisParameterProviders.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/callstack/FunctionNameMapper.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/IAnalysisModuleSource.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/IAnalysisRequirementProvider.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisModule.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisManager.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfCustomAttributes.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventField.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventField.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/IMatchProcessingUnit.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceProperties.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceAdapterManager.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTrace.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTraceEventContent.java
tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandInputTest.java
tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandResultTest.java
tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandShellTest.java
tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandShell.java
tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventPropertySource.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/ITmfTreeColumnDataProvider.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfClosestDataPointTooltipProvider.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/SDView.java

index cc1d3162de39ab4511bb46804c23a4b48635bff1..36bb3967f7cfeb90765b830beb4be31aeb4c0308 100644 (file)
@@ -54,9 +54,6 @@ public class GraphOps {
                 assertEquals("Node timestamps", v1.getTs(), v2.getTs());
                 /* Check each edge */
                 for (EdgeDirection dir : EdgeDirection.values()) {
-                    if (dir == null) {
-                        throw new NullPointerException();
-                    }
                     TmfEdge edge1 = v1.getEdge(dir);
                     TmfEdge edge2 = v2.getEdge(dir);
                     if (edge1 == null) {
index 64afc95099fae183f599e7ee0b54b34ecf61c279..e5e5411172455b0163153663c523cdc2fea4c308 100644 (file)
@@ -323,7 +323,7 @@ public class CriticalPathView extends AbstractTimeGraphView {
 
             /* find vertical links */
             graph.scanLineTraverse(vertex, new VerticalLinksVisitor(graph, graphLinks, entryMap));
-            fLinks.put(trace, fCurrentObject, graphLinks);
+            fLinks.put(trace, checkNotNull(fCurrentObject), graphLinks);
             links = graphLinks;
 
             List<ILinkEvent> linksInRange = new ArrayList<>();
@@ -346,7 +346,7 @@ public class CriticalPathView extends AbstractTimeGraphView {
         }
 
         @Override
-        public @Nullable ITimeGraphEntry[] getChildren(@Nullable Object parentElement) {
+        public ITimeGraphEntry @Nullable [] getChildren(@Nullable Object parentElement) {
             if (parentElement instanceof CriticalPathEntry) {
                 List<? extends ITimeGraphEntry> children = ((CriticalPathEntry) parentElement).getChildren();
                 return children.toArray(new TimeGraphEntry[children.size()]);
index ab9692608f7c4b25051104d3a7875df109f926d1..bf4c48363ecb0b15b4186261cf2a27521bdca72d 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Set;
 import java.util.TreeSet;
 
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
@@ -96,7 +97,7 @@ public final class KernelThreadInformationProvider {
         int threadQuark;
         try {
             threadQuark = ss.getQuarkAbsolute(Attributes.THREADS);
-            Set<Integer> tids = new TreeSet<>();
+            Set<@NonNull Integer> tids = new TreeSet<>();
             for (Integer quark : ss.getSubAttributes(threadQuark, false)) {
                 tids.add(Integer.parseInt(ss.getAttributeName(quark)));
             }
index 6d91f2e8dfe043478d03c6e902189927c50ddaff..e494b294c7c801900e1b34a57103e654e8c37b83 100644 (file)
@@ -18,7 +18,7 @@ import org.eclipse.osgi.util.NLS;
 /**
  * @author France Lapointe Nguyen
  */
-@NonNullByDefault(false)
+@NonNullByDefault({})
 public class Messages extends NLS {
     private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.messages"; //$NON-NLS-1$
 
index fe551828cb8d2142f78763180793c571fafdacb6..ba8fd859465f6807b1f2bac069a6796354232698 100644 (file)
@@ -110,9 +110,9 @@ public abstract class AbstractSegmentStoreStatisticsViewer extends AbstractTmfTr
         return new ITmfTreeColumnDataProvider() {
 
             @Override
-            public List<TmfTreeColumnData> getColumnData() {
+            public List<@Nullable TmfTreeColumnData> getColumnData() {
                 /* All columns are sortable */
-                List<TmfTreeColumnData> columns = new ArrayList<>();
+                List<@Nullable TmfTreeColumnData> columns = new ArrayList<>();
                 TmfTreeColumnData column = new TmfTreeColumnData(COLUMN_NAMES[0]);
                 column.setComparator(new ViewerComparator() {
                     @Override
index cbc9f420bce669da719de2bc2899805428cf9933..0b430f3e4ebe1d94956d10d295b1cbac1c4a2b3e 100644 (file)
@@ -19,7 +19,7 @@ import org.eclipse.osgi.util.NLS;
  *
  * @author Bernd Hufmann
  */
-@NonNullByDefault(false)
+@NonNullByDefault({})
 public class Messages extends NLS {
 
     private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.statistics.messages"; //$NON-NLS-1$
index f57ee2759722c02388c22b977a4245b2fa7944e8..a8d032ff29a2171d57ef0917d6fa337c2d4f5d1d 100644 (file)
@@ -19,7 +19,7 @@ import org.eclipse.osgi.util.NLS;
  * @author France Lapointe Nguyen
  * @since 2.0
  */
-@NonNullByDefault(false)
+@NonNullByDefault({})
 public class Messages extends NLS {
     private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.messages"; //$NON-NLS-1$
 
index 9a6919a7ef8949fb9835cdaad939e24c6eca1f17..6e452d64e775032769aa6e589e20b18e7633f19e 100644 (file)
@@ -36,7 +36,7 @@ public class SegmentStoreContentProvider implements ISortingLazyContentProvider
     /**
      * Array of all the segments in the segment store of the current trace
      */
-    private @Nullable ISegment[] fSegmentArray = null;
+    private ISegment @Nullable [] fSegmentArray = null;
 
     /**
      * Table viewer of the latency table viewer
@@ -67,8 +67,8 @@ public class SegmentStoreContentProvider implements ISortingLazyContentProvider
     @Override
     public void inputChanged(@Nullable Viewer viewer, @Nullable Object oldInput, @Nullable Object newInput) {
         fTableViewer = (TableViewer) viewer;
-        if (newInput instanceof ISegmentStore<?>) {
-            ISegmentStore<?> segmentStore = (ISegmentStore<?>) newInput;
+        if (newInput instanceof ISegmentStore) {
+            ISegmentStore<ISegment> segmentStore = (ISegmentStore<ISegment>) newInput;
             fSegmentArray = Iterables.toArray(segmentStore, ISegment.class);
             if (fComparator != null) {
                 Arrays.sort(fSegmentArray, fComparator);
index c120b0bc45bfd3c0e071ab72647ca3ac07ee8a95..51ddb18ad4703560bdd30eeed98e765303a9164b 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Bundle-Name
 Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 2.0.0.qualifier
 Bundle-Localization: plugin
 Bundle-SymbolicName: org.eclipse.tracecompass.common.core;singleton:=true
 Bundle-Activator: org.eclipse.tracecompass.internal.common.core.Activator
index 57afdf8b7c2f484507a2845e8735a9e37d4eb2d5..47afbf3490f751e8d27ca56cf3f82d3dbd0217a6 100644 (file)
@@ -18,7 +18,6 @@
   </parent>
 
   <artifactId>org.eclipse.tracecompass.common.core</artifactId>
-  <version>1.2.0-SNAPSHOT</version>
   <packaging>eclipse-plugin</packaging>
 
   <name>Trace Compass Common Utilities Core Plug-in</name>
index a1141e3f2d6ab03c3862adce399ab6ac3840acca..c1008edae3720b72fd774fa0d02eefb3dbcb32cf 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.common.core;
 
+import java.util.Map;
+
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 
@@ -43,6 +45,30 @@ public final class NonNullUtils {
         return (str == null ? "" : str); //$NON-NLS-1$
     }
 
+    /**
+     * Checks equality with two nullable objects
+     *
+     * @param o1
+     *            the first object to compare
+     * @param o2
+     *            the second object to compare
+     * @return true if o1.equals(o2) or o1 == o2
+     * @since 1.0
+     */
+    public static boolean equalsNullable(final @Nullable Object o1, final @Nullable Object o2) {
+        if (o1 == o2) {
+            return true;
+        }
+        if (o1 == null) {
+            return false;
+        }
+        return o1.equals(o2);
+    }
+
+    // ------------------------------------------------------------------------
+    // checkNotNull() methods, to convert @Nullable references to @NonNull ones
+    // ------------------------------------------------------------------------
+
     /**
      * Convert a non-annotated object reference to a {@link NonNull} one.
      *
@@ -56,7 +82,7 @@ public final class NonNullUtils {
      * @throws NullPointerException
      *             If the reference was actually null
      */
-    public static <T> T checkNotNull(@Nullable T obj) {
+    public static <T> @NonNull T checkNotNull(@Nullable T obj) {
         if (obj == null) {
             throw new NullPointerException();
         }
@@ -64,22 +90,66 @@ public final class NonNullUtils {
     }
 
     /**
-     * Checks equality with two nullable objects
+     * Convert a non-annotated [] array reference to a @NonNull one.
      *
-     * @param o1
-     *            the first object to compare
-     * @param o2
-     *            the second object to compare
-     * @return true if o1.equals(o2) or o1 == o2
-     * @since 1.0
+     * Note that this method does not check the array contents itself, which can
+     * still contain null elements.
+     *
+     * @param array
+     *            The array whose reference should not be null
+     * @return A {@link NonNull} reference to the array
+     * @throws NullPointerException
+     *             If the reference was actually null
+     * @since 2.0
      */
-    public static boolean equalsNullable(final @Nullable Object o1, final @Nullable Object o2) {
-        if (o1 == o2) {
-            return true;
+    public static <@Nullable T> T[] checkNotNull(T @Nullable [] array) {
+        if (array == null) {
+            throw new NullPointerException();
         }
-        if (o1 == null) {
-            return false;
+        return array;
+    }
+
+    /**
+     * Convert a non-annotated {@link Iterable} to a NonNull one.
+     *
+     * Note that, unlike {{@link #checkNotNull(Object)}}, this method does not
+     * check the contents itself, which can still contain null elements.
+     *
+     * @param container
+     *            The iterable whose reference should not be null
+     * @return A {@link NonNull} reference to the Iterable. The original class
+     *         type is preserved.
+     * @throws NullPointerException
+     *             If the reference was actually null
+     * @since 2.0
+     */
+    public static <@Nullable T, C extends Iterable<T>> C checkNotNull(@Nullable C container) {
+        if (container == null) {
+            throw new NullPointerException();
         }
-        return o1.equals(o2);
+        return container;
     }
+
+    /**
+     * Convert a non-annotated {@link Map} to a NonNull one.
+     *
+     * Note that, unlike {{@link #checkNotNull(Object)}}, this method does not
+     * check the keys or values themselves, which can still contain null
+     * elements.
+     *
+     * @param map
+     *            The map whose reference should not be null
+     * @return A {@link NonNull} reference to the Map
+     * @throws NullPointerException
+     *             If the reference was actually null
+     * @since 2.0
+     */
+    public static <@Nullable K, @Nullable V, M extends Map<K, V>> M checkNotNull(@Nullable M map) {
+        if (map == null) {
+            throw new NullPointerException();
+        }
+        return map;
+    }
+
+
 }
index df7532960e36ac7fb0dd02592e5f997dceb560a3..99c79100750b60a37ed247e48d25b922fa870615 100644 (file)
@@ -24,7 +24,7 @@ import org.eclipse.jdt.annotation.Nullable;
  * Utility methods for arbitrary objects.
  *
  * @author Patrick Tasse
- * @since 1.2
+ * @since 2.0
  */
 public final class ObjectUtils {
 
index 088ce19362eb3e1bec65d0a250eeda1a576ee2d2..5797273adf5c0eca0af9419d010581fbcef60a24 100644 (file)
@@ -311,7 +311,7 @@ public class BufferedBlockingQueue<T> implements Iterable<T> {
         @Override
         public T next() {
             if (hasNext()) {
-                T next = fNext;
+                @Nullable T next = fNext;
                 if (next != null) {
                     fNext = null;
                     return next;
index 76196cdf3425ec30bfbcfe0d23bc28f9624e8666..8fe956aacfbb0baf2ea55ac343bd96abfee783eb 100644 (file)
@@ -175,8 +175,7 @@ public class BitBufferTest {
      */
     @Test
     public void testGetBytes() {
-        @NonNull
-        byte[] data = new byte[2];
+        byte @NonNull [] data = new byte[2];
         ByteBuffer bb = ByteBuffer.allocate(10);
         bb.put((byte) 0);
         bb.put((byte) 1);
@@ -199,8 +198,7 @@ public class BitBufferTest {
      */
     @Test
     public void testGetBytesMiddle() throws CTFException {
-        @NonNull
-        byte[] data = new byte[5];
+        byte @NonNull [] data = new byte[5];
         // this string has been carefully selected and tested... don't change
         // the string and expect the result to be the same.
         fixture = new BitBuffer(Util.testMemory(ByteBuffer.wrap(new String("hello world").getBytes())));
index 8316cb8b4408e9587379ad6ee6e574a98c6460d5..aa3646058daa7bf46701e0396ef136fd2fcf39be 100644 (file)
@@ -187,7 +187,7 @@ public final class BitBuffer {
      *             - If there are fewer than length bytes remaining in this
      *             buffer
      */
-    public void get(@NonNull byte[] dst) {
+    public void get(byte @NonNull [] dst) {
         fBuffer.position((int) (fPosition / BIT_CHAR));
         fBuffer.get(dst);
         fPosition += dst.length * BIT_CHAR;
index 75e2a82d7e1a7e33d58171c6eddfc3e15d40fcfc..d445096939b84c0270ca0b01c822012730c27347 100644 (file)
@@ -46,7 +46,7 @@ public abstract class AbstractArrayDefinition extends Definition {
      *
      * @return the definitions
      */
-    public abstract List<Definition> getDefinitions();
+    public abstract List<@Nullable Definition> getDefinitions();
 
     /**
      * Get the the number of elements in the array
index 9496337a5188629caa15b2aa0d788fe9582e3433..8ceae678124eeab87be1f8cf1c761c52e24cbd23 100644 (file)
@@ -47,7 +47,7 @@ public interface IDeclaration {
      * @throws CTFException
      *             error in reading
      */
-    Definition createDefinition(IDefinitionScope definitionScope, @NonNull String fieldName, @NonNull BitBuffer input) throws CTFException;
+    @NonNull Definition createDefinition(IDefinitionScope definitionScope, @NonNull String fieldName, @NonNull BitBuffer input) throws CTFException;
 
     /**
      * Get the path of a definition
index 22e2232e9c4e8d9ec981ae04d8d70d11dacc7a2f..5c4b008eb847dc7366d081853f27fd84dfdc1e32 100644 (file)
@@ -60,7 +60,7 @@ public class CTFStream {
     /**
      * Maps event ids to events
      */
-    private final ArrayList<IEventDeclaration> fEvents = new ArrayList<>();
+    private final ArrayList<@Nullable IEventDeclaration> fEvents = new ArrayList<>();
 
     private boolean fEventUnsetId = false;
     private boolean fStreamIdSet = false;
@@ -332,7 +332,7 @@ public class CTFStream {
         }
     }
 
-    private static void ensureSize(ArrayList<? extends Object> list, int index) {
+    private static void ensureSize(ArrayList<@Nullable ? extends Object> list, int index) {
         list.ensureCapacity(index);
         while (list.size() <= index) {
             list.add(null);
index 085d4141b0346cd15e04cc2804872e6a94f4ba9d..3983f34804e8842971bcb49054c77185fb3ef1b4 100644 (file)
@@ -123,8 +123,8 @@ public final class ArrayDeclaration extends CompoundDeclaration {
         return "[declaration] array[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
     }
 
-    private @NonNull List<Definition> read(@NonNull BitBuffer input, @Nullable IDefinitionScope definitionScope, String fieldName) throws CTFException {
-        Builder<Definition> definitions = new ImmutableList.Builder<>();
+    private @NonNull List<@NonNull Definition> read(@NonNull BitBuffer input, @Nullable IDefinitionScope definitionScope, String fieldName) throws CTFException {
+        Builder<@NonNull Definition> definitions = new ImmutableList.Builder<>();
         if (!fChildrenNames.containsKey(fieldName)) {
             for (int i = 0; i < fLength; i++) {
                 fChildrenNames.put(fieldName, fieldName + '[' + i + ']');
index 127d3c631b564e032f91b08c0dae1f4fc2e85c9c..8ce57e09380999530a859dd12dfbc726f7398b26 100644 (file)
@@ -164,9 +164,6 @@ public class LttngKernelExecGraphProvider extends AbstractTmfGraphProvider {
             }
         }
         for (LttngWorker k : kernelWorker) {
-            if (k == null) {
-                throw new NullPointerException();
-            }
             List<TmfVertex> nodes = graph.getNodesOf(k);
             for (TmfVertex node : nodes) {
                 /*
index 36d0340f798451186d2ea38aae552d5acb73bfaf..5ecd6a5510e434404b2610313a4e853a9c6917fe 100644 (file)
@@ -18,7 +18,7 @@ import org.eclipse.osgi.util.NLS;
  * @author Francis Giraldeau <francis.giraldeau@gmail.com>
  *
  */
-@NonNullByDefault(false)
+@NonNullByDefault({})
 public class Messages extends NLS {
     private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.handlers.messages"; //$NON-NLS-1$
 
index ddccd32e7d2b3fe225bd23a0c115d586cd5a171f..d7ab07235b6a5428f4a86927e7885e3b8c8ffe6d 100644 (file)
@@ -12,6 +12,7 @@ package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.hand
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Map;
 
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jdt.annotation.Nullable;
@@ -62,7 +63,7 @@ public class TraceEventHandlerExecutionGraph extends BaseHandler {
 
     private final Table<String, Integer, LttngWorker> fKernel;
     private final IMatchProcessingUnit fMatchProcessing;
-    private HashMap<ITmfEvent, TmfVertex> fTcpNodes;
+    private Map<ITmfEvent, TmfVertex> fTcpNodes;
     private TmfEventMatching fTcpMatching;
 
     /**
@@ -100,7 +101,7 @@ public class TraceEventHandlerExecutionGraph extends BaseHandler {
             }
 
             @Override
-            public void init(@Nullable Collection<ITmfTrace> fTraces) {
+            public void init(Collection<ITmfTrace> fTraces) {
 
             }
 
index f7961de676a3a57409f7f06a6cf9c94f4c4d5d6a..d3b264c35226a1d14df6decb00702a70597a525a 100644 (file)
@@ -138,9 +138,6 @@ public class LttngSystemModel {
             return LttngInterruptContext.DEFAULT_CONTEXT;
         }
         LttngInterruptContext peek = stack.peek();
-        if (peek == null) {
-            peek = LttngInterruptContext.DEFAULT_CONTEXT;
-        }
         return peek;
     }
 
index bb5f974e7969676ae7f2b578f73bd16be94b7f62..66fc0e0f3bcd04df255a0fba2bb5b367662317de 100644 (file)
@@ -12,6 +12,7 @@
 
 package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.model;
 
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
 
 import com.google.common.collect.HashBasedTable;
@@ -25,7 +26,7 @@ import com.google.common.collect.Table;
  */
 public class VirtualCPU {
 
-    private static final Table<VirtualMachine, Long, VirtualCPU> VIRTUAL_CPU_TABLE = NonNullUtils.checkNotNull(HashBasedTable.<VirtualMachine, Long, VirtualCPU> create());
+    private static final Table<VirtualMachine, Long, @Nullable VirtualCPU> VIRTUAL_CPU_TABLE = NonNullUtils.checkNotNull(HashBasedTable.<VirtualMachine, Long, VirtualCPU> create());
 
     private final VirtualMachine fVm;
     private final Long fCpuId;
index 6cc1155b8abdd8a61fdbdd89e00a7e8fa166444e..22b17a7c0d614302cf535d094b3f4e74102bf481 100644 (file)
@@ -110,7 +110,7 @@ public class VirtualMachineCpuAnalysis extends TmfStateSystemAnalysisModule {
          * Create the multimap for threads with the appropriate comparator
          * objects for keys and values
          */
-        final Multimap<Integer, ITmfStateInterval> map = NonNullUtils.checkNotNull(TreeMultimap.<Integer, ITmfStateInterval> create(
+        final Multimap<Integer, ITmfStateInterval> map = NonNullUtils.checkNotNull(TreeMultimap.<@NonNull Integer, @NonNull ITmfStateInterval> create(
                 new Comparator<Integer>() {
                     @Override
                     public int compare(@Nullable Integer arg0, @Nullable Integer arg1) {
@@ -195,9 +195,6 @@ public class VirtualMachineCpuAnalysis extends TmfStateSystemAnalysisModule {
          * module
          */
         for (Integer tid : KernelThreadInformationProvider.getThreadIds(kernelModule)) {
-            if (tid == null) {
-                throw new IllegalStateException();
-            }
             map.putAll(tid, KernelThreadInformationProvider.getStatusIntervalsForThread(kernelModule, tid, start, end, resolution, monitor));
             if (monitor.isCanceled()) {
                 return map;
index 706f44ae87ad9c13a605f767c228b377b9edc64a..08904b328e174d378c5062d7a15a9f62ed9168f3 100644 (file)
@@ -83,7 +83,7 @@ public class VirtualMachineStateProvider extends AbstractTmfStateProvider {
 
     /* TODO: An analysis should support many hypervisor models */
     private IVirtualMachineModel fModel;
-    private final Table<ITmfTrace, String, Integer> fEventNames;
+    private final Table<ITmfTrace, String, @Nullable Integer> fEventNames;
     private final Map<ITmfTrace, IKernelAnalysisEventLayout> fLayouts;
 
     // ------------------------------------------------------------------------
@@ -100,7 +100,7 @@ public class VirtualMachineStateProvider extends AbstractTmfStateProvider {
         super(experiment, "Virtual Machine State Provider"); //$NON-NLS-1$
 
         fModel = new QemuKvmVmModel(experiment);
-        Table<ITmfTrace, String, Integer> table = NonNullUtils.checkNotNull(HashBasedTable.<ITmfTrace, String, Integer> create());
+        Table<ITmfTrace, String, @Nullable Integer> table = NonNullUtils.checkNotNull(HashBasedTable.<ITmfTrace, String, Integer> create());
         fEventNames = table;
         fLayouts = new HashMap<>();
     }
@@ -373,4 +373,4 @@ public class VirtualMachineStateProvider extends AbstractTmfStateProvider {
         return new HostThread(hostId, currentTid);
     }
 
-}
\ No newline at end of file
+}
index 89ff6997cfb925957b1de930d6e87eb8f0ad87b3..3a58e05ae375ed82d1eaa8f3f23a9ead6718ece7 100644 (file)
@@ -42,9 +42,9 @@ import com.google.common.collect.ImmutableSet;
  */
 public class TcpLttngEventMatching implements ITmfMatchEventDefinition {
 
-    private static final @NonNull String[] KEY_SEQ = { TcpEventStrings.TRANSPORT_FIELDS, TcpEventStrings.TYPE_TCP, TcpEventStrings.SEQ };
-    private static final @NonNull String[] KEY_ACKSEQ = { TcpEventStrings.TRANSPORT_FIELDS, TcpEventStrings.TYPE_TCP, TcpEventStrings.ACKSEQ };
-    private static final @NonNull String[] KEY_FLAGS = { TcpEventStrings.TRANSPORT_FIELDS, TcpEventStrings.TYPE_TCP, TcpEventStrings.FLAGS };
+    private static final String @NonNull [] KEY_SEQ = { TcpEventStrings.TRANSPORT_FIELDS, TcpEventStrings.TYPE_TCP, TcpEventStrings.SEQ };
+    private static final String @NonNull [] KEY_ACKSEQ = { TcpEventStrings.TRANSPORT_FIELDS, TcpEventStrings.TYPE_TCP, TcpEventStrings.ACKSEQ };
+    private static final String @NonNull [] KEY_FLAGS = { TcpEventStrings.TRANSPORT_FIELDS, TcpEventStrings.TYPE_TCP, TcpEventStrings.FLAGS };
 
     private static final ImmutableSet<String> REQUIRED_EVENTS = ImmutableSet.of(
             TcpEventStrings.NET_DEV_QUEUE,
index 24e35d154a8e6141d9956eb1b7d9fca9a8e11479..3a87c31169cfc44425b0ce549d4803f4d34442a4 100644 (file)
@@ -208,7 +208,7 @@ public class EthernetIIPacket extends Packet {
     public Map<String, String> getFields() {
         Map<String, String> map = fFields;
         if (map == null) {
-            ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder();
+            ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
             builder.put("Source MAC Address", ConversionHelper.toMacAddress(fSourceMacAddress)); //$NON-NLS-1$
             builder.put("Destination MAC Address", ConversionHelper.toMacAddress(fDestinationMacAddress)); //$NON-NLS-1$
             builder.put("Ethertype", String.valueOf(EthertypeHelper.toEtherType(fType))); //$NON-NLS-1$
index cff699650e68ffdaa75bbbd57a1c9e683deb38d0..44d9e6627711840fb88fe54ec17af3e48534282d 100644 (file)
@@ -62,7 +62,7 @@ public class IPv4Packet extends Packet {
     private final int fHeaderChecksum;
     private final Inet4Address fSourceIpAddress;
     private final Inet4Address fDestinationIpAddress;
-    private final @Nullable byte[] fOptions;
+    private final byte @Nullable [] fOptions;
 
     private @Nullable IPv4Endpoint fSourceEndpoint;
     private @Nullable IPv4Endpoint fDestinationEndpoint;
@@ -392,7 +392,7 @@ public class IPv4Packet extends Packet {
      *
      * @return The options of the packet.
      */
-    public @Nullable byte[] getOptions() {
+    public byte @Nullable [] getOptions() {
         final byte[] options = fOptions;
         if (options == null) {
             return null;
index 6e6109dac493a9563471926ff136175932819fcd..595f464ad31d33e6cc2309d80e683a71c4efd013 100644 (file)
@@ -59,7 +59,7 @@ public class TCPPacket extends Packet {
     private final int fWindowSize;
     private final int fChecksum;
     private final int fUrgentPointer;
-    private final @Nullable byte[] fOptions; // TODO Interpret options.
+    private final byte @Nullable [] fOptions; // TODO Interpret options.
 
     private @Nullable TCPEndpoint fSourceEndpoint;
     private @Nullable TCPEndpoint fDestinationEndpoint;
@@ -382,7 +382,7 @@ public class TCPPacket extends Packet {
      *
      * @return The options of the packet.
      */
-    public @Nullable byte[] getOptions() {
+    public byte @Nullable [] getOptions() {
         byte[] options = fOptions;
         if (options == null) {
             return null;
index f9ce624a2f525ad9a69776dc5c3cf3f41a8df995..3a6e4d803458efccebdcfe23bd7dd84b369e77ac 100644 (file)
@@ -16,7 +16,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.osgi.util.NLS;
 
-@NonNullByDefault(false)
+@NonNullByDefault({})
 @SuppressWarnings("javadoc")
 public class Messages extends NLS {
 
index 07eb86f0ff4235270257c1980841065c2a9d34e9..be158043c0c2f9dd7ed574a1b7a527229fda6b7a 100644 (file)
 package org.eclipse.tracecompass.internal.tmf.pcap.core.event;
 
 import java.util.ArrayList;
-import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
 
 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
 import org.eclipse.tracecompass.internal.pcap.core.protocol.PcapProtocol;
 import org.eclipse.tracecompass.internal.pcap.core.protocol.pcap.PcapPacket;
-import org.eclipse.tracecompass.internal.pcap.core.stream.PacketStream;
 import org.eclipse.tracecompass.internal.pcap.core.stream.PacketStreamBuilder;
 import org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol;
 import org.eclipse.tracecompass.internal.tmf.pcap.core.util.ProtocolConversion;
@@ -74,13 +74,8 @@ public class TmfPacketStreamBuilder {
     public synchronized Iterable<TmfPacketStream> getStreams() {
         // We can't store in immutable list since the stream number/content can
         // change dynamically.
-        List<TmfPacketStream> list = new ArrayList<>();
-        for (PacketStream stream : fBuilder.getStreams()) {
-            if (stream != null) {
-                list.add(new TmfPacketStream(stream));
-            }
-        }
-        return list;
+        return StreamSupport.stream(fBuilder.getStreams().spliterator(), false)
+                .map(e -> new TmfPacketStream(e))
+                .collect(Collectors.toCollection(ArrayList::new));
     }
-
 }
index bc43a39492dce3598454840fe12b48081d0787f3..2f5b911311a1fda35b0bbe7d634bff6b86e8689b 100644 (file)
@@ -30,6 +30,7 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.pcap.core.packet.BadPacketException;
 import org.eclipse.tracecompass.internal.pcap.core.protocol.pcap.PcapPacket;
 import org.eclipse.tracecompass.internal.pcap.core.trace.BadPcapFileException;
@@ -252,13 +253,13 @@ public class PcapTrace extends TmfTrace implements ITmfTraceProperties {
 
         Map<String, String> properties = fTraceProperties;
         if (properties == null) {
-            ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder();
-            builder.put(Messages.PcapTrace_Version, String.format("%d%c%d", pcap.getMajorVersion(), '.', pcap.getMinorVersion())); //$NON-NLS-1$
-            builder.put(Messages.PcapTrace_TimeZoneCorrection, pcap.getTimeZoneCorrection() + " s"); //$NON-NLS-1$
-            builder.put(Messages.PcapTrace_TimestampAccuracy, String.valueOf(pcap.getTimeAccuracy()));
-            builder.put(Messages.PcapTrace_MaxSnapLength, pcap.getSnapLength() + " bytes"); //$NON-NLS-1$
-            builder.put(Messages.PcapTrace_LinkLayerHeaderType, LinkTypeHelper.toString((int) pcap.getDataLinkType()) + " (" + pcap.getDataLinkType() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-            builder.put(Messages.PcapTrace_FileEndianness, pcap.getByteOrder().toString());
+            ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
+            builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_Version), String.format("%d%c%d", pcap.getMajorVersion(), '.', pcap.getMinorVersion())); //$NON-NLS-1$
+            builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_TimeZoneCorrection), pcap.getTimeZoneCorrection() + " s"); //$NON-NLS-1$
+            builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_TimestampAccuracy), String.valueOf(pcap.getTimeAccuracy()));
+            builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_MaxSnapLength), pcap.getSnapLength() + " bytes"); //$NON-NLS-1$
+            builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_LinkLayerHeaderType), LinkTypeHelper.toString((int) pcap.getDataLinkType()) + " (" + pcap.getDataLinkType() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+            builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_FileEndianness), pcap.getByteOrder().toString());
 
             return checkNotNull(builder.build());
 
index 164b3c9ddaf858bc83b284f8a0065e4c3f925277..cfa3eebff81e3b31ab64f02561751b92dc60c0ac 100644 (file)
@@ -283,9 +283,6 @@ public class StreamListView extends TmfView {
                 }
                 for (Entry<TmfPcapProtocol, Table> protocolEntry : tables.entrySet()) {
                     TmfPcapProtocol protocol = protocolEntry.getKey();
-                    if (protocol == null) {
-                        throw new IllegalStateException();
-                    }
                     TmfPacketStreamBuilder builder = analysis.getBuilder(protocol);
                     Table table = protocolEntry.getValue();
                     if (builder != null && !(table.isDisposed())) {
diff --git a/pom.xml b/pom.xml
index fbd5a5c763d402f0c58dad981510e09359b6d729..1674eb44a741b71624e52073121d634141cc5aa4 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                         <version>2.0.0</version>
                       </artifact>
                     </target>
-                    <filters>
-                      <filter>
-                        <type>eclipse-plugin</type>
-                        <id>org.eclipse.jdt.annotation</id>
-                        <restrictTo>
-                          <versionRange>[1.0,2.0)</versionRange>
-                        </restrictTo>
-                      </filter>
-                    </filters>
                 </configuration>
             </plugin>
             <plugin>
           <configuration>
             <encoding>UTF-8</encoding>
             <useProjectSettings>true</useProjectSettings>
+            <compilerArguments>
+              <annotationpath>common/org.eclipse.tracecompass.common.core/annotations</annotationpath>
+            </compilerArguments>
           </configuration>
         </plugin>
         <plugin>
index 209c934c020d6ca06832bf7c848052e4222c1f74..75b6caa33f8b4889048f846114737dda0dba946a 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="tracecompass-e4.5" sequenceNumber="56">
+<?pde version="3.8"?><target name="tracecompass-e4.5" sequenceNumber="57">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/>
@@ -44,7 +44,7 @@
 <unit id="org.eclipse.pde.runtime" version="0.0.0"/>
 <unit id="org.eclipse.pde.junit.runtime" version="0.0.0"/>
 <unit id="org.eclipse.test.feature.group" version="0.0.0"/>
-<unit id="org.eclipse.jdt.annotation" version="1.1.100.v20140704-0625"/>
+<unit id="org.eclipse.jdt.annotation" version="2.0.100.v20150311-1658"/>
 <unit id="org.eclipse.ui.views.log" version="0.0.0"/>
 <repository location="http://download.eclipse.org/eclipse/updates/4.5/"/>
 </location>
index ec801186111c4f0f391cff44a11945c94317c2e6..15597f2ba4befd599023a2845073e62e98af8b69 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="tracecompass-eStaging" sequenceNumber="49">
+<?pde version="3.8"?><target name="tracecompass-eStaging" sequenceNumber="50">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/>
@@ -41,7 +41,7 @@
 </location>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.eclipse.test.feature.group" version="0.0.0"/>
-<unit id="org.eclipse.jdt.annotation" version="1.1.100.v20140704-0625"/>
+<unit id="org.eclipse.jdt.annotation" version="2.0.100.v20150311-1658"/>
 <repository location="http://download.eclipse.org/eclipse/updates/4.5/"/>
 </location>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
index 41beea22eb94aee976efa92656b689ed2a76a79f..8d6e097f2718d4954a44a37b87c036deee55d535 100644 (file)
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertTrue;
 import java.util.Arrays;
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.segmentstore.core.BasicSegment;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
 import org.eclipse.tracecompass.segmentstore.core.treemap.TreeMapStore;
@@ -35,7 +36,7 @@ import com.google.common.collect.Lists;
  */
 public class TreeMapStoreTest {
 
-    private TreeMapStore<ISegment> fSegmentStore;
+    private TreeMapStore<@NonNull ISegment> fSegmentStore;
 
     private static final ISegment SEGMENT_2_6 = new BasicSegment(2, 6);
     private static final ISegment SEGMENT_4_6 = new BasicSegment(4, 6);
@@ -112,7 +113,7 @@ public class TreeMapStoreTest {
      */
     @Test
     public void testToSpecifyArraySubtype() {
-        TreeMapStore<BasicSegment> tms2 = new TreeMapStore<>();
+        TreeMapStore<@NonNull BasicSegment> tms2 = new TreeMapStore<>();
         BasicSegment otherSegment = new BasicSegment(2, 6);
         tms2.add(otherSegment);
         BasicSegment[] array = tms2.toArray(new BasicSegment[0]);
@@ -153,7 +154,7 @@ public class TreeMapStoreTest {
     @Test
     public void testIterationOrderNonSortedInsertion() {
         /* Prepare the segment store, we don't use the 'fixture' in this test */
-        TreeMapStore<ISegment> store = new TreeMapStore<>();
+        TreeMapStore<@NonNull ISegment> store = new TreeMapStore<>();
         for (ISegment segment : REVERSE_SEGMENTS) {
             store.add(checkNotNull(segment));
         }
@@ -291,7 +292,7 @@ public class TreeMapStoreTest {
      */
     @Test
     public void testDispose() {
-        TreeMapStore<ISegment> store = new TreeMapStore<>();
+        TreeMapStore<@NonNull ISegment> store = new TreeMapStore<>();
         store.add(SEGMENT_2_6);
         store.dispose();
         assertEquals(0, store.size());
index fa5b2b8616bc9f26181188df7d5b27f948c919c0..01ce5017c848f6cda6c931420e016434ea7d2abd 100644 (file)
@@ -171,7 +171,7 @@ public class TreeMapStore<E extends ISegment> implements ISegmentStore<E> {
     }
 
     @Override
-    public <T> T[] toArray(@Nullable T[] a) {
+    public <T> T[] toArray(T @Nullable[] a) {
         fLock.readLock().lock();
         try {
             return checkNotNull(fStartTimesIndex.values().toArray(a));
index 6d2350b96d17310bddd5a63e58996a0401541e72..2ea13f74b3adc6fb83bea2f5f4ac060a51d4dce3 100644 (file)
@@ -198,7 +198,7 @@ public final class Attribute {
      *
      * @return The full attribute path elements
      */
-    public @NonNull String[] getFullAttribute() {
+    public String @NonNull [] getFullAttribute() {
         LinkedList<String> list = new LinkedList<>();
         Attribute curNode = this;
 
index 3ac74c8218a241943d7587869384bdb70356db18..97f8777de4466fc0781fe79e4dc1c588b3e29437 100644 (file)
@@ -337,7 +337,7 @@ public final class AttributeTree {
      *            The quark of the attribute
      * @return The path elements of the full path
      */
-    public synchronized @NonNull String[] getFullAttributePathArray(int quark) {
+    public synchronized String @NonNull [] getFullAttributePathArray(int quark) {
         return attributeList.get(quark).getFullAttribute();
     }
 
index bfe449dfc2c4fc7557f60bd1c87fe61385118d3c..b7c4fc81f45392e80b7098ab840cb28ea16cc83d 100644 (file)
@@ -98,11 +98,7 @@ public class TransientState {
         fRWLock.readLock().lock();
         try {
             checkValidAttribute(quark);
-            ITmfStateValue ret = fOngoingStateInfo.get(quark);
-            if (ret == null) {
-                throw new IllegalStateException("Null interval stored in transient state"); //$NON-NLS-1$
-            }
-            return ret;
+            return fOngoingStateInfo.get(quark);
         } finally {
             fRWLock.readLock().unlock();
         }
index 9cb4c23772c38d8bd4ced6f02c447655bd9acb15..3f63cb6955deaf2509f7849754467680790bea2b 100644 (file)
@@ -259,7 +259,7 @@ public interface ITmfStateSystem {
      *             If the attribute quark is out of range
      * @since 1.0
      */
-    @NonNull String[] getFullAttributePathArray(int attributeQuark);
+    String @NonNull [] getFullAttributePathArray(int attributeQuark);
 
     /**
      * Returns the parent quark of the attribute.
index 51a0d6774fff9ef397de49cb7e8a3414843f4595..ebb4e6598e20a8558adfc7a66611c5e4b3b32e2a 100644 (file)
@@ -85,7 +85,7 @@ public class TmfXmlCondition {
 
         Element rootNode = node;
         /* Process the conditions: in each case, only process Element nodes */
-        List<Element> childElements = XmlUtils.getChildElements(rootNode);
+        List<@Nullable Element> childElements = XmlUtils.getChildElements(rootNode);
 
         /*
          * If the node is an if, take the child as the root condition
@@ -100,6 +100,10 @@ public class TmfXmlCondition {
             childElements = XmlUtils.getChildElements(rootNode);
         }
 
+        if (rootNode == null) {
+            throw new IllegalArgumentException();
+        }
+
         switch (rootNode.getNodeName()) {
         case TmfXmlStrings.CONDITION:
             fOperator = LogicalOperator.NONE;
@@ -141,8 +145,13 @@ public class TmfXmlCondition {
              * A state value is either preceded by an eventField or a number of
              * state attributes
              */
-            if (childElements.size() == 1 && childElements.get(0).getNodeName().equals(TmfXmlStrings.ELEMENT_FIELD)) {
-                String attribute = childElements.get(0).getAttribute(TmfXmlStrings.NAME);
+            @Nullable Element firstChild = childElements.get(0);
+            if (firstChild == null) {
+                throw new IllegalStateException();
+            }
+
+            if (childElements.size() == 1 && firstChild.getNodeName().equals(TmfXmlStrings.ELEMENT_FIELD)) {
+                String attribute = firstChild.getAttribute(TmfXmlStrings.NAME);
                 if (attribute == null) {
                     throw new IllegalArgumentException();
                 }
@@ -150,7 +159,7 @@ public class TmfXmlCondition {
             } else {
                 List<ITmfXmlStateAttribute> attributes = new ArrayList<>();
                 for (Element element : childElements) {
-                    if (!element.getNodeName().equals(TmfXmlStrings.STATE_ATTRIBUTE)) {
+                    if (element == null || !element.getNodeName().equals(TmfXmlStrings.STATE_ATTRIBUTE)) {
                         throw new IllegalArgumentException("TmfXmlCondition: a condition either has a eventField element or a number of TmfXmlStateAttribute elements before the state value"); //$NON-NLS-1$
                     }
                     ITmfXmlStateAttribute attribute = modelFactory.createStateAttribute(element, fContainer);
index abd24f4434837bc1fc5f333fbe64634f953428cc..71c92c3518599b387ee0906e8012706353d33d4a 100644 (file)
@@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.model;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.Activator;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
 import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
@@ -67,12 +68,9 @@ public class TmfXmlEventHandler {
         }
         fName = name;
 
-        List<Element> childElements = XmlUtils.getChildElements(node, TmfXmlStrings.STATE_CHANGE);
+        List<@NonNull Element> childElements = XmlUtils.getChildElements(node, TmfXmlStrings.STATE_CHANGE);
         /* load state changes */
         for (Element childElem : childElements) {
-            if (childElem == null) {
-                continue;
-            }
             TmfXmlStateChange stateChange = modelFactory.createStateChange(childElem, fParent);
             fStateChangeList.add(stateChange);
         }
index 04991c6d3f0f10e678301f5530ca6ac9f1f88cc9..320a68772395f9c66a94a0ec6ddaad5866a86bef 100644 (file)
@@ -64,7 +64,7 @@ public class TmfXmlLocation {
         fId = id;
         fContainer = container;
 
-        List<Element> childElements = XmlUtils.getChildElements(location);
+        List<@Nullable Element> childElements = XmlUtils.getChildElements(location);
         for (Element attribute : childElements) {
             if (attribute == null) {
                 continue;
index 670b3ffc080a1b62278c8537a16848190d11850f..5816b9f2d681ffeac4b4a6d62b10b3e87759d807 100644 (file)
@@ -98,7 +98,7 @@ public abstract class TmfXmlStateAttribute implements ITmfXmlStateAttribute {
             fName = fContainer.getAttributeValue(attribute.getAttribute(TmfXmlStrings.VALUE));
             break;
         case TmfXmlStrings.TYPE_QUERY:
-            List<Element> childElements = XmlUtils.getChildElements(attribute);
+            List<@Nullable Element> childElements = XmlUtils.getChildElements(attribute);
             for (Element subAttributeNode : childElements) {
                 if (subAttributeNode == null) {
                     continue;
index 52e317573ac22d2a6da06cba067574aea4d9de0f..8f238da3d85956b8dadd2884184a409a82f099a3 100644 (file)
@@ -187,7 +187,7 @@ public class TmfXmlStateChange {
         private final ITmfXmlStateValue fValue;
 
         public XmlStateValueChange(ITmfXmlModelFactory modelFactory, Element statechange) {
-            List<Element> childElements = XmlUtils.getChildElements(statechange);
+            List<@Nullable Element> childElements = XmlUtils.getChildElements(statechange);
 
             /*
              * Last child element is the state value, the others are attributes
@@ -199,7 +199,7 @@ public class TmfXmlStateChange {
             }
             List<ITmfXmlStateAttribute> attributes = new ArrayList<>();
             for (Element element : childElements) {
-                if (!element.getNodeName().equals(TmfXmlStrings.STATE_ATTRIBUTE)) {
+                if (element == null || !element.getNodeName().equals(TmfXmlStrings.STATE_ATTRIBUTE)) {
                     throw new IllegalArgumentException("TmfXmlStateChange: a state change must have only TmfXmlStateAttribute elements before the state value"); //$NON-NLS-1$
                 }
                 ITmfXmlStateAttribute attribute = modelFactory.createStateAttribute(element, fContainer);
index a9264234a6f0cce75b943cc842c84fed7403fb49..d92d20d74f5245eb8eb3a1045c9df890cc2c86ea 100644 (file)
@@ -134,7 +134,7 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue {
             break;
         case TmfXmlStrings.TYPE_QUERY:
             /* Value is the result of a query */
-            List<Element> children = XmlUtils.getChildElements(node);
+            List<@Nullable Element> children = XmlUtils.getChildElements(node);
             List<ITmfXmlStateAttribute> childAttributes = new ArrayList<>();
             for (Element child : children) {
                 if (child == null) {
index 79a8357e0bdafb4e31e46bcb25893dabe05b0903..af855e0593a7d07feb64ea376df68ab1dc1312d8 100644 (file)
@@ -12,6 +12,7 @@
 
 package org.eclipse.tracecompass.tmf.analysis.xml.core.module;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlLocation;
 
@@ -47,6 +48,6 @@ public interface IXmlStateSystemContainer extends ITmfXmlTopLevelElement {
      *
      * @return The list of {@link TmfXmlLocation}
      */
-    Iterable<TmfXmlLocation> getLocations();
+    @NonNull Iterable<@NonNull TmfXmlLocation> getLocations();
 
 }
index d8437fa982ead146d6c2917b2467d863e42b61ec..a53bf205ca2c412485be89a130d975d3d8f899c2 100644 (file)
@@ -36,6 +36,7 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.Activator;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
@@ -159,9 +160,9 @@ public class XmlUtils {
      *            The parent element to get children from
      * @return The list of children Element of the parent
      */
-    public static List<Element> getChildElements(Element parent) {
+    public static List<@Nullable Element> getChildElements(Element parent) {
         NodeList childNodes = parent.getChildNodes();
-        List<Element> childElements = new ArrayList<>();
+        List<@Nullable Element> childElements = new ArrayList<>();
         for (int index = 0; index < childNodes.getLength(); index++) {
             if (childNodes.item(index).getNodeType() == Node.ELEMENT_NODE) {
                 childElements.add((Element) childNodes.item(index));
@@ -180,10 +181,10 @@ public class XmlUtils {
      *            The tag of the elements to return
      * @return The list of children {@link Element} of the parent
      */
-    public static List<Element> getChildElements(Element parent, String elementTag) {
+    public static List<@NonNull Element> getChildElements(Element parent, String elementTag) {
         /* get the state providers and find the corresponding one */
         NodeList nodes = parent.getElementsByTagName(elementTag);
-        List<Element> childElements = new ArrayList<>();
+        List<@NonNull Element> childElements = new ArrayList<>();
 
         for (int i = 0; i < nodes.getLength(); i++) {
             Element node = (Element) nodes.item(i);
index 43b8dfd5c53397e25d626e8a6f8e037d543d82ba..a68aa98f4f50bee2ae20181fea08a3ad203cb490 100644 (file)
@@ -18,3 +18,5 @@ bin.includes = META-INF/,\
                plugin.xml,\
                test_xml_files/
 src.includes = about.html
+additional.bundles = org.eclipse.jdt.annotation
+jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
index 36ba8fee6797b02abf3d855468817771ed5c1831..86e53bc2349d3e5da47b629e2daccbd9b6fd9ce1 100644 (file)
@@ -21,3 +21,4 @@ Export-Package: org.eclipse.tracecompass.internal.tmf.analysis.xml.ui;x-friends:
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.xychart;x-internal:=true,
  org.eclipse.tracecompass.tmf.analysis.xml.ui.module,
  org.eclipse.tracecompass.tmf.analysis.xml.ui.views.timegraph
+Import-Package: com.google.common.collect
index 17ef228453fa3fce35604603155346061cb3c07f..60a866f550fd57ff4fd8f55cb14394d6ea6eb183 100644 (file)
@@ -23,6 +23,7 @@ import java.util.regex.Pattern;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator;
@@ -85,7 +86,7 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
     private class SeriesData {
 
         private final double[] fYValues;
-        private final @Nullable double[] fYAbsoluteValues;
+        private final double @Nullable [] fYAbsoluteValues;
         private final Integer fDisplayQuark;
         private final String fName;
         private final DisplayType fType;
@@ -177,7 +178,7 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
         }
 
         @Override
-        public @Nullable Iterable<TmfXmlLocation> getLocations() {
+        public @NonNull Iterable<@NonNull TmfXmlLocation> getLocations() {
             return Collections.EMPTY_SET;
         }
 
@@ -365,10 +366,8 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
                 ((TmfStateSystemAnalysisModule) module).waitForInitialization();
             }
             for (ITmfStateSystem ssq : module.getStateSystems()) {
-                if (ssq != null) {
-                    ss = ssq;
-                    break;
-                }
+                ss = ssq;
+                break;
             }
         }
         if (ss == null) {
@@ -389,24 +388,18 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
         fEntry = entry;
 
         /* Get the display element to use */
-        List<Element> displayElements = XmlUtils.getChildElements(entryElement, TmfXmlUiStrings.DISPLAY_ELEMENT);
+        List<@NonNull Element> displayElements = XmlUtils.getChildElements(entryElement, TmfXmlUiStrings.DISPLAY_ELEMENT);
         if (displayElements.isEmpty()) {
             Activator.logWarning(String.format("XML view: entry for %s should have a display element", path)); //$NON-NLS-1$
             return;
         }
         Element displayElement = displayElements.get(0);
-        if (displayElement == null) {
-            throw new IllegalStateException();
-        }
         fDisplay = fFactory.createStateAttribute(displayElement, entry);
 
         /* Get the series name element to use */
         List<Element> seriesNameElements = XmlUtils.getChildElements(entryElement, TmfXmlUiStrings.NAME_ELEMENT);
         if (!seriesNameElements.isEmpty()) {
             Element seriesNameElement = seriesNameElements.get(0);
-            if (seriesNameElement == null) {
-                throw new IllegalStateException();
-            }
             fSeriesName = fFactory.createStateAttribute(seriesNameElement, entry);
         }
 
index 74bdaeba40523366ef1fb29cb1897dce7bab12a9..febc1a0ee0b19e585b4ad172223d86b698f33cde 100644 (file)
@@ -279,9 +279,6 @@ public class XmlTimeGraphView extends AbstractTimeGraphView {
                     ((TmfStateSystemAnalysisModule) module).waitForInitialization();
                 }
                 for (ITmfStateSystem ssq : module.getStateSystems()) {
-                    if (ssq == null) {
-                        return;
-                    }
                     ssq.waitUntilBuilt();
 
                     long startTime = ssq.getStartTime();
index 39b1dcc7798f94287aa7baae858872500c957afc..c73794ac004fbe3c40f29b1088a2e5c2dd87de96 100644 (file)
@@ -13,7 +13,8 @@ Require-Bundle: org.junit;bundle-version="4.0.0",
  org.eclipse.core.resources,
  org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core,
- org.eclipse.test.performance
+ org.eclipse.test.performance,
+ org.eclipse.cdt.core
 Export-Package: org.eclipse.tracecompass.tmf.core.tests,
  org.eclipse.tracecompass.tmf.core.tests.perf,
  org.eclipse.tracecompass.tmf.core.tests.shared,
index a51fd3d6f673105b28f8258d9ac2e3325a117a22..739b398b75847752690106c8341a495e52dbfa95 100644 (file)
@@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.core.tests.trace.text;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -188,6 +189,7 @@ public class TextTraceTest {
     public void testTraceParsing() {
         ITmfContext context = fTrace.seekEvent(0);
         SyslogEvent event = fTrace.getNext(context);
+        assertNotNull(event);
         TextTraceEventContent content = event.getContent();
         assertEquals("getTimestamp", "Jan 1 01:01:01", event.getTimestamp().toString());
         assertEquals("getField:HOST", "HostA", content.getFieldValue(Field.HOST));
@@ -196,6 +198,7 @@ public class TextTraceTest {
         assertEquals("getField:LINE", "4", content.getFieldValue(Field.LINE));
         assertEquals("getField:MESSAGE", "Message A", content.getFieldValue(Field.MESSAGE).toString());
         event = fTrace.getNext(context);
+        assertNotNull(event);
         content = event.getContent();
         assertEquals("getTimestamp", "Jan 1 02:02:02", event.getTimestamp().toString());
         assertEquals("getField:HOST", "HostB", content.getFieldValue(Field.HOST));
@@ -204,6 +207,7 @@ public class TextTraceTest {
         assertEquals("getField:LINE", "5", content.getFieldValue(Field.LINE));
         assertEquals("getField:MESSAGE", "Message B", content.getFieldValue(Field.MESSAGE).toString());
         event = fTrace.getNext(context);
+        assertNotNull(event);
         content = event.getContent();
         assertEquals("getTimestamp", "Jan 1 03:03:03", event.getTimestamp().toString());
         assertEquals("getField:HOST", "HostC", content.getFieldValue(Field.HOST));
@@ -212,6 +216,7 @@ public class TextTraceTest {
         assertEquals("getField:LINE", "6", content.getFieldValue(Field.LINE));
         assertEquals("getField:MESSAGE", "Message C", content.getFieldValue(Field.MESSAGE).toString());
         event = fTrace.getNext(context);
+        assertNotNull(event);
         content = event.getContent();
         assertEquals("getTimestamp", "Jan 1 04:04:04", event.getTimestamp().toString());
         assertEquals("getField:HOST", "HostD", content.getFieldValue(Field.HOST));
@@ -220,6 +225,7 @@ public class TextTraceTest {
         assertEquals("getField:LINE", "7", content.getFieldValue(Field.LINE));
         assertEquals("getField:MESSAGE", "Message D", content.getFieldValue(Field.MESSAGE).toString());
         event = fTrace.getNext(context);
+        assertNotNull(event);
         content = event.getContent();
         assertEquals("getTimestamp", "Jan 1 05:05:05", event.getTimestamp().toString());
         assertEquals("getField:HOST", "HostE", content.getFieldValue(Field.HOST));
@@ -228,6 +234,7 @@ public class TextTraceTest {
         assertEquals("getField:LINE", "8", content.getFieldValue(Field.LINE));
         assertEquals("getField:MESSAGE", "", content.getFieldValue(Field.MESSAGE).toString());
         event = fTrace.getNext(context);
+        assertNotNull(event);
         content = event.getContent();
         assertEquals("getTimestamp", "Jan 1 06:06:06", event.getTimestamp().toString());
         assertEquals("getField:HOST", "HostF", content.getFieldValue(Field.HOST));
@@ -245,16 +252,19 @@ public class TextTraceTest {
         ITmfContext context = fTrace.seekEvent(3);
         double ratio = fTrace.getLocationRatio(context.getLocation());
         SyslogEvent event = fTrace.getNext(context);
+        assertNotNull(event);
         TextTraceEventContent content = event.getContent();
         Object logger = content.getFieldValue(Field.LOGGER);
         context.dispose();
         context = fTrace.seekEvent(ratio);
         event = fTrace.getNext(context);
+        assertNotNull(event);
         content = event.getContent();
         assertEquals("getField:LOGGER", logger.toString(), content.getFieldValue(Field.LOGGER).toString());
         context.dispose();
         context = fTrace.seekEvent(0.0);
         event = fTrace.getNext(context);
+        assertNotNull(event);
         content = event.getContent();
         assertEquals("getField:LOGGER", "LoggerA", content.getFieldValue(Field.LOGGER));
         context.dispose();
index 0681f0ce8997be25d144929d94f83d7481e6d792..29cab03fc474f8012c199ffc0f8c9e6eeb50d178 100644 (file)
@@ -9,6 +9,8 @@
 
 package org.eclipse.tracecompass.internal.tmf.core.analysis;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -82,10 +84,11 @@ public final class TmfAnalysisParameterProviders {
                         continue;
                     }
                     if (analysisId.equals(id)) {
-                        if (fParamProviderInstances.containsKey(className)) {
-                            providers.add(fParamProviderInstances.get(className));
+                        IAnalysisParameterProvider provider = fParamProviderInstances.get(className);
+                        if (provider != null) {
+                            providers.add(provider);
                         } else {
-                            IAnalysisParameterProvider provider = (IAnalysisParameterProvider) ce.createExecutableExtension(CLASS_ATTR);
+                            provider = checkNotNull((IAnalysisParameterProvider) ce.createExecutableExtension(CLASS_ATTR));
                             fParamProviderInstances.put(className, provider);
                             providers.add(provider);
                         }
index d118252c4bf0f31a06465d96dd8ae5024994343c..bece22a43a355ed12560d3f661d89b99dcfa97ea 100644 (file)
@@ -123,7 +123,7 @@ public final class FunctionNameMapper {
         return REMOVE_ZEROS_PATTERN.matcher(address).replaceFirst(""); //$NON-NLS-1$
     }
 
-    private static @Nullable IBinaryParser.IBinaryObject getBinaryObject(File file) {
+    private static IBinaryParser.@Nullable IBinaryObject getBinaryObject(File file) {
         IPath filePath = new Path(file.toString());
 
         /* Get all the available binary parsers */
index 3c49e41af9b54739ff75328f8e22f06689d78410..e1792622eb558de5fdfa2339c09381333e95136c 100644 (file)
@@ -12,6 +12,7 @@
 
 package org.eclipse.tracecompass.tmf.core.analysis;
 
+import org.eclipse.jdt.annotation.NonNull;
 
 /**
  * Interface that module sources must implement. A module source provides a list
@@ -31,6 +32,6 @@ public interface IAnalysisModuleSource {
      *
      * @return The analysis module helpers in iterable format
      */
-    Iterable<IAnalysisModuleHelper> getAnalysisModules();
+    @NonNull Iterable<IAnalysisModuleHelper> getAnalysisModules();
 
 }
index c7d2ea594568e947a6260d4189cfbf6d9a99bc0a..62e41fb80b7a3e55f7018ef0c4cfddcc9e084553 100644 (file)
@@ -13,6 +13,8 @@
 
 package org.eclipse.tracecompass.tmf.core.analysis;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * Interface that provides the necessary methods for an analysis to define its
  * requirements.
@@ -20,6 +22,7 @@ package org.eclipse.tracecompass.tmf.core.analysis;
  * @author Guilliano Molaire
  * @author Mathieu Rail
  */
+@NonNullByDefault
 public interface IAnalysisRequirementProvider {
 
     /**
index 7502b608981e3374296bb158cba58b499e15ee80..777be00e282f131a324296e39723694c38538190 100644 (file)
@@ -57,7 +57,7 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
     private @Nullable String fId;
     private boolean fAutomatic = false, fStarted = false;
     private volatile @Nullable ITmfTrace fTrace;
-    private final Map<String, Object> fParameters = new HashMap<>();
+    private final Map<String, @Nullable Object> fParameters = new HashMap<>();
     private final List<String> fParameterNames = new ArrayList<>();
     private final List<IAnalysisOutput> fOutputs = new ArrayList<>();
     private Set<IAnalysisParameterProvider> fParameterProviders = new HashSet<>();
index f32e5f1631791bf456e2d35b82938afda6159b0b..6899bef895a0a800beba544a3f2933549b3def57 100644 (file)
@@ -216,7 +216,7 @@ public class TmfAnalysisManager {
                         provider = providerClass.newInstance();
                         fParamProviderInstances.put(providerClass, provider);
                     }
-                    if (provider != null && provider.appliesToTrace(trace)) {
+                    if (provider.appliesToTrace(trace)) {
                         providerSet.add(provider);
                     }
                 } catch (IllegalArgumentException | SecurityException | InstantiationException | IllegalAccessException e) {
index 4be73b00f557bb8fba9473a72ac92c6c573707d2..887cce691d68ca9475b4b518dbd8532cc19e0227 100644 (file)
@@ -14,12 +14,16 @@ package org.eclipse.tracecompass.tmf.core.event;
 
 import java.util.Set;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  * Interface for events to implement to provide information about custom
  * attributes.
  *
  * @author Simon Delisle
  */
+@NonNullByDefault
 public interface ITmfCustomAttributes {
 
     /**
@@ -38,5 +42,5 @@ public interface ITmfCustomAttributes {
      * @return Value of this attribute, or null if there is no attribute with
      *         that name
      */
-    String getCustomAttribute(String name);
+    @Nullable String getCustomAttribute(String name);
 }
\ No newline at end of file
index a6a0571b85dd16d806785ad7277d8e270cbc7234..a9b7d2205067402107385d8c989b02f37241ae1c 100644 (file)
@@ -80,6 +80,6 @@ public interface ITmfEventField {
      * @param path The path to the subfield
      * @return a specific subfield by path (null if inexistent)
      */
-    ITmfEventField getField(@NonNull String... path);
+    ITmfEventField getField(String @NonNull ... path);
 
 }
index 501d61c2938e4e3746ebe20949031ca65cef26c0..bd4c1cf3ccad3a264ad27e3583e48b67d3585f39 100644 (file)
@@ -17,6 +17,7 @@ package org.eclipse.tracecompass.tmf.core.event;
 
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Map;
 
@@ -66,19 +67,15 @@ public class TmfEventField implements ITmfEventField {
      * @throws IllegalArgumentException
      *             If 'name' is null, or if 'fields' has duplicate field names.
      */
-    public TmfEventField(@NonNull String name, @Nullable Object value, @Nullable ITmfEventField[] fields) {
+    public TmfEventField(@NonNull String name, @Nullable Object value, ITmfEventField @Nullable [] fields) {
         fName = name;
         fValue = value;
 
         if (fields == null) {
             fFields = checkNotNull(ImmutableMap.<String, ITmfEventField> of());
         } else {
-            /* Java 8 streams will make this even more simple! */
             ImmutableMap.Builder<String, ITmfEventField> mapBuilder = new ImmutableMap.Builder<>();
-            for (ITmfEventField field : fields) {
-                final String curName = field.getName();
-                mapBuilder.put(curName, field);
-            }
+            Arrays.stream(fields).forEach(t -> mapBuilder.put(t.getName(), t));
             fFields = checkNotNull(mapBuilder.build());
         }
     }
index 7cfb3edfebc735021ee666f1a81e8fbcc43a91e1..ff4263c2614c5b5a9494c1ffd0a04ae19c1b0c81 100644 (file)
@@ -14,6 +14,7 @@ package org.eclipse.tracecompass.tmf.core.event.matching;
 
 import java.util.Collection;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 
 /**
@@ -24,6 +25,7 @@ import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
  *
  * @author Geneviève Bastien
  */
+@NonNullByDefault
 public interface IMatchProcessingUnit {
 
     /**
index 8f460d7e70fdbc49144a15ec4a0258a452ad04f7..998ac8bed6fd43b1e15d53b0bdefcd58f16a07b7 100644 (file)
@@ -14,6 +14,8 @@ package org.eclipse.tracecompass.tmf.core.trace;
 
 import java.util.Map;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * Interface for trace types to implement when they can provide additional
  * trace-wide properties.
@@ -23,6 +25,7 @@ import java.util.Map;
  *
  * @author Alexandre Montplaisir
  */
+@NonNullByDefault
 public interface ITmfTraceProperties {
 
     /**
index 7baceda6834606b0a6a0f00986f0d6692eca8fee..483ea1bc8728e1634ccffd0b31613e5bb29bb6b2 100644 (file)
@@ -18,6 +18,7 @@ import java.util.List;
 import java.util.Map.Entry;
 
 import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jdt.annotation.Nullable;
 
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
@@ -97,14 +98,14 @@ public class TmfTraceAdapterManager {
         Collection<Entry<Class<? extends ITmfTrace>, IAdapterFactory>> entries = fFactoriesByClass.entries();
         List<T> adapters = new ArrayList<>(factoriesById.size() + entries.size());
         for (IAdapterFactory factory : factoriesById) {
-            T adapter = factory.getAdapter(trace, adapterType);
+            @Nullable T adapter = factory.getAdapter(trace, adapterType);
             if (adapter != null) {
                 adapters.add(adapter);
             }
         }
         for (Entry<Class<? extends ITmfTrace>, IAdapterFactory> entry : entries) {
             if (entry.getKey().isInstance(trace)) {
-                T adapter = entry.getValue().getAdapter(trace, adapterType);
+                @Nullable T adapter = entry.getValue().getAdapter(trace, adapterType);
                 if (adapter != null) {
                     adapters.add(adapter);
                 }
index bfd4a812d0cbef657d72ea32151d1a8f257de322..8c13d91e489ab9247cbd9fcba77ae38bd2b37f0c 100644 (file)
@@ -26,6 +26,7 @@ import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
@@ -249,12 +250,12 @@ public abstract class TextTrace<T extends TextTraceEvent> extends TmfTrace imple
     }
 
     @Override
-    public synchronized T getNext(ITmfContext context) {
+    public synchronized @Nullable T getNext(ITmfContext context) {
         if (!(context instanceof TextTraceContext)) {
             throw new IllegalArgumentException();
         }
         TextTraceContext savedContext = new TextTraceContext(context.getLocation(), context.getRank());
-        T event = parse((TextTraceContext) context);
+        @Nullable T event = parse((TextTraceContext) context);
         if (event != null) {
             updateAttributes(savedContext, event);
             context.increaseRank();
@@ -269,7 +270,7 @@ public abstract class TextTrace<T extends TextTraceEvent> extends TmfTrace imple
      *            the context
      * @return the next event or null
      */
-    protected synchronized T parse(TextTraceContext tmfContext) {
+    protected synchronized @Nullable T parse(TextTraceContext tmfContext) {
         if (fFile == null) {
             return null;
         }
index aab941d4fe9e280e444036ffef1b327f48fa8fff..769c29c3a56289abbab02b44a69d8849c7af163d 100644 (file)
@@ -46,7 +46,7 @@ public class TextTraceEventContent implements ITmfEventField {
      * @throws IllegalArgumentException
      *             if any one of the field names is null
      */
-    public TextTraceEventContent(@NonNull String[] fieldNames) {
+    public TextTraceEventContent(String @NonNull [] fieldNames) {
         fName = ITmfEventField.ROOT_FIELD_ID;
         fValue = null;
         fFields = new ArrayList<>(fieldNames.length);
index fa9421e603b6b9561554374b307b40a113b0983d..c3c8d98530a6902fb896bbb0a22e31739dfb8d39 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.Test;
 public class CommandInputTest {
 
     private static final @NonNull String COMMAND = "my-command";
-    private static final @NonNull String[] CMD_INPUT = { "This", "are", "the", "params" };
+    private static final String @NonNull [] CMD_INPUT = { "This", "are", "the", "params" };
 
     /**
      * Test suite for the {@link CommandInput#add(String)} and {@link CommandInput#addAll(List)}
index c854530ce07ccbc222995f2794861e03c99e541a..3b40a01bc785a6f40c8a7ec8ef1a300ffcf3cd21 100644 (file)
@@ -26,9 +26,9 @@ import org.junit.Test;
  */
 public class CommandResultTest {
 
-    private static final @NonNull String[] CMD_OUTPUT = { "This", "is", "the", "output" };
-    private static final @NonNull String[] CMD_NO_ERROR_OUTPUT = {};
-    private static final @NonNull String[] CMD_ERROR_OUTPUT = { "This", "is", "the", "error", "output" };
+    private static final String @NonNull [] CMD_OUTPUT = { "This", "is", "the", "output" };
+    private static final String @NonNull [] CMD_NO_ERROR_OUTPUT = {};
+    private static final String @NonNull [] CMD_ERROR_OUTPUT = { "This", "is", "the", "error", "output" };
 
     /**
      * Test suite for the {@link CommandResult} class
index d52468078198c35aba72bb08703aa36bdc3377f7..27065c0024bc21ad46297df5a3a269a3cfe4feac 100644 (file)
@@ -39,9 +39,9 @@ public class CommandShellTest {
 
     private static final boolean IS_UNIX = !Platform.getOS().equals(Platform.OS_WIN32);
 
-    private static final @NonNull String[] CMD_INPUT_UNIX = { "ls", "-l" };
-    private static final @NonNull String[] CMD_ERROR_INPUT_UNIX = { "ls", "blablablabla" };
-    private static final @NonNull String[] CMD_UNKNOWN_COMMAND_UNIX = { "blablablabla" };
+    private static final String @NonNull [] CMD_INPUT_UNIX = { "ls", "-l" };
+    private static final String @NonNull [] CMD_ERROR_INPUT_UNIX = { "ls", "blablablabla" };
+    private static final String @NonNull [] CMD_UNKNOWN_COMMAND_UNIX = { "blablablabla" };
 
     private static final IRemoteConnection LOCAL_CONNECTION = TmfRemoteConnectionFactory.getLocalConnection();
     private static final RemoteSystemProxy LOCAL_PROXY = new RemoteSystemProxy(checkNotNull(LOCAL_CONNECTION));
index a22913f76eb817c75f0755251787a60b5c575811..828070350ebbc85bd0e72b221c57f620d5f7cf25 100644 (file)
@@ -148,7 +148,7 @@ public class CommandShell implements ICommandShell {
         return new CommandResult(result, output, error);
     }
 
-    private static @NonNull String[] splitLines(String output) {
+    private static String @NonNull [] splitLines(String output) {
         return checkNotNull(output.split("\\r?\\n")); //$NON-NLS-1$
     }
 }
index dc451859111c771cf2f83fed82ea4493f1e457ef..4fd10699bbeeeeae74b61b691932074f66de2ea5 100644 (file)
@@ -20,6 +20,7 @@ Require-Bundle: org.eclipse.core.expressions,
  org.eclipse.ui.navigator,
  org.eclipse.ui.navigator.resources,
  org.eclipse.jface.text,
+ org.eclipse.cdt.core,
  org.swtchart,
  com.ibm.icu,
  org.eclipse.linuxtools.dataviewers.piechart,
index 2e88c5a80c64dd007fa6f04a16e9baac66beeb92..a93eb88099d662cb47922373087a3151f6c5b2f0 100644 (file)
@@ -312,7 +312,7 @@ public class TmfEventPropertySource implements IPropertySource {
         /* Display custom attributes, if available */
         if (fEvent instanceof ITmfCustomAttributes) {
             ITmfCustomAttributes event = (ITmfCustomAttributes) fEvent;
-            if (event.listCustomAttributes() != null && !event.listCustomAttributes().isEmpty()) {
+            if (!event.listCustomAttributes().isEmpty()) {
                 descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_CUSTOM_ATTRIBUTE, NAME_CUSTOM_ATTRIBUTES));
             }
         }
index 32327312590730a8765072825803ce137d8da83e..56bb78530a20ace7a11ebf0af627b91b9d8f7014 100644 (file)
@@ -201,7 +201,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
     /**
      * Empty string array, used by {@link #getItemStrings}.
      */
-    protected static final @NonNull String[] EMPTY_STRING_ARRAY = new String[0];
+    protected static final String @NonNull [] EMPTY_STRING_ARRAY = new String[0];
 
     /**
      * Empty string
index 800b5eb596ba501d016759e063a2d4980d5a8eaa..573d6b4d478f58e75ed0f49b3cb2a701b0b81864 100755 (executable)
@@ -15,6 +15,8 @@ package org.eclipse.tracecompass.tmf.ui.viewers.tree;
 
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
+
 /**
  * Basic methods that must be implemented in a column data provider. Tree
  * viewers will use class implementing this to populate the columns.
@@ -28,5 +30,5 @@ public interface ITmfTreeColumnDataProvider {
      *
      * @return columns list
      */
-    List<TmfTreeColumnData> getColumnData();
+    @NonNull List<TmfTreeColumnData> getColumnData();
 }
\ No newline at end of file
index 01d4fe65ed3b666c894c1105fab322a6181f7150..e5c0db0ff844e4301e27c2334486533ff5707312 100644 (file)
@@ -14,7 +14,6 @@ package org.eclipse.tracecompass.tmf.ui.viewers.xycharts;
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.MouseEvent;
@@ -36,7 +35,6 @@ import org.swtchart.ISeries;
  * @author Bernd Hufmann
  * @since 2.0
  */
-@NonNullByDefault(false)
 public class TmfClosestDataPointTooltipProvider extends TmfBaseProvider implements MouseTrackListener, MouseMoveListener, PaintListener {
 
     // ------------------------------------------------------------------------
index 3e2622af9ffeb93f5e2f2fb94631fff7b9834235..34205de860a219cc28ee71e313348a6c98f68f65 100644 (file)
@@ -217,9 +217,7 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer {
                 ((TmfStateSystemAnalysisModule) module).waitForInitialization();
             }
             for (ITmfStateSystem ss : module.getStateSystems()) {
-                if (ss != null) {
-                    traceEntry.addChild(new StateSystemEntry(ss));
-                }
+                traceEntry.addChild(new StateSystemEntry(ss));
             }
         }
         return traceEntry;
index bde2d05028b98bdf38fc354a99e095636526995c..9b5e99ed8f2467a094f16b91ba3c2b2583b7ee46 100644 (file)
@@ -1439,7 +1439,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      *            The progress monitor object
      * @return The list of events for the entry
      */
-    protected abstract @Nullable List<ITimeEvent> getEventList(@NonNull TimeGraphEntry entry,
+    protected abstract @Nullable List<@NonNull ITimeEvent> getEventList(@NonNull TimeGraphEntry entry,
             long startTime, long endTime, long resolution,
             @NonNull IProgressMonitor monitor);
 
@@ -1457,7 +1457,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      *            The progress monitor object
      * @return The list of link events
      */
-    protected @Nullable List<ILinkEvent> getLinkList(long startTime, long endTime,
+    protected @Nullable List<@NonNull ILinkEvent> getLinkList(long startTime, long endTime,
             long resolution, @NonNull IProgressMonitor monitor) {
         return new ArrayList<>();
     }
index 79aab0851f7d0d9916b3242c5d297451c61a4191..cfb38837473834aa63906b694020d0181d25b56a 100644 (file)
@@ -1147,12 +1147,10 @@ public class SDView extends ViewPart implements IPartListener {
 
     @Override
     public <T> T getAdapter(Class<T> adapter) {
-        T obj = super.getAdapter(adapter);
         if (fSdPropertiesProvider != null && adapter.equals(IPropertySheetPage.class)) {
             return adapter.cast(fSdPropertiesProvider.getPropertySheetEntry());
         }
-
-        return obj;
+        return super.getAdapter(adapter);
     }
 
     /**
This page took 0.106375 seconds and 5 git commands to generate.