From 4c4e281658452fd4f899727b4267f478201a2654 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Mon, 25 May 2015 12:38:29 -0400 Subject: [PATCH] releng: Transition to jdt.annotation 2.0 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 Reviewed-on: https://git.eclipse.org/r/57252 Reviewed-by: Hudson CI Reviewed-by: Matthew Khouzam --- .../graph/core/tests/stubs/GraphOps.java | 3 - .../criticalpath/view/CriticalPathView.java | 4 +- .../KernelThreadInformationProvider.java | 3 +- .../os/linux/ui/views/latency/Messages.java | 2 +- .../AbstractSegmentStoreStatisticsViewer.java | 4 +- .../ui/views/latency/statistics/Messages.java | 2 +- .../ui/views/segmentstore/Messages.java | 2 +- .../SegmentStoreContentProvider.java | 6 +- .../META-INF/MANIFEST.MF | 2 +- .../pom.xml | 1 - .../common/core/NonNullUtils.java | 98 ++++++++++++++++--- .../tracecompass/common/core/ObjectUtils.java | 2 +- .../core/collect/BufferedBlockingQueue.java | 2 +- .../ctf/core/tests/io/BitBufferTest.java | 6 +- .../ctf/core/event/io/BitBuffer.java | 2 +- .../event/types/AbstractArrayDefinition.java | 2 +- .../ctf/core/event/types/IDeclaration.java | 2 +- .../ctf/core/trace/CTFStream.java | 4 +- .../core/event/types/ArrayDeclaration.java | 4 +- .../LttngKernelExecGraphProvider.java | 3 - .../analysis/graph/handlers/Messages.java | 2 +- .../TraceEventHandlerExecutionGraph.java | 5 +- .../graph/model/LttngSystemModel.java | 3 - .../core/analysis/vm/model/VirtualCPU.java | 3 +- .../vm/module/VirtualMachineCpuAnalysis.java | 5 +- .../module/VirtualMachineStateProvider.java | 6 +- .../event/matching/TcpLttngEventMatching.java | 6 +- .../protocol/ethernet2/EthernetIIPacket.java | 2 +- .../pcap/core/protocol/ipv4/IPv4Packet.java | 4 +- .../pcap/core/protocol/tcp/TCPPacket.java | 4 +- .../tmf/pcap/core/event/Messages.java | 2 +- .../core/event/TmfPacketStreamBuilder.java | 15 +-- .../tmf/pcap/core/trace/PcapTrace.java | 15 +-- .../tmf/pcap/ui/stream/StreamListView.java | 3 - pom.xml | 12 +-- .../tracecompass-e4.5.target | 4 +- .../tracecompass-eStaging.target | 4 +- .../core/tests/treemap/TreeMapStoreTest.java | 9 +- .../core/treemap/TreeMapStore.java | 2 +- .../internal/statesystem/core/Attribute.java | 2 +- .../statesystem/core/AttributeTree.java | 2 +- .../statesystem/core/TransientState.java | 6 +- .../statesystem/core/ITmfStateSystem.java | 2 +- .../xml/core/model/TmfXmlCondition.java | 17 +++- .../xml/core/model/TmfXmlEventHandler.java | 6 +- .../xml/core/model/TmfXmlLocation.java | 2 +- .../xml/core/model/TmfXmlStateAttribute.java | 2 +- .../xml/core/model/TmfXmlStateChange.java | 4 +- .../readwrite/TmfXmlReadWriteStateValue.java | 2 +- .../core/module/IXmlStateSystemContainer.java | 3 +- .../analysis/xml/core/module/XmlUtils.java | 9 +- .../build.properties | 2 + .../META-INF/MANIFEST.MF | 1 + .../xml/ui/views/xychart/XmlXYViewer.java | 19 ++-- .../ui/views/timegraph/XmlTimeGraphView.java | 3 - .../META-INF/MANIFEST.MF | 3 +- .../core/tests/trace/text/TextTraceTest.java | 10 ++ .../TmfAnalysisParameterProviders.java | 9 +- .../core/callstack/FunctionNameMapper.java | 2 +- .../core/analysis/IAnalysisModuleSource.java | 3 +- .../IAnalysisRequirementProvider.java | 3 + .../analysis/TmfAbstractAnalysisModule.java | 2 +- .../tmf/core/analysis/TmfAnalysisManager.java | 2 +- .../tmf/core/event/ITmfCustomAttributes.java | 6 +- .../tmf/core/event/ITmfEventField.java | 2 +- .../tmf/core/event/TmfEventField.java | 9 +- .../event/matching/IMatchProcessingUnit.java | 2 + .../tmf/core/trace/ITmfTraceProperties.java | 3 + .../core/trace/TmfTraceAdapterManager.java | 5 +- .../tmf/core/trace/text/TextTrace.java | 7 +- .../trace/text/TextTraceEventContent.java | 2 +- .../core/tests/shell/CommandInputTest.java | 2 +- .../core/tests/shell/CommandResultTest.java | 6 +- .../core/tests/shell/CommandShellTest.java | 6 +- .../tmf/remote/core/shell/CommandShell.java | 2 +- .../META-INF/MANIFEST.MF | 1 + .../events/TmfEventPropertySource.java | 2 +- .../tmf/ui/viewers/events/TmfEventsTable.java | 2 +- .../tree/ITmfTreeColumnDataProvider.java | 4 +- .../TmfClosestDataPointTooltipProvider.java | 2 - .../statesystem/TmfStateSystemViewer.java | 4 +- .../timegraph/AbstractTimeGraphView.java | 4 +- .../tmf/ui/views/uml2sd/SDView.java | 4 +- 83 files changed, 259 insertions(+), 192 deletions(-) diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/stubs/org/eclipse/tracecompass/analysis/graph/core/tests/stubs/GraphOps.java b/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/stubs/org/eclipse/tracecompass/analysis/graph/core/tests/stubs/GraphOps.java index cc1d3162de..36bb3967f7 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/stubs/org/eclipse/tracecompass/analysis/graph/core/tests/stubs/GraphOps.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/stubs/org/eclipse/tracecompass/analysis/graph/core/tests/stubs/GraphOps.java @@ -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) { diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java index 64afc95099..e5e5411172 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java @@ -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 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 children = ((CriticalPathEntry) parentElement).getChildren(); return children.toArray(new TimeGraphEntry[children.size()]); diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelThreadInformationProvider.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelThreadInformationProvider.java index ab9692608f..bf4c48363e 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelThreadInformationProvider.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelThreadInformationProvider.java @@ -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 tids = new TreeSet<>(); + Set<@NonNull Integer> tids = new TreeSet<>(); for (Integer quark : ss.getSubAttributes(threadQuark, false)) { tids.add(Integer.parseInt(ss.getAttributeName(quark))); } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/Messages.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/Messages.java index 6d91f2e8df..e494b294c7 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/Messages.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/Messages.java @@ -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$ diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/AbstractSegmentStoreStatisticsViewer.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/AbstractSegmentStoreStatisticsViewer.java index fe551828cb..ba8fd85946 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/AbstractSegmentStoreStatisticsViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/AbstractSegmentStoreStatisticsViewer.java @@ -110,9 +110,9 @@ public abstract class AbstractSegmentStoreStatisticsViewer extends AbstractTmfTr return new ITmfTreeColumnDataProvider() { @Override - public List getColumnData() { + public List<@Nullable TmfTreeColumnData> getColumnData() { /* All columns are sortable */ - List columns = new ArrayList<>(); + List<@Nullable TmfTreeColumnData> columns = new ArrayList<>(); TmfTreeColumnData column = new TmfTreeColumnData(COLUMN_NAMES[0]); column.setComparator(new ViewerComparator() { @Override diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/Messages.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/Messages.java index cbc9f420bc..0b430f3e4e 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/Messages.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/Messages.java @@ -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$ diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/Messages.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/Messages.java index f57ee27597..a8d032ff29 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/Messages.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/Messages.java @@ -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$ diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/SegmentStoreContentProvider.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/SegmentStoreContentProvider.java index 9a6919a7ef..6e452d64e7 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/SegmentStoreContentProvider.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/SegmentStoreContentProvider.java @@ -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 segmentStore = (ISegmentStore) newInput; fSegmentArray = Iterables.toArray(segmentStore, ISegment.class); if (fComparator != null) { Arrays.sort(fSegmentArray, fComparator); diff --git a/common/org.eclipse.tracecompass.common.core/META-INF/MANIFEST.MF b/common/org.eclipse.tracecompass.common.core/META-INF/MANIFEST.MF index c120b0bc45..51ddb18ad4 100644 --- a/common/org.eclipse.tracecompass.common.core/META-INF/MANIFEST.MF +++ b/common/org.eclipse.tracecompass.common.core/META-INF/MANIFEST.MF @@ -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 diff --git a/common/org.eclipse.tracecompass.common.core/pom.xml b/common/org.eclipse.tracecompass.common.core/pom.xml index 57afdf8b7c..47afbf3490 100644 --- a/common/org.eclipse.tracecompass.common.core/pom.xml +++ b/common/org.eclipse.tracecompass.common.core/pom.xml @@ -18,7 +18,6 @@ org.eclipse.tracecompass.common.core - 1.2.0-SNAPSHOT eclipse-plugin Trace Compass Common Utilities Core Plug-in diff --git a/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/NonNullUtils.java b/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/NonNullUtils.java index a1141e3f2d..c1008edae3 100644 --- a/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/NonNullUtils.java +++ b/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/NonNullUtils.java @@ -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 checkNotNull(@Nullable T obj) { + public static @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> 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> M checkNotNull(@Nullable M map) { + if (map == null) { + throw new NullPointerException(); + } + return map; + } + + } diff --git a/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/ObjectUtils.java b/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/ObjectUtils.java index df7532960e..99c7910075 100644 --- a/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/ObjectUtils.java +++ b/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/ObjectUtils.java @@ -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 { diff --git a/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/collect/BufferedBlockingQueue.java b/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/collect/BufferedBlockingQueue.java index 088ce19362..5797273adf 100644 --- a/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/collect/BufferedBlockingQueue.java +++ b/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/collect/BufferedBlockingQueue.java @@ -311,7 +311,7 @@ public class BufferedBlockingQueue implements Iterable { @Override public T next() { if (hasNext()) { - T next = fNext; + @Nullable T next = fNext; if (next != null) { fNext = null; return next; diff --git a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/io/BitBufferTest.java b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/io/BitBufferTest.java index 76196cdf34..8fe956aacf 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/io/BitBufferTest.java +++ b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/io/BitBufferTest.java @@ -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()))); diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/io/BitBuffer.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/io/BitBuffer.java index 8316cb8b44..aa3646058d 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/io/BitBuffer.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/io/BitBuffer.java @@ -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; diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/AbstractArrayDefinition.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/AbstractArrayDefinition.java index 75e2a82d7e..d445096939 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/AbstractArrayDefinition.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/AbstractArrayDefinition.java @@ -46,7 +46,7 @@ public abstract class AbstractArrayDefinition extends Definition { * * @return the definitions */ - public abstract List getDefinitions(); + public abstract List<@Nullable Definition> getDefinitions(); /** * Get the the number of elements in the array diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/IDeclaration.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/IDeclaration.java index 9496337a51..8ceae67812 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/IDeclaration.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/IDeclaration.java @@ -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 diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStream.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStream.java index 22e2232e9c..5c4b008eb8 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStream.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStream.java @@ -60,7 +60,7 @@ public class CTFStream { /** * Maps event ids to events */ - private final ArrayList 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 list, int index) { + private static void ensureSize(ArrayList<@Nullable ? extends Object> list, int index) { list.ensureCapacity(index); while (list.size() <= index) { list.add(null); diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDeclaration.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDeclaration.java index 085d4141b0..3983f34804 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDeclaration.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDeclaration.java @@ -123,8 +123,8 @@ public final class ArrayDeclaration extends CompoundDeclaration { return "[declaration] array[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$ } - private @NonNull List read(@NonNull BitBuffer input, @Nullable IDefinitionScope definitionScope, String fieldName) throws CTFException { - Builder 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 + ']'); diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/building/LttngKernelExecGraphProvider.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/building/LttngKernelExecGraphProvider.java index 127d3c631b..8ce57e0938 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/building/LttngKernelExecGraphProvider.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/building/LttngKernelExecGraphProvider.java @@ -164,9 +164,6 @@ public class LttngKernelExecGraphProvider extends AbstractTmfGraphProvider { } } for (LttngWorker k : kernelWorker) { - if (k == null) { - throw new NullPointerException(); - } List nodes = graph.getNodesOf(k); for (TmfVertex node : nodes) { /* diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/Messages.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/Messages.java index 36d0340f79..5ecd6a5510 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/Messages.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/Messages.java @@ -18,7 +18,7 @@ import org.eclipse.osgi.util.NLS; * @author Francis Giraldeau * */ -@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$ diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerExecutionGraph.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerExecutionGraph.java index ddccd32e7d..d7ab07235b 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerExecutionGraph.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerExecutionGraph.java @@ -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 fKernel; private final IMatchProcessingUnit fMatchProcessing; - private HashMap fTcpNodes; + private Map fTcpNodes; private TmfEventMatching fTcpMatching; /** @@ -100,7 +101,7 @@ public class TraceEventHandlerExecutionGraph extends BaseHandler { } @Override - public void init(@Nullable Collection fTraces) { + public void init(Collection fTraces) { } diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/model/LttngSystemModel.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/model/LttngSystemModel.java index f7961de676..d3b264c352 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/model/LttngSystemModel.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/model/LttngSystemModel.java @@ -138,9 +138,6 @@ public class LttngSystemModel { return LttngInterruptContext.DEFAULT_CONTEXT; } LttngInterruptContext peek = stack.peek(); - if (peek == null) { - peek = LttngInterruptContext.DEFAULT_CONTEXT; - } return peek; } diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/model/VirtualCPU.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/model/VirtualCPU.java index bb5f974e79..66fc0e0f3b 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/model/VirtualCPU.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/model/VirtualCPU.java @@ -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 VIRTUAL_CPU_TABLE = NonNullUtils.checkNotNull(HashBasedTable. create()); + private static final Table VIRTUAL_CPU_TABLE = NonNullUtils.checkNotNull(HashBasedTable. create()); private final VirtualMachine fVm; private final Long fCpuId; diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineCpuAnalysis.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineCpuAnalysis.java index 6cc1155b8a..22b17a7c0d 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineCpuAnalysis.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineCpuAnalysis.java @@ -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 map = NonNullUtils.checkNotNull(TreeMultimap. create( + final Multimap map = NonNullUtils.checkNotNull(TreeMultimap.<@NonNull Integer, @NonNull ITmfStateInterval> create( new Comparator() { @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; diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java index 706f44ae87..08904b328e 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java @@ -83,7 +83,7 @@ public class VirtualMachineStateProvider extends AbstractTmfStateProvider { /* TODO: An analysis should support many hypervisor models */ private IVirtualMachineModel fModel; - private final Table fEventNames; + private final Table fEventNames; private final Map fLayouts; // ------------------------------------------------------------------------ @@ -100,7 +100,7 @@ public class VirtualMachineStateProvider extends AbstractTmfStateProvider { super(experiment, "Virtual Machine State Provider"); //$NON-NLS-1$ fModel = new QemuKvmVmModel(experiment); - Table table = NonNullUtils.checkNotNull(HashBasedTable. create()); + Table table = NonNullUtils.checkNotNull(HashBasedTable. 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 +} diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/matching/TcpLttngEventMatching.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/matching/TcpLttngEventMatching.java index 89ff6997cf..3a58e05ae3 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/matching/TcpLttngEventMatching.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/matching/TcpLttngEventMatching.java @@ -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 REQUIRED_EVENTS = ImmutableSet.of( TcpEventStrings.NET_DEV_QUEUE, diff --git a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java index 24e35d154a..3a87c31169 100644 --- a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java +++ b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java @@ -208,7 +208,7 @@ public class EthernetIIPacket extends Packet { public Map getFields() { Map map = fFields; if (map == null) { - ImmutableMap.Builder builder = ImmutableMap. builder(); + ImmutableMap.Builder 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$ diff --git a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ipv4/IPv4Packet.java b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ipv4/IPv4Packet.java index cff699650e..44d9e66277 100644 --- a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ipv4/IPv4Packet.java +++ b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ipv4/IPv4Packet.java @@ -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; diff --git a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/tcp/TCPPacket.java b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/tcp/TCPPacket.java index 6e6109dac4..595f464ad3 100644 --- a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/tcp/TCPPacket.java +++ b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/tcp/TCPPacket.java @@ -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; diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/Messages.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/Messages.java index f9ce624a2f..3a6e4d8034 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/Messages.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/Messages.java @@ -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 { diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/TmfPacketStreamBuilder.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/TmfPacketStreamBuilder.java index 07eb86f0ff..be158043c0 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/TmfPacketStreamBuilder.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/TmfPacketStreamBuilder.java @@ -13,12 +13,12 @@ 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 getStreams() { // We can't store in immutable list since the stream number/content can // change dynamically. - List 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)); } - } diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/trace/PcapTrace.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/trace/PcapTrace.java index bc43a39492..2f5b911311 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/trace/PcapTrace.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/trace/PcapTrace.java @@ -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 properties = fTraceProperties; if (properties == null) { - ImmutableMap.Builder builder = ImmutableMap. 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 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()); diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/stream/StreamListView.java b/pcap/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/stream/StreamListView.java index 164b3c9dda..cfa3eebff8 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/stream/StreamListView.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/stream/StreamListView.java @@ -283,9 +283,6 @@ public class StreamListView extends TmfView { } for (Entry 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 fbd5a5c763..1674eb44a7 100644 --- a/pom.xml +++ b/pom.xml @@ -201,15 +201,6 @@ 2.0.0 - - - eclipse-plugin - org.eclipse.jdt.annotation - - [1.0,2.0) - - - @@ -319,6 +310,9 @@ UTF-8 true + + common/org.eclipse.tracecompass.common.core/annotations + diff --git a/releng/org.eclipse.tracecompass.target/tracecompass-e4.5.target b/releng/org.eclipse.tracecompass.target/tracecompass-e4.5.target index 209c934c02..75b6caa33f 100644 --- a/releng/org.eclipse.tracecompass.target/tracecompass-e4.5.target +++ b/releng/org.eclipse.tracecompass.target/tracecompass-e4.5.target @@ -1,5 +1,5 @@ - + @@ -44,7 +44,7 @@ - + diff --git a/releng/org.eclipse.tracecompass.target/tracecompass-eStaging.target b/releng/org.eclipse.tracecompass.target/tracecompass-eStaging.target index ec80118611..15597f2ba4 100644 --- a/releng/org.eclipse.tracecompass.target/tracecompass-eStaging.target +++ b/releng/org.eclipse.tracecompass.target/tracecompass-eStaging.target @@ -1,5 +1,5 @@ - + @@ -41,7 +41,7 @@ - + diff --git a/statesystem/org.eclipse.tracecompass.segmentstore.core.tests/src/org/eclipse/tracecompass/segmentstore/core/tests/treemap/TreeMapStoreTest.java b/statesystem/org.eclipse.tracecompass.segmentstore.core.tests/src/org/eclipse/tracecompass/segmentstore/core/tests/treemap/TreeMapStoreTest.java index 41beea22eb..8d6e097f27 100644 --- a/statesystem/org.eclipse.tracecompass.segmentstore.core.tests/src/org/eclipse/tracecompass/segmentstore/core/tests/treemap/TreeMapStoreTest.java +++ b/statesystem/org.eclipse.tracecompass.segmentstore.core.tests/src/org/eclipse/tracecompass/segmentstore/core/tests/treemap/TreeMapStoreTest.java @@ -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 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 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 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 store = new TreeMapStore<>(); + TreeMapStore<@NonNull ISegment> store = new TreeMapStore<>(); store.add(SEGMENT_2_6); store.dispose(); assertEquals(0, store.size()); diff --git a/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java b/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java index fa5b2b8616..01ce5017c8 100644 --- a/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java +++ b/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java @@ -171,7 +171,7 @@ public class TreeMapStore implements ISegmentStore { } @Override - public T[] toArray(@Nullable T[] a) { + public T[] toArray(T @Nullable[] a) { fLock.readLock().lock(); try { return checkNotNull(fStartTimesIndex.values().toArray(a)); diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/Attribute.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/Attribute.java index 6d2350b96d..2ea13f74b3 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/Attribute.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/Attribute.java @@ -198,7 +198,7 @@ public final class Attribute { * * @return The full attribute path elements */ - public @NonNull String[] getFullAttribute() { + public String @NonNull [] getFullAttribute() { LinkedList list = new LinkedList<>(); Attribute curNode = this; diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java index 3ac74c8218..97f8777de4 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java @@ -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(); } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java index bfe449dfc2..b7c4fc81f4 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java @@ -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(); } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java index 9cb4c23772..3f63cb6955 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java @@ -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. diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlCondition.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlCondition.java index 51a0d6774f..ebb4e6598e 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlCondition.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlCondition.java @@ -85,7 +85,7 @@ public class TmfXmlCondition { Element rootNode = node; /* Process the conditions: in each case, only process Element nodes */ - List 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 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); diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlEventHandler.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlEventHandler.java index abd24f4434..71c92c3518 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlEventHandler.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlEventHandler.java @@ -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 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); } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlLocation.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlLocation.java index 04991c6d3f..320a687723 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlLocation.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlLocation.java @@ -64,7 +64,7 @@ public class TmfXmlLocation { fId = id; fContainer = container; - List childElements = XmlUtils.getChildElements(location); + List<@Nullable Element> childElements = XmlUtils.getChildElements(location); for (Element attribute : childElements) { if (attribute == null) { continue; diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java index 670b3ffc08..5816b9f2d6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java @@ -98,7 +98,7 @@ public abstract class TmfXmlStateAttribute implements ITmfXmlStateAttribute { fName = fContainer.getAttributeValue(attribute.getAttribute(TmfXmlStrings.VALUE)); break; case TmfXmlStrings.TYPE_QUERY: - List childElements = XmlUtils.getChildElements(attribute); + List<@Nullable Element> childElements = XmlUtils.getChildElements(attribute); for (Element subAttributeNode : childElements) { if (subAttributeNode == null) { continue; diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateChange.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateChange.java index 52e317573a..8f238da3d8 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateChange.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateChange.java @@ -187,7 +187,7 @@ public class TmfXmlStateChange { private final ITmfXmlStateValue fValue; public XmlStateValueChange(ITmfXmlModelFactory modelFactory, Element statechange) { - List 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 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); diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateValue.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateValue.java index a9264234a6..d92d20d74f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateValue.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateValue.java @@ -134,7 +134,7 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { break; case TmfXmlStrings.TYPE_QUERY: /* Value is the result of a query */ - List children = XmlUtils.getChildElements(node); + List<@Nullable Element> children = XmlUtils.getChildElements(node); List childAttributes = new ArrayList<>(); for (Element child : children) { if (child == null) { diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/IXmlStateSystemContainer.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/IXmlStateSystemContainer.java index 79a8357e0b..af855e0593 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/IXmlStateSystemContainer.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/IXmlStateSystemContainer.java @@ -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 getLocations(); + @NonNull Iterable<@NonNull TmfXmlLocation> getLocations(); } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/XmlUtils.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/XmlUtils.java index d8437fa982..a53bf205ca 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/XmlUtils.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/XmlUtils.java @@ -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 getChildElements(Element parent) { + public static List<@Nullable Element> getChildElements(Element parent) { NodeList childNodes = parent.getChildNodes(); - List 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 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 childElements = new ArrayList<>(); + List<@NonNull Element> childElements = new ArrayList<>(); for (int i = 0; i < nodes.getLength(); i++) { Element node = (Element) nodes.item(i); diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.tests/build.properties b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.tests/build.properties index 43b8dfd5c5..a68aa98f4f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.tests/build.properties +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.tests/build.properties @@ -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 diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/META-INF/MANIFEST.MF b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/META-INF/MANIFEST.MF index 36ba8fee67..86e53bc234 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/META-INF/MANIFEST.MF +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/META-INF/MANIFEST.MF @@ -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 diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java index 17ef228453..60a866f550 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java @@ -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 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 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 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); } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java index 74bdaeba40..febc1a0ee0 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java @@ -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(); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/META-INF/MANIFEST.MF b/tmf/org.eclipse.tracecompass.tmf.core.tests/META-INF/MANIFEST.MF index 39b1dcc779..c73794ac00 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/META-INF/MANIFEST.MF +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/META-INF/MANIFEST.MF @@ -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, diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/text/TextTraceTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/text/TextTraceTest.java index a51fd3d6f6..739b398b75 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/text/TextTraceTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/text/TextTraceTest.java @@ -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(); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/analysis/TmfAnalysisParameterProviders.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/analysis/TmfAnalysisParameterProviders.java index 0681f0ce89..29cab03fc4 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/analysis/TmfAnalysisParameterProviders.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/analysis/TmfAnalysisParameterProviders.java @@ -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); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/callstack/FunctionNameMapper.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/callstack/FunctionNameMapper.java index d118252c4b..bece22a43a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/callstack/FunctionNameMapper.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/callstack/FunctionNameMapper.java @@ -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 */ diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/IAnalysisModuleSource.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/IAnalysisModuleSource.java index 3c49e41af9..e1792622eb 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/IAnalysisModuleSource.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/IAnalysisModuleSource.java @@ -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 getAnalysisModules(); + @NonNull Iterable getAnalysisModules(); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/IAnalysisRequirementProvider.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/IAnalysisRequirementProvider.java index c7d2ea5945..62e41fb80b 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/IAnalysisRequirementProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/IAnalysisRequirementProvider.java @@ -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 { /** diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisModule.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisModule.java index 7502b60898..777be00e28 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisModule.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisModule.java @@ -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 fParameters = new HashMap<>(); + private final Map fParameters = new HashMap<>(); private final List fParameterNames = new ArrayList<>(); private final List fOutputs = new ArrayList<>(); private Set fParameterProviders = new HashSet<>(); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisManager.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisManager.java index f32e5f1631..6899bef895 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisManager.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisManager.java @@ -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) { diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfCustomAttributes.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfCustomAttributes.java index 4be73b00f5..887cce691d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfCustomAttributes.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfCustomAttributes.java @@ -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 diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventField.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventField.java index a6a0571b85..a9b7d22050 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventField.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventField.java @@ -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); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventField.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventField.java index 501d61c293..bd4c1cf3cc 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventField.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventField.java @@ -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. of()); } else { - /* Java 8 streams will make this even more simple! */ ImmutableMap.Builder 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()); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/IMatchProcessingUnit.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/IMatchProcessingUnit.java index 7cfb3edfeb..ff4263c261 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/IMatchProcessingUnit.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/IMatchProcessingUnit.java @@ -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 { /** diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceProperties.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceProperties.java index 8f460d7e70..998ac8bed6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceProperties.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceProperties.java @@ -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 { /** diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceAdapterManager.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceAdapterManager.java index 7baceda683..483ea1bc87 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceAdapterManager.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceAdapterManager.java @@ -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, IAdapterFactory>> entries = fFactoriesByClass.entries(); List 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, 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); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTrace.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTrace.java index bfd4a812d0..8c13d91e48 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTrace.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTrace.java @@ -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 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 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; } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTraceEventContent.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTraceEventContent.java index aab941d4fe..769c29c3a5 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTraceEventContent.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTraceEventContent.java @@ -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); diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandInputTest.java b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandInputTest.java index fa9421e603..c3c8d98530 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandInputTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandInputTest.java @@ -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)} diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandResultTest.java b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandResultTest.java index c854530ce0..3b40a01bc7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandResultTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandResultTest.java @@ -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 diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandShellTest.java b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandShellTest.java index d524680781..27065c0024 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandShellTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandShellTest.java @@ -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)); diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandShell.java b/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandShell.java index a22913f76e..828070350e 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandShell.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandShell.java @@ -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$ } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF b/tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF index dc45185911..4fd10699bb 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF +++ b/tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF @@ -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, diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventPropertySource.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventPropertySource.java index 2e88c5a80c..a93eb88099 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventPropertySource.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventPropertySource.java @@ -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)); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java index 3232731259..56bb78530a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java @@ -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 diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/ITmfTreeColumnDataProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/ITmfTreeColumnDataProvider.java index 800b5eb596..573d6b4d47 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/ITmfTreeColumnDataProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/ITmfTreeColumnDataProvider.java @@ -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 getColumnData(); + @NonNull List getColumnData(); } \ No newline at end of file diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfClosestDataPointTooltipProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfClosestDataPointTooltipProvider.java index 01d4fe65ed..e5c0db0ff8 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfClosestDataPointTooltipProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfClosestDataPointTooltipProvider.java @@ -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 { // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java index 3e2622af9f..34205de860 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java @@ -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; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java index bde2d05028..9b5e99ed8f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java @@ -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 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 getLinkList(long startTime, long endTime, + protected @Nullable List<@NonNull ILinkEvent> getLinkList(long startTime, long endTime, long resolution, @NonNull IProgressMonitor monitor) { return new ArrayList<>(); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/SDView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/SDView.java index 79aab0851f..cfb3883747 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/SDView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/SDView.java @@ -1147,12 +1147,10 @@ public class SDView extends ViewPart implements IPartListener { @Override public T getAdapter(Class adapter) { - T obj = super.getAdapter(adapter); if (fSdPropertiesProvider != null && adapter.equals(IPropertySheetPage.class)) { return adapter.cast(fSdPropertiesProvider.getPropertySheetEntry()); } - - return obj; + return super.getAdapter(adapter); } /** -- 2.34.1