From: Alexandre Montplaisir Date: Tue, 24 Nov 2015 23:50:39 +0000 (-0500) Subject: Fix some null warnings X-Git-Url: http://git.efficios.com/?p=deliverable%2Ftracecompass.git;a=commitdiff_plain;h=aa35350660b47f6479a7fa499d8d10e2772e46fd Fix some null warnings Change-Id: Ib0290125def1e0ea58bcf81c2075ef99db3f1f1a Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/59428 Reviewed-by: Hudson CI Reviewed-by: Marc-Andre Laperle Tested-by: Marc-Andre Laperle --- diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/base/TmfGraphStatistics.java b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/base/TmfGraphStatistics.java index 0d5814a240..70974d9286 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/base/TmfGraphStatistics.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/base/TmfGraphStatistics.java @@ -79,6 +79,9 @@ public class TmfGraphStatistics implements ITmfGraphVisitor { synchronized (fWorkerStats) { if (horizontal && graph != null) { IGraphWorker worker = graph.getParentOf(edge.getVertexFrom()); + if (worker == null) { + return; + } Long duration = edge.getDuration(); Long currentTotal = fWorkerStats.get(worker); if (currentTotal != null) { diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelAnalysisModule.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelAnalysisModule.java index dac5dcf3c4..aeee16c811 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelAnalysisModule.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelAnalysisModule.java @@ -83,7 +83,7 @@ public class KernelAnalysisModule extends TmfStateSystemAnalysisModule { // eventReq.addValues(OPTIONAL_EVENTS, ValuePriorityLevel.OPTIONAL); // // REQUIREMENTS = checkNotNull(ImmutableSet.of(domainReq, eventReq)); - REQUIREMENTS = checkNotNull(Collections.EMPTY_SET); + REQUIREMENTS = Collections.EMPTY_SET; } @Override 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 bf4c48363e..874020e14c 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 @@ -92,7 +92,7 @@ public final class KernelThreadInformationProvider { public static Collection getThreadIds(KernelAnalysisModule module) { ITmfStateSystem ss = module.getStateSystem(); if (ss == null) { - return NonNullUtils.checkNotNull(Collections.EMPTY_SET); + return Collections.EMPTY_SET; } int threadQuark; try { @@ -104,7 +104,7 @@ public final class KernelThreadInformationProvider { return tids; } catch (AttributeNotFoundException e) { } - return NonNullUtils.checkNotNull(Collections.EMPTY_SET); + return Collections.EMPTY_SET; } /** @@ -245,7 +245,7 @@ public final class KernelThreadInformationProvider { public static List getStatusIntervalsForThread(KernelAnalysisModule module, Integer threadId, long start, long end, long resolution, IProgressMonitor monitor) { ITmfStateSystem ss = module.getStateSystem(); if (ss == null) { - return NonNullUtils.checkNotNull(Collections.EMPTY_LIST); + return Collections.EMPTY_LIST; } try { @@ -255,7 +255,7 @@ public final class KernelThreadInformationProvider { return statusIntervals; } catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) { } - return NonNullUtils.checkNotNull(Collections.EMPTY_LIST); + return Collections.EMPTY_LIST; } } diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java index c949c04de7..06d6365e69 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java @@ -81,7 +81,9 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal protected Iterable getListeners() { List listeners = new ArrayList<>(); for (Object listener : fListeners.getListeners()) { - listeners.add((IAnalysisProgressListener) listener); + if (listener != null) { + listeners.add((IAnalysisProgressListener) listener); + } } return listeners; } 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 5ffc52f96e..f14f2579ff 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 @@ -13,9 +13,12 @@ package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNullContents; + import java.util.Arrays; import java.util.Comparator; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; @@ -51,7 +54,7 @@ public class SegmentStoreContentProvider implements ISortingLazyContentProvider @Override public void updateElement(int index) { final TableViewer tableViewer = fTableViewer; - final ISegment[] segmentArray = fSegmentArray; + final ISegment @Nullable [] segmentArray = fSegmentArray; if (tableViewer != null && segmentArray != null) { tableViewer.replace(segmentArray[index], index); } @@ -68,16 +71,24 @@ public class SegmentStoreContentProvider implements ISortingLazyContentProvider public void inputChanged(@Nullable Viewer viewer, @Nullable Object oldInput, @Nullable Object newInput) { fTableViewer = (TableViewer) viewer; if (newInput instanceof ISegmentStore) { + @SuppressWarnings("unchecked") ISegmentStore segmentStore = (ISegmentStore) newInput; - fSegmentArray = Iterables.toArray(segmentStore, ISegment.class); + ISegment[] array = Iterables.toArray(segmentStore, ISegment.class); + @NonNull ISegment[] checkedArray = checkNotNullContents(array); if (fComparator != null) { - Arrays.sort(fSegmentArray, fComparator); + Arrays.sort(checkedArray, fComparator); } + fSegmentArray = checkedArray; } else if (newInput instanceof ISegment[]) { - fSegmentArray = ((ISegment[]) newInput).clone(); + /* + * Ensure that there are no null elements in the array, so we can + * set it back to fSegmentArray, which does not allow nulls. + */ + @NonNull ISegment[] checkedArray = checkNotNullContents((@Nullable ISegment[]) newInput); if (fComparator != null) { - Arrays.sort(fSegmentArray, fComparator); + Arrays.sort(checkedArray, fComparator); } + fSegmentArray = checkedArray; } else { fSegmentArray = null; } @@ -85,18 +96,21 @@ public class SegmentStoreContentProvider implements ISortingLazyContentProvider @Override public void setSortOrder(@Nullable Comparator comparator) { + @NonNull ISegment @Nullable [] segmentArray = fSegmentArray; if (comparator == null) { return; } - if (fSegmentArray == null) { + if (segmentArray == null) { return; } final TableViewer tableViewer = fTableViewer; if (tableViewer == null) { return; } - fComparator = (Comparator) comparator; - Arrays.sort(fSegmentArray, fComparator); + @SuppressWarnings("unchecked") + Comparator comp = (Comparator) comparator; + fComparator = comp; + Arrays.sort(segmentArray, fComparator); tableViewer.refresh(); } diff --git a/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/event/BtfEventType.java b/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/event/BtfEventType.java index 835c280ff3..aa5c23bf77 100644 --- a/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/event/BtfEventType.java +++ b/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/event/BtfEventType.java @@ -44,7 +44,7 @@ public class BtfEventType extends TmfEventType { BtfColumnNames.NOTES.toString() }; private static final @NonNull ITmfEventField FIELDS_WITHOUT_NOTES = TmfEventField.makeRoot(FIELD_WITH_NOTES_COLUMNS); private static final @NonNull ITmfEventField FIELDS_WITH_NOTES = TmfEventField.makeRoot(FIELDS_WITHOUT_NOTES_COLUMNS); - private final String fName; + private final @NonNull String fName; private final String fDescription; private final boolean fHasNotes; private final List fCols; @@ -55,7 +55,7 @@ public class BtfEventType extends TmfEventType { * @param name the event name * @param description the event description */ - public BtfEventType(String name, String description) { + public BtfEventType(@NonNull String name, String description) { super(); fName = name; fDescription = description; diff --git a/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventTypeFactory.java b/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventTypeFactory.java index 9570cc17d7..0b0364e131 100644 --- a/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventTypeFactory.java +++ b/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventTypeFactory.java @@ -12,6 +12,8 @@ package org.eclipse.tracecompass.btf.core.trace; +import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString; + import java.util.Map; import org.eclipse.tracecompass.btf.core.Messages; @@ -33,22 +35,22 @@ public final class BtfEventTypeFactory { static { ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); // Environment - builder.put("STI", new BtfEventType(Messages.BtfTypeId_STIName, Messages.BtfTypeId_STIDescr)); //$NON-NLS-1$ + builder.put("STI", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_STIName), Messages.BtfTypeId_STIDescr)); //$NON-NLS-1$ // Software - builder.put("T", new BtfEventType(Messages.BtfTypeId_TName, Messages.BtfTypeId_TDescr)); //$NON-NLS-1$ - builder.put("ISR", new BtfEventType(Messages.BtfTypeId_ISRName, Messages.BtfTypeId_ISRDescr)); //$NON-NLS-1$ - builder.put("R", new BtfEventType(Messages.BtfTypeId_RName, Messages.BtfTypeId_RDescr)); //$NON-NLS-1$ - builder.put("IB", new BtfEventType(Messages.BtfTypeId_IBName, Messages.BtfTypeId_IBDescr)); //$NON-NLS-1$ + builder.put("T", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_TName), Messages.BtfTypeId_TDescr)); //$NON-NLS-1$ + builder.put("ISR", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_ISRName), Messages.BtfTypeId_ISRDescr)); //$NON-NLS-1$ + builder.put("R", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_RName), Messages.BtfTypeId_RDescr)); //$NON-NLS-1$ + builder.put("IB", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_IBName), Messages.BtfTypeId_IBDescr)); //$NON-NLS-1$ // Hardware - builder.put("ECU", new BtfEventType(Messages.BtfTypeId_ECUName, Messages.BtfTypeId_ECUDescr)); //$NON-NLS-1$ - builder.put("P", new BtfEventType(Messages.BtfTypeId_PName, Messages.BtfTypeId_PDescr)); //$NON-NLS-1$ - builder.put("C", new BtfEventType(Messages.BtfTypeId_CName, Messages.BtfTypeId_CDescr)); //$NON-NLS-1$ + builder.put("ECU", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_ECUName), Messages.BtfTypeId_ECUDescr)); //$NON-NLS-1$ + builder.put("P", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_PName), Messages.BtfTypeId_PDescr)); //$NON-NLS-1$ + builder.put("C", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_CName), Messages.BtfTypeId_CDescr)); //$NON-NLS-1$ // Operating system - builder.put("SCHED", new BtfEventType(Messages.BtfTypeId_SCHEDName, Messages.BtfTypeId_SCHEDDescr)); //$NON-NLS-1$ - builder.put("SIG", new BtfEventType(Messages.BtfTypeId_SIGName, Messages.BtfTypeId_SIGDescr)); //$NON-NLS-1$ - builder.put("SEM", new BtfEventType(Messages.BtfTypeId_SEMName, Messages.BtfTypeId_SEMDescr)); //$NON-NLS-1$ + builder.put("SCHED", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SCHEDName), Messages.BtfTypeId_SCHEDDescr)); //$NON-NLS-1$ + builder.put("SIG", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SIGName), Messages.BtfTypeId_SIGDescr)); //$NON-NLS-1$ + builder.put("SEM", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SEMName), Messages.BtfTypeId_SEMDescr)); //$NON-NLS-1$ // Information - builder.put("SIM", new BtfEventType(Messages.BtfTypeId_SIMName, Messages.BtfTypeId_SIMDescr)); //$NON-NLS-1$ + builder.put("SIM", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SIMName), Messages.BtfTypeId_SIMDescr)); //$NON-NLS-1$ TYPES = builder.build(); } diff --git a/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/collect/StreamFlattener.java b/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/collect/StreamFlattener.java index af7845b7c7..5daaa96c47 100644 --- a/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/collect/StreamFlattener.java +++ b/common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/collect/StreamFlattener.java @@ -9,6 +9,8 @@ package org.eclipse.tracecompass.common.core.collect; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.util.function.Function; import java.util.stream.Stream; @@ -47,8 +49,9 @@ public class StreamFlattener { * recursively. */ public Stream flatten(T element) { - return Stream.concat( + Stream ret = Stream.concat( Stream.of(element), fGetChildrenFunction.apply(element).flatMap(this::flatten)); + return checkNotNull(ret); } } diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/IEventDeclaration.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/IEventDeclaration.java index bb2392fc08..166b8e1da5 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/IEventDeclaration.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/IEventDeclaration.java @@ -98,7 +98,7 @@ public interface IEventDeclaration { * * @return The set of custom attributes */ - Set getCustomAttributes(); + @NonNull Set<@NonNull String> getCustomAttributes(); /** * Get the value of a given CTF attribute. diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/EnumDeclaration.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/EnumDeclaration.java index ffa0b8bf84..77238602f3 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/EnumDeclaration.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/EnumDeclaration.java @@ -353,8 +353,7 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp } sb.append("type:").append(fContainerType.toString()); //$NON-NLS-1$ sb.append(']'); - String string = sb.toString(); - return string; + return sb.toString(); } @Override diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDefinition.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDefinition.java index c6ec4053a1..c614d00e4e 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDefinition.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDefinition.java @@ -46,7 +46,7 @@ public final class StructDefinition extends ScopedDefinition implements IComposi // Attributes // ------------------------------------------------------------------------ - private final ImmutableList fFieldNames; + private final @NonNull List fFieldNames; private final Definition[] fDefinitions; private Map fDefinitionsMap = null; @@ -128,7 +128,7 @@ public final class StructDefinition extends ScopedDefinition implements IComposi } @Override - public List getFieldNames() { + public @NonNull List getFieldNames() { return fFieldNames; } @@ -152,15 +152,13 @@ public final class StructDefinition extends ScopedDefinition implements IComposi builder.append("{ "); //$NON-NLS-1$ - if (fFieldNames != null) { - List fields = new LinkedList<>(); - for (String field : fFieldNames) { - String appendee = field + " = " + lookupDefinition(field).toString(); //$NON-NLS-1$ - fields.add(appendee); - } - Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$ - builder.append(joiner.join(fields)); + List fields = new LinkedList<>(); + for (String field : fFieldNames) { + String appendee = field + " = " + lookupDefinition(field).toString(); //$NON-NLS-1$ + fields.add(appendee); } + Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$ + builder.append(joiner.join(fields)); builder.append(" }"); //$NON-NLS-1$ diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java index f8355b97dd..1a871ddbb1 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java @@ -16,6 +16,7 @@ import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; import java.util.Collection; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.ctf.core.CTFException; import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer; @@ -128,13 +129,13 @@ public class SequenceDeclaration extends CompoundDeclaration { fPaths.put(fieldName, fieldName + '[' + collection.size() + ']'); } List paths = (List) fPaths.get(fieldName); - Builder definitions = new ImmutableList.Builder<>(); + Builder<@NonNull Definition> definitions = new ImmutableList.Builder<>(); for (int i = 0; i < length; i++) { /* We should not have inserted any null values */ String elemName = checkNotNull(paths.get(i)); definitions.add(fElemType.createDefinition(definitionScope, elemName, input)); } - List list = checkNotNull(definitions.build()); + List<@NonNull Definition> list = checkNotNull(definitions.build()); return new ArrayDefinition(this, definitionScope, fieldName, list); } diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/composite/EventHeaderDefinition.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/composite/EventHeaderDefinition.java index 0ca7d58199..f98ad6682a 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/composite/EventHeaderDefinition.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/composite/EventHeaderDefinition.java @@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableList; */ public final class EventHeaderDefinition extends Definition implements ICompositeDefinition { - private static final List FIELD_NAMES = ImmutableList.of( + private static final @NonNull List FIELD_NAMES = ImmutableList.of( IEventHeaderDeclaration.ID, IEventHeaderDeclaration.TIMESTAMP ); @@ -99,7 +99,7 @@ public final class EventHeaderDefinition extends Definition implements IComposit } @Override - public List getFieldNames() { + public @NonNull List getFieldNames() { return FIELD_NAMES; } } \ No newline at end of file diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java index e7f56bda48..16b6586013 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java @@ -413,7 +413,7 @@ public class CtfTmfTraceTest { */ @Test public void testEventLookup() { - Set eventTypes = fixture.getContainedEventTypes(); + Set<@NonNull ? extends ITmfEventType> eventTypes = fixture.getContainedEventTypes(); Set eventNames = TmfEventTypeCollectionHelper.getEventNames(eventTypes); assertTrue(eventNames.contains("sched_switch")); assertFalse(eventNames.contains("Sched_switch")); diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/trace/iterator/CtfIterator.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/trace/iterator/CtfIterator.java index e6c1ae15e9..299ad2e5ae 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/trace/iterator/CtfIterator.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/trace/iterator/CtfIterator.java @@ -16,6 +16,7 @@ package org.eclipse.tracecompass.internal.tmf.ctf.core.trace.iterator; import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; import static org.eclipse.tracecompass.common.core.NonNullUtils.equalsNullable; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.ctf.core.CTFException; import org.eclipse.tracecompass.ctf.core.event.EventDefinition; import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInputReader; @@ -43,7 +44,7 @@ public class CtfIterator extends CTFTraceReader /** An invalid location */ public static final CtfLocation NULL_LOCATION = new CtfLocation(CtfLocation.INVALID_LOCATION); - private final CtfTmfTrace fTrace; + private final @NonNull CtfTmfTrace fTrace; private CtfLocation fCurLocation; private long fCurRank; @@ -69,7 +70,7 @@ public class CtfIterator extends CTFTraceReader * If the iterator couldn't not be instantiated, probably due to * a read error. */ - public CtfIterator(CTFTrace ctfTrace, CtfTmfTrace ctfTmfTrace) throws CTFException { + public CtfIterator(CTFTrace ctfTrace, @NonNull CtfTmfTrace ctfTmfTrace) throws CTFException { super(ctfTrace); fTrace = ctfTmfTrace; if (hasMoreEvents()) { @@ -97,7 +98,7 @@ public class CtfIterator extends CTFTraceReader * If the iterator couldn't not be instantiated, probably due to * a read error. */ - public CtfIterator(CTFTrace ctfTrace, CtfTmfTrace ctfTmfTrace, CtfLocationInfo ctfLocationData, long rank) + public CtfIterator(CTFTrace ctfTrace, @NonNull CtfTmfTrace ctfTmfTrace, CtfLocationInfo ctfLocationData, long rank) throws CTFException { super(ctfTrace); @@ -330,8 +331,7 @@ public class CtfIterator extends CTFTraceReader public int hashCode() { final int prime = 31; int result = super.hashCode(); - result = (prime * result) - + ((fTrace == null) ? 0 : fTrace.hashCode()); + result = (prime * result) + fTrace.hashCode(); result = (prime * result) + ((fCurLocation == null) ? 0 : fCurLocation.hashCode()); result = (prime * result) + (int) (fCurRank ^ (fCurRank >>> 32)); diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java index 17ef0213ca..6c1688300d 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java @@ -293,7 +293,7 @@ public class CtfTmfEvent extends TmfEvent if (declaration == null) { return new HashSet<>(); } - return checkNotNull(declaration.getCustomAttributes()); + return declaration.getCustomAttributes(); } @Override diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java index 6bc6d92e10..b891bc1da2 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java @@ -101,7 +101,7 @@ public abstract class CtfTmfEventField extends TmfEventField { * String The name to assign to this field * @return The resulting CtfTmfEventField object */ - public static CtfTmfEventField parseField(IDefinition fieldDef, + public static @NonNull CtfTmfEventField parseField(IDefinition fieldDef, @NonNull String fieldName) { CtfTmfEventField field = null; diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventType.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventType.java index 10340dca6a..39db1877b9 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventType.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventType.java @@ -11,6 +11,7 @@ package org.eclipse.tracecompass.tmf.ctf.core.event; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; @@ -29,7 +30,7 @@ public class CtfTmfEventType extends TmfEventType { * @param content * The event field */ - public CtfTmfEventType(String eventName, ITmfEventField content) { + public CtfTmfEventType(@NonNull String eventName, ITmfEventField content) { super(eventName, content); } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java index 4bc464bc27..878da4a2e2 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java @@ -213,7 +213,7 @@ public class CtfTmfTrace extends TmfTrace null, content.toArray(new ITmfEventField[content.size()])); - ctfTmfEventType = new CtfTmfEventType(ied.getName(), contentTree); + ctfTmfEventType = new CtfTmfEventType(checkNotNull(ied.getName()), contentTree); fContainedEventTypes.put(ctfTmfEventType.getName(), ctfTmfEventType); } } diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/stubs/org/eclipse/tracecompass/internal/lttng2/control/stubs/shells/LTTngToolsFileShell.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/stubs/org/eclipse/tracecompass/internal/lttng2/control/stubs/shells/LTTngToolsFileShell.java index ffd8e119a8..55c2dce152 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/stubs/org/eclipse/tracecompass/internal/lttng2/control/stubs/shells/LTTngToolsFileShell.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/stubs/org/eclipse/tracecompass/internal/lttng2/control/stubs/shells/LTTngToolsFileShell.java @@ -30,6 +30,7 @@ import java.util.regex.Pattern; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.remote.core.stubs.shells.TestCommandShell; import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput; import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandOutputListener; @@ -201,8 +202,8 @@ public class LTTngToolsFileShell extends TestCommandShell { // Save output/result in command map if (output != null && errorOutput != null) { commandMap.put(input, createCommandResult(result, - checkNotNull(output.toArray(new String[output.size()])), - checkNotNull(errorOutput.toArray(new String[errorOutput.size()])))); + checkNotNull(output.toArray(new @NonNull String[output.size()])), + checkNotNull(errorOutput.toArray(new @NonNull String[errorOutput.size()])))); } inOutput = false; } else if (OUTPUT_KEY.equals(strLine)) { @@ -273,7 +274,7 @@ public class LTTngToolsFileShell extends TestCommandShell { return checkNotNull(commands.get(fullCommand)); } - String[] output = new String[1]; + @NonNull String[] output = new @NonNull String[1]; output[0] = String.valueOf("Command not found"); ICommandResult result = createCommandResult(1, output, output); return result; diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/AssignEventHandler.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/AssignEventHandler.java index a44f6f2088..45ee3264bc 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/AssignEventHandler.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/AssignEventHandler.java @@ -23,6 +23,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; @@ -137,7 +138,7 @@ public class AssignEventHandler extends BaseControlViewHandler { @Override public boolean isEnabled() { - ArrayList events = new ArrayList<>(); + @NonNull ArrayList<@NonNull BaseEventComponent> events = new ArrayList<>(); TraceSessionComponent[] sessions = null; Boolean isKernel = null; diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/model/impl/NullControlService.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/model/impl/NullControlService.java index fa7346dfba..595e3d92e1 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/model/impl/NullControlService.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/model/impl/NullControlService.java @@ -50,7 +50,7 @@ class NullControlService implements ILttngControlService { @Override public List getSessionNames(IProgressMonitor monitor) throws ExecutionException { - return checkNotNull(Collections.EMPTY_LIST); + return Collections.EMPTY_LIST; } @Override @@ -65,17 +65,17 @@ class NullControlService implements ILttngControlService { @Override public List getKernelProvider(IProgressMonitor monitor) throws ExecutionException { - return checkNotNull(Collections.EMPTY_LIST); + return Collections.EMPTY_LIST; } @Override public List getUstProvider() throws ExecutionException { - return checkNotNull(Collections.EMPTY_LIST); + return Collections.EMPTY_LIST; } @Override public List getUstProvider(IProgressMonitor monitor) throws ExecutionException { - return checkNotNull(Collections.EMPTY_LIST); + return Collections.EMPTY_LIST; } @Override @@ -125,7 +125,7 @@ class NullControlService implements ILttngControlService { @Override public List getContextList(IProgressMonitor monitor) throws ExecutionException { - return checkNotNull(Collections.EMPTY_LIST); + return Collections.EMPTY_LIST; } @Override diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/preferences/ControlPreferences.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/preferences/ControlPreferences.java index 9d88d223f1..ab9691dce3 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/preferences/ControlPreferences.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/preferences/ControlPreferences.java @@ -11,8 +11,11 @@ **********************************************************************/ package org.eclipse.tracecompass.internal.lttng2.control.ui.views.preferences; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.io.File; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.tracecompass.internal.lttng2.control.ui.views.logging.ControlCommandLogger; @@ -144,8 +147,8 @@ public class ControlPreferences { /** * @return value of tracing group preference */ - public String getTracingGroup() { - return fPreferenceStore.getString(TRACE_CONTROL_TRACING_GROUP_PREF); + public @NonNull String getTracingGroup() { + return checkNotNull(fPreferenceStore.getString(TRACE_CONTROL_TRACING_GROUP_PREF)); } /** diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlService.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlService.java index e531a4a21d..e7e6f45667 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlService.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlService.java @@ -1067,7 +1067,7 @@ public class LTTngControlService implements ILttngControlService { } String[] args = commandLine.split("\\s+"); //$NON-NLS-1$ ICommandInput command = fCommandShell.createCommand(); - command.addAll(checkNotNull(Arrays.asList(args))); + command.addAll(Arrays.asList(args)); ICommandResult result = executeCommand(command, monitor); if (isError(result)) { @@ -1474,7 +1474,7 @@ public class LTTngControlService implements ILttngControlService { protected @NonNull ICommandInput createCommand(String... segments) { ICommandInput command = fCommandShell.createCommand(); command.add(LTTngControlServiceConstants.CONTROL_COMMAND); - List groupOption = getTracingGroupOption(); + List<@NonNull String> groupOption = getTracingGroupOption(); if (!groupOption.isEmpty()) { command.addAll(groupOption); } @@ -1491,8 +1491,8 @@ public class LTTngControlService implements ILttngControlService { /** * @return the tracing group option if configured in the preferences */ - protected @NonNull List getTracingGroupOption() { - List groupOption = new ArrayList<>(); + protected @NonNull List<@NonNull String> getTracingGroupOption() { + List<@NonNull String> groupOption = new ArrayList<>(); if (!ControlPreferences.getInstance().isDefaultTracingGroup() && !ControlPreferences.getInstance().getTracingGroup().equals("")) { //$NON-NLS-1$ groupOption.add(LTTngControlServiceConstants.OPTION_TRACING_GROUP); groupOption.add(ControlPreferences.getInstance().getTracingGroup()); diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java index 0b1c77fe7c..cdf9c4bb8d 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java @@ -740,7 +740,7 @@ public class LTTngControlServiceMI extends LTTngControlService { protected ICommandInput createCommand(String... strings) { ICommandInput command = getCommandShell().createCommand(); command.add(LTTngControlServiceConstants.CONTROL_COMMAND); - List groupOption = getTracingGroupOption(); + List<@NonNull String> groupOption = getTracingGroupOption(); if (!groupOption.isEmpty()) { command.addAll(groupOption); } diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/EventMatchingBenchmark.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/EventMatchingBenchmark.java index ddce8fe44f..6c2a0c7eae 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/EventMatchingBenchmark.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/EventMatchingBenchmark.java @@ -14,6 +14,7 @@ package org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.event.matching; import java.util.Set; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.test.performance.Dimension; import org.eclipse.test.performance.Performance; import org.eclipse.test.performance.PerformanceMeter; @@ -58,7 +59,7 @@ public class EventMatchingBenchmark { CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_SRC); CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_DEST); - Set traces = ImmutableSet.of((ITmfTrace) trace1, trace2); + Set<@NonNull ITmfTrace> traces = ImmutableSet.of(trace1, trace2); runCpuTest(traces, "Match TCP events", 100); trace1.dispose(); @@ -75,7 +76,7 @@ public class EventMatchingBenchmark { CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_DB); CtfTmfTrace trace3 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_HTTPD); - Set traces = ImmutableSet.of((ITmfTrace) trace1, trace2, trace3); + Set<@NonNull ITmfTrace> traces = ImmutableSet.of(trace1, trace2, trace3); runCpuTest(traces, "Django traces", 10); runMemoryTest(traces, "Django traces", 10); @@ -84,7 +85,7 @@ public class EventMatchingBenchmark { trace3.dispose(); } - private static void runCpuTest(Set testTraces, String testName, int loop_count) { + private static void runCpuTest(Set<@NonNull ITmfTrace> testTraces, String testName, int loop_count) { Performance perf = Performance.getDefault(); PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + TIME); perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + TIME, Dimension.CPU_TIME); @@ -101,7 +102,7 @@ public class EventMatchingBenchmark { } /* Benchmark memory used by the algorithm */ - private static void runMemoryTest(Set testTraces, String testName, int loop_count) { + private static void runMemoryTest(Set<@NonNull ITmfTrace> testTraces, String testName, int loop_count) { Performance perf = Performance.getDefault(); PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + MEMORY); perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + MEMORY, Dimension.USED_JAVA_HEAP); diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/TraceSynchronizationBenchmark.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/TraceSynchronizationBenchmark.java index a71beafcff..5580ee549b 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/TraceSynchronizationBenchmark.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/event/matching/TraceSynchronizationBenchmark.java @@ -16,6 +16,7 @@ import static org.junit.Assert.assertNotNull; import java.util.Collections; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.test.performance.Dimension; import org.eclipse.test.performance.Performance; import org.eclipse.test.performance.PerformanceMeter; @@ -89,14 +90,14 @@ public class TraceSynchronizationBenchmark { trace3.dispose(); } - private static void runCpuTest(TmfExperiment experiment, String testName, int loop_count) { + private static void runCpuTest(@NonNull TmfExperiment experiment, String testName, int loop_count) { Performance perf = Performance.getDefault(); PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + TIME); perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + TIME, Dimension.CPU_TIME); for (int i = 0; i < loop_count; i++) { pm.start(); - SynchronizationManager.synchronizeTraces(null, Collections. singleton(experiment), true); + SynchronizationManager.synchronizeTraces(null, Collections.singleton(experiment), true); pm.stop(); } pm.commit(); @@ -104,7 +105,7 @@ public class TraceSynchronizationBenchmark { } /* Benchmark memory used by the algorithm */ - private static void runMemoryTest(TmfExperiment experiment, String testName, int loop_count) { + private static void runMemoryTest(@NonNull TmfExperiment experiment, String testName, int loop_count) { Performance perf = Performance.getDefault(); PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + MEMORY); perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + MEMORY, Dimension.USED_JAVA_HEAP); @@ -113,7 +114,7 @@ public class TraceSynchronizationBenchmark { System.gc(); pm.start(); - SynchronizationAlgorithm algo = SynchronizationManager.synchronizeTraces(null, Collections. singleton(experiment), true); + SynchronizationAlgorithm algo = SynchronizationManager.synchronizeTraces(null, Collections.singleton(experiment), true); assertNotNull(algo); System.gc(); diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTestExperiment.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTestExperiment.java index 8fe186971c..e9ffc3357b 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTestExperiment.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTestExperiment.java @@ -12,6 +12,8 @@ package org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.vm; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.io.File; import java.util.HashSet; import java.util.Set; @@ -59,12 +61,14 @@ public enum VmTestExperiment { * experiment */ public synchronized TmfExperiment getExperiment(boolean deleteSuppFiles) { - Set traces = new HashSet<>(); + Set<@NonNull ITmfTrace> traces = new HashSet<>(); for (VmTraces trace : fTraces) { - traces.add(trace.getTrace()); + ITmfTrace tmfTrace = trace.getTrace(); + if (tmfTrace != null) { + traces.add(tmfTrace); + } } - @SuppressWarnings("null") - @NonNull String expName = this.name(); + String expName = checkNotNull(this.name()); VirtualMachineExperiment experiment = new VirtualMachineExperiment(expName, traces); if (deleteSuppFiles) { /* diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTraces.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTraces.java index e464161b2d..d44ce16f90 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTraces.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTraces.java @@ -21,6 +21,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.lttng2.kernel.core.tests.Activator; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; @@ -69,7 +70,7 @@ public enum VmTraces { * * @return A TmfXmlTraceStub reference to this trace */ - public ITmfTrace getTrace() { + public @Nullable ITmfTrace getTrace() { ITmfTrace trace = new TmfXmlTraceStub(); IStatus status = trace.validate(null, fPath.toOSString()); if (!status.isOK()) { diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/MatchAndSyncTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/MatchAndSyncTest.java index 3b3b0c6588..0d82b95e2a 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/MatchAndSyncTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/MatchAndSyncTest.java @@ -21,6 +21,7 @@ import java.lang.reflect.Method; import java.util.LinkedList; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpEventMatching; import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpLttngEventMatching; import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace; @@ -47,7 +48,7 @@ public class MatchAndSyncTest { CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_SRC); CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_DEST); - List tracearr = new LinkedList<>(); + List<@NonNull ITmfTrace> tracearr = new LinkedList<>(); tracearr.add(trace1); tracearr.add(trace2); diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerStatedump.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerStatedump.java index 226aa200d6..c6c66ba2dd 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerStatedump.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerStatedump.java @@ -9,6 +9,8 @@ package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.handlers; +import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString; + import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread; import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout; import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.building.LttngKernelExecGraphProvider; @@ -46,7 +48,7 @@ public class TraceEventHandlerStatedump extends BaseHandler { } Integer tid = EventField.getInt(event, eventLayout.fieldTid()); - String name = EventField.getOrDefault(event, eventLayout.fieldName(), Messages.TraceEventHandlerSched_UnknownThreadName); + String name = EventField.getOrDefault(event, eventLayout.fieldName(), nullToEmptyString(Messages.TraceEventHandlerSched_UnknownThreadName)); Integer status = EventField.getInt(event, eventLayout.fieldStatus()); String host = event.getTrace().getHostId(); diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/trace/VirtualMachineExperiment.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/trace/VirtualMachineExperiment.java index 4eef98ceaf..8fb8baacaa 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/trace/VirtualMachineExperiment.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/trace/VirtualMachineExperiment.java @@ -13,8 +13,6 @@ package org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.trace; -import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; - import java.util.Collections; import java.util.Set; @@ -34,7 +32,7 @@ public class VirtualMachineExperiment extends TmfExperiment { * Default constructor. Needed by the extension point. */ public VirtualMachineExperiment() { - this("", checkNotNull(Collections.EMPTY_SET)); //$NON-NLS-1$ + this("", Collections.EMPTY_SET); //$NON-NLS-1$ } /** diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoStateProvider.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoStateProvider.java index 49d312ac06..9ef8441220 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoStateProvider.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/UstDebugInfoStateProvider.java @@ -207,7 +207,7 @@ public class UstDebugInfoStateProvider extends AbstractTmfStateProvider { * Add this library to the pending entries, the matching * build_id/debug_link event will finish updating this attribute */ - fPendingEntries.put(baddr, sopath); + fPendingEntries.put(baddr, checkNotNull(sopath)); } /** diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java index 0692772894..82f87e56b5 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java @@ -14,6 +14,7 @@ package org.eclipse.tracecompass.lttng2.ust.core.analysis.memory; import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; +import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString; import java.util.Set; @@ -100,8 +101,8 @@ public class UstMemoryAnalysisModule extends TmfStateSystemAnalysisModule { * In order to have these events, the libc wrapper with probes should be * loaded */ - eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingInformation); - eventsReq.addInformation(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation); + eventsReq.addInformation(nullToEmptyString(Messages.UstMemoryAnalysisModule_EventsLoadingInformation)); + eventsReq.addInformation(nullToEmptyString(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation)); /* The domain type of the analysis */ TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN); 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 595f464ad3..574b011279 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 @@ -19,6 +19,7 @@ import java.nio.ByteOrder; import java.util.Arrays; import java.util.Map; +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; @@ -425,7 +426,7 @@ public class TCPPacket extends Packet { public Map getFields() { Map map = fFields; if (map == null) { - Builder builder = ImmutableMap. builder() + Builder builder = ImmutableMap.<@NonNull String, @NonNull String> builder() .put("Source Port", String.valueOf(fSourcePort)) //$NON-NLS-1$ .put("Destination Port", String.valueOf(fDestinationPort)) //$NON-NLS-1$ .put("Sequence Number", String.valueOf(fSequenceNumber)) //$NON-NLS-1$ diff --git a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/udp/UDPPacket.java b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/udp/UDPPacket.java index 1abbf0a166..169c2f51d3 100644 --- a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/udp/UDPPacket.java +++ b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/udp/UDPPacket.java @@ -16,6 +16,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Map; +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; @@ -205,7 +206,7 @@ public class UDPPacket extends Packet { public Map getFields() { Map map = fFields; if (map == null) { - ImmutableMap.Builder builder = ImmutableMap. builder() + ImmutableMap.Builder builder = ImmutableMap.<@NonNull String, @NonNull String> builder() .put("Source Port", String.valueOf(fSourcePort)) //$NON-NLS-1$ .put("Destination Port", String.valueOf(fDestinationPort)) //$NON-NLS-1$ .put("Length", String.valueOf(fTotalLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/unknown/UnknownPacket.java b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/unknown/UnknownPacket.java index 54a7c1cca6..c214995b41 100644 --- a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/unknown/UnknownPacket.java +++ b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/unknown/UnknownPacket.java @@ -18,6 +18,7 @@ import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.util.Map; +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.Packet; @@ -134,7 +135,7 @@ public class UnknownPacket extends Packet { if (map == null) { byte[] array = checkNotNull(fPayload.array()); - Builder builder = ImmutableMap. builder() + Builder builder = ImmutableMap.<@NonNull String, @NonNull String> builder() .put("Binary", ConversionHelper.bytesToHex(array, true)); //$NON-NLS-1$ try { String s = new String(array, "UTF-8"); //$NON-NLS-1$ diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core.tests/src/org/eclipse/tracecompass/tmf/pcap/core/tests/event/PcapEventFieldTest.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core.tests/src/org/eclipse/tracecompass/tmf/pcap/core/tests/event/PcapEventFieldTest.java index 269932328b..6f9661a176 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core.tests/src/org/eclipse/tracecompass/tmf/pcap/core/tests/event/PcapEventFieldTest.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core.tests/src/org/eclipse/tracecompass/tmf/pcap/core/tests/event/PcapEventFieldTest.java @@ -210,21 +210,15 @@ public class PcapEventFieldTest { } // Convenience method - private static ITmfEventField[] generatePacketFields(Packet packet) { + private static ITmfEventField @NonNull [] generatePacketFields(Packet packet) { List fieldList = new ArrayList<>(); List subfieldList = new ArrayList<>(); Packet localPacket = packet; while (localPacket != null) { subfieldList.clear(); - for (Map.Entry entry : localPacket.getFields().entrySet()) { - - @SuppressWarnings("null") - @NonNull + for (Map.Entry<@NonNull String, @NonNull String> entry : localPacket.getFields().entrySet()) { String key = entry.getKey(); - - @SuppressWarnings("null") - @NonNull String value = entry.getValue(); subfieldList.add(new TmfEventField(key, value, null)); } diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEvent.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEvent.java index 8e9c1fc16f..33d84f43ba 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEvent.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEvent.java @@ -210,7 +210,7 @@ public class PcapEvent extends TmfEvent { } if (packet == null) { - fProtocols = checkNotNull(Collections.EMPTY_LIST); + fProtocols = Collections.EMPTY_LIST; return fProtocols; } // Go through all the packets and add them to list. diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEventField.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEventField.java index daa3fadc49..0cc4a2fbdd 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEventField.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEventField.java @@ -12,7 +12,6 @@ package org.eclipse.tracecompass.internal.tmf.pcap.core.event; -import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.internal.pcap.core.packet.Packet; import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; @@ -41,7 +40,7 @@ public class PcapEventField extends TmfEventField { * @throws IllegalArgumentException * If 'name' is null, or if 'fields' has duplicate field names. */ - public PcapEventField(String name, Object value, @Nullable ITmfEventField[] fields, Packet packet) { + public PcapEventField(String name, Object value, ITmfEventField[] fields, Packet packet) { super(name, value, fields); fSummaryString = packet.getLocalSummaryString(); } diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapRootEventField.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapRootEventField.java index 795a70d7e1..5afcd8c226 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapRootEventField.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapRootEventField.java @@ -40,7 +40,7 @@ public class PcapRootEventField extends TmfEventField { * @throws IllegalArgumentException * If 'name' is null, or if 'fields' has duplicate field names. */ - public PcapRootEventField(@Nullable ITmfEventField[] fields, Packet packet) { + public PcapRootEventField(ITmfEventField[] fields, Packet packet) { super(ITmfEventField.ROOT_FIELD_ID, null, fields); fPacketSourceField = new TmfEventField(PcapEvent.EVENT_FIELD_PACKET_SOURCE, packet.getMostEcapsulatedPacket().getSourceEndpoint().toString(), null); diff --git a/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/BasicSegment.java b/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/BasicSegment.java index c14f95c0c8..61b12b9997 100644 --- a/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/BasicSegment.java +++ b/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/BasicSegment.java @@ -26,9 +26,15 @@ public class BasicSegment implements ISegment { private static final long serialVersionUID = -3257452887960883177L; - private static final Comparator COMPARATOR = checkNotNull(Ordering - .from(SegmentComparators.INTERVAL_START_COMPARATOR) - .compound(SegmentComparators.INTERVAL_END_COMPARATOR)); + private static final Comparator COMPARATOR; + static { + /* checkNotNull() has to be called separately, or else it breaks the + * type inference. */ + Comparator comp = Ordering + .from(SegmentComparators.INTERVAL_START_COMPARATOR) + .compound(SegmentComparators.INTERVAL_END_COMPARATOR); + COMPARATOR = checkNotNull(comp); + } private final long fStart; private final long fEnd; diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/InMemoryBackendTest.java b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/InMemoryBackendTest.java index f3e9b83dc2..7ac37cde94 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/InMemoryBackendTest.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/InMemoryBackendTest.java @@ -17,6 +17,7 @@ import static org.junit.Assert.*; import java.util.ArrayList; import java.util.List; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend; import org.eclipse.tracecompass.statesystem.core.backend.StateHistoryBackendFactory; import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; @@ -96,7 +97,7 @@ public class InMemoryBackendTest { */ @Test public void testDoQuery() { - List interval = new ArrayList<>(NUMBER_OF_ATTRIBUTES); + List<@Nullable ITmfStateInterval> interval = new ArrayList<>(NUMBER_OF_ATTRIBUTES); for (int i = 0; i < NUMBER_OF_ATTRIBUTES; i++) { interval.add(null); } @@ -142,7 +143,7 @@ public class InMemoryBackendTest { testInterval(interval[8], 908, 998, 9); testInterval(interval[9], 909, 999, 9); - List intervalQuery = new ArrayList<>(NUMBER_OF_ATTRIBUTES); + List<@Nullable ITmfStateInterval> intervalQuery = new ArrayList<>(NUMBER_OF_ATTRIBUTES); for (int i = 0; i < NUMBER_OF_ATTRIBUTES; i++) { intervalQuery.add(null); } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/statevalue/StateValueCompareToTest.java b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/statevalue/StateValueCompareToTest.java index f65b18df7a..73951589b8 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/statevalue/StateValueCompareToTest.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/statevalue/StateValueCompareToTest.java @@ -14,6 +14,7 @@ package org.eclipse.tracecompass.statesystem.core.tests.statevalue; import static org.junit.Assert.assertTrue; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; @@ -24,6 +25,7 @@ import org.junit.Test; * * @author Naser Ezzati */ +@NonNullByDefault public class StateValueCompareToTest { // ------------------------------------------------------------------------ diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/InMemoryBackend.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/InMemoryBackend.java index 454e251a10..5ec490c657 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/InMemoryBackend.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/InMemoryBackend.java @@ -30,6 +30,7 @@ import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; import org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; +import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; /** * State history back-end that stores its intervals in RAM only. It cannot be @@ -231,7 +232,7 @@ public class InMemoryBackend implements IStateHistoryBackend { } private static Iterator serachforEndTime(TreeSet tree, long time) { - ITmfStateInterval dummyInterval = new TmfStateInterval(-1, time, -1, null); + ITmfStateInterval dummyInterval = new TmfStateInterval(-1, time, -1, TmfStateValue.nullValue()); ITmfStateInterval myInterval = tree.lower(dummyInterval); if (myInterval == null) { return tree.iterator(); diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java index 30e6eb809e..dc5a31d996 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java @@ -18,6 +18,7 @@ package org.eclipse.tracecompass.internal.statesystem.core.backend.historytree; import java.io.IOException; import java.nio.ByteBuffer; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; @@ -62,7 +63,7 @@ public final class HTInterval implements ITmfStateInterval, Comparable intervalEnd) { throw new TimeRangeException("Start:" + intervalStart + ", End:" + intervalEnd); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -104,7 +105,7 @@ public final class HTInterval implements ITmfStateInterval, Comparable intervalEnd) { throw new TimeRangeException("Start:" + intervalStart + ", End:" + intervalEnd); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java index 08727c1afe..9013b89787 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java @@ -24,6 +24,7 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.locks.ReentrantReadWriteLock; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; @@ -172,7 +173,7 @@ public abstract class HTNode { * @throws IOException * If there was an error reading from the file channel */ - public static final HTNode readNode(HTConfig config, FileChannel fc) + public static final @NonNull HTNode readNode(HTConfig config, FileChannel fc) throws IOException { HTNode newNode = null; int res, i; diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HT_IO.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HT_IO.java index 11620b353b..65911113bf 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HT_IO.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HT_IO.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.statesystem.core.Activator; /** @@ -99,7 +100,7 @@ class HT_IO { * reading. Instead of using a big reader-writer lock, we'll * just catch this exception. */ - public synchronized HTNode readNode(int seqNumber) throws ClosedChannelException { + public synchronized @NonNull HTNode readNode(int seqNumber) throws ClosedChannelException { /* Do a cache lookup */ int offset = seqNumber & (CACHE_SIZE - 1); HTNode readNode = fNodeCache[offset]; @@ -115,12 +116,13 @@ class HT_IO { /* Put the node in the cache. */ fNodeCache[offset] = readNode; return readNode; + } catch (ClosedChannelException e) { throw e; } catch (IOException e) { /* Other types of IOExceptions shouldn't happen at this point though */ Activator.getDefault().logError(e.getMessage(), e); - return null; + throw new IllegalStateException(); } } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTree.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTree.java index 32fbeb6e18..d8f25d4ded 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTree.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTree.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.statesystem.core.Activator; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; @@ -73,7 +74,7 @@ public class HistoryTree { private int fNodeCount; /** "Cache" to keep the active nodes in memory */ - private final List fLatestBranch; + private final List<@NonNull HTNode> fLatestBranch; // ------------------------------------------------------------------------ // Constructors/"Destructors" @@ -101,7 +102,7 @@ public class HistoryTree { fConfig = conf; fTreeEnd = conf.getTreeStart(); fNodeCount = 0; - fLatestBranch = Collections.synchronizedList(new ArrayList()); + fLatestBranch = Collections.synchronizedList(new ArrayList<>()); /* Prepare the IO object */ fTreeIO = new HT_IO(fConfig, true); @@ -216,8 +217,8 @@ public class HistoryTree { * start * @throws ClosedChannelException */ - private List buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException { - List list = new ArrayList<>(); + private List<@NonNull HTNode> buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException { + List<@NonNull HTNode> list = new ArrayList<>(); HTNode nextChildNode = fTreeIO.readNode(rootNodeSeqNb); list.add(nextChildNode); @@ -343,7 +344,7 @@ public class HistoryTree { * * @return The immutable latest branch */ - protected List getLatestBranch() { + protected List<@NonNull HTNode> getLatestBranch() { return ImmutableList.copyOf(fLatestBranch); } @@ -600,7 +601,7 @@ public class HistoryTree { * Start time of the new node * @return The newly created node */ - private CoreNode initNewCoreNode(int parentSeqNumber, long startTime) { + private @NonNull CoreNode initNewCoreNode(int parentSeqNumber, long startTime) { CoreNode newNode = new CoreNode(fConfig, fNodeCount, parentSeqNumber, startTime); fNodeCount++; @@ -621,7 +622,7 @@ public class HistoryTree { * Start time of the new node * @return The newly created node */ - private LeafNode initNewLeafNode(int parentSeqNumber, long startTime) { + private @NonNull LeafNode initNewLeafNode(int parentSeqNumber, long startTime) { LeafNode newNode = new LeafNode(fConfig, fNodeCount, parentSeqNumber, startTime); fNodeCount++; diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/backend/IStateHistoryBackend.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/backend/IStateHistoryBackend.java index d3cd7828c0..093e781dc3 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/backend/IStateHistoryBackend.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/backend/IStateHistoryBackend.java @@ -18,6 +18,7 @@ import java.io.PrintWriter; import java.util.List; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; @@ -79,7 +80,7 @@ public interface IStateHistoryBackend { */ // FIXME change to IStateInterval? void insertPastState(long stateStartTime, long stateEndTime, - int quark, ITmfStateValue value) throws TimeRangeException; + int quark, @NonNull ITmfStateValue value) throws TimeRangeException; /** * Indicate to the provider that we are done building the history (so it can @@ -159,7 +160,7 @@ public interface IStateHistoryBackend { * @throws StateSystemDisposedException * If the state system is disposed while a request is ongoing. */ - void doQuery(@NonNull List currentStateInfo, long t) + void doQuery(@NonNull List<@Nullable ITmfStateInterval> currentStateInfo, long t) throws TimeRangeException, StateSystemDisposedException; /** diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/interval/TmfStateInterval.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/interval/TmfStateInterval.java index d2bd91c4f3..81c6ce46a9 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/interval/TmfStateInterval.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/interval/TmfStateInterval.java @@ -12,6 +12,7 @@ package org.eclipse.tracecompass.statesystem.core.interval; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; import com.google.common.base.Objects; @@ -28,7 +29,7 @@ public final class TmfStateInterval implements ITmfStateInterval { private final long start; private final long end; private final int attribute; - private final ITmfStateValue sv; + private final @NonNull ITmfStateValue sv; /** * Construct an interval from its given parameters @@ -43,7 +44,7 @@ public final class TmfStateInterval implements ITmfStateInterval { * State value this interval will contain */ public TmfStateInterval(long start, long end, int attribute, - ITmfStateValue sv) { + @NonNull ITmfStateValue sv) { this.start = start; this.end = end; this.attribute = attribute; diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyStateValue.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyStateValue.java index 708569d565..cc0ad19df2 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyStateValue.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyStateValue.java @@ -12,8 +12,6 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.model.readonly; -import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; - import java.util.Collections; import java.util.List; @@ -65,7 +63,7 @@ public class TmfXmlReadOnlyStateValue extends TmfXmlStateValue { */ public TmfXmlReadOnlyStateValue(TmfXmlReadOnlyModelFactory modelFactory, Element node, IXmlStateSystemContainer container, String eventField) { - super(modelFactory, node, container, checkNotNull(Collections.EMPTY_LIST), eventField); + super(modelFactory, node, container, Collections.EMPTY_LIST, eventField); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java index ad73371c85..5dc864ad64 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java @@ -44,13 +44,13 @@ import org.w3c.dom.NodeList; public class XmlStateProvider extends AbstractTmfStateProvider implements IXmlStateSystemContainer { private final IPath fFilePath; - @NonNull private final String fStateId; + private final @NonNull String fStateId; /** List of all Event Handlers */ private final List fEventHandlers = new ArrayList<>(); /** List of all Locations */ - private final Set fLocations; + private final @NonNull Set<@NonNull TmfXmlLocation> fLocations; /** Map for defined values */ private final Map fDefinedValues = new HashMap<>(); @@ -90,7 +90,7 @@ public class XmlStateProvider extends AbstractTmfStateProvider implements IXmlSt /* parser for the locations */ List childElements = XmlUtils.getChildElements(doc, TmfXmlStrings.LOCATION); - Set locations = new HashSet<>(); + Set<@NonNull TmfXmlLocation> locations = new HashSet<>(); for (Element element : childElements) { if (element == null) { continue; diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/XmlAnalysisModuleSource.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/XmlAnalysisModuleSource.java index 32545bee15..cf9d23eb48 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/XmlAnalysisModuleSource.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/XmlAnalysisModuleSource.java @@ -33,6 +33,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.Messages; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlUtils; @@ -70,7 +71,7 @@ public class XmlAnalysisModuleSource implements IAnalysisModuleSource { .append("org.eclipse.linuxtools.tmf.analysis.xml.core") //$NON-NLS-1$ .append("xml_files"); //$NON-NLS-1$ - private static List fModules = null; + private static List<@NonNull IAnalysisModuleHelper> fModules = null; /** * Constructor. It adds the new module listener to the analysis manager. @@ -81,12 +82,14 @@ public class XmlAnalysisModuleSource implements IAnalysisModuleSource { @Override public synchronized Iterable getAnalysisModules() { - if (fModules == null) { - fModules = new ArrayList<>(); + List<@NonNull IAnalysisModuleHelper> modules = fModules; + if (modules == null) { + modules = new ArrayList<>(); + fModules = modules; populateBuiltinModules(); populateAnalysisModules(); } - return fModules; + return modules; } private static void processFile(File xmlFile) { 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 1027ee4d6f..c39fe80775 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 @@ -254,7 +254,7 @@ public class XmlTimeGraphView extends AbstractTimeGraphView { return; } - Set stateSystemModules = new HashSet<>(); + Set<@NonNull ITmfAnalysisModuleWithStateSystems> stateSystemModules = new HashSet<>(); if (analysisIds.isEmpty()) { /* * No analysis specified, take all state system analysis modules diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/AnalysisRequirementTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/AnalysisRequirementTest.java index 5f7be2e40c..0838a58c2f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/AnalysisRequirementTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/AnalysisRequirementTest.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement; import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel; @@ -52,9 +53,9 @@ public class AnalysisRequirementTest { private static final String VALUE_F = "Test Value F"; /* Requirement information strings */ - private static final String INFO_A = "This is an information."; - private static final String INFO_B = "This is another information."; - private static final String INFO_C = "This is the last information."; + private static final @NonNull String INFO_A = "This is an information."; + private static final @NonNull String INFO_B = "This is another information."; + private static final @NonNull String INFO_C = "This is the last information."; /** * Test suite for the {@link TmfAnalysisRequirement#addInformation} and the diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java index a1245df779..b335b3f25d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java @@ -48,7 +48,7 @@ public class TmfEventTest { private final @NonNull ITmfTrace fTrace = STUB_TRACE.getTrace(); - private final String fTypeId = "TestType"; + private final @NonNull String fTypeId = "TestType"; private final @NonNull String fLabel1 = "AString"; private final @NonNull String fLabel2 = "AnInteger"; private final String[] fLabels = new String[] { fLabel1, fLabel2 }; diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java index 0ff7437760..5348c2b01b 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java @@ -17,6 +17,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; @@ -32,7 +33,7 @@ import org.junit.Test; */ public class TmfAsyncSequenceDiagramEventTest { - private final String fTypeId = "Some type"; + private final @NonNull String fTypeId = "Some type"; private final String fLabel0 = "label1"; private final String fLabel1 = "label2"; private final String[] fLabels = new String[] { fLabel0, fLabel1 }; diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java index b11fc5e474..476c6cae83 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java @@ -17,6 +17,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; @@ -32,9 +33,9 @@ import org.junit.Test; */ public class TmfSyncSequenceDiagramEventTest { - private final String fTypeId = "Some type"; - private final String fLabel0 = "label1"; - private final String fLabel1 = "label2"; + private final @NonNull String fTypeId = "Some type"; + private final @NonNull String fLabel0 = "label1"; + private final @NonNull String fLabel1 = "label2"; private final String[] fLabels = new String[] { fLabel0, fLabel1 }; private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogEventType.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogEventType.java index b39bcfa783..50332b97fe 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogEventType.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogEventType.java @@ -13,6 +13,7 @@ package org.eclipse.tracecompass.tmf.tests.stubs.trace.text; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; /** @@ -21,7 +22,7 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEventType; public class SyslogEventType extends TmfEventType { /** The event type id string. */ - public static final String TYPE_ID = "Syslog"; //$NON-NLS-1$ + public static final @NonNull String TYPE_ID = "Syslog"; //$NON-NLS-1$ /** A default instance of this class */ public static final SyslogEventType INSTANCE = new SyslogEventType(); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/analysis/TmfAnalysisModuleSources.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/analysis/TmfAnalysisModuleSources.java index 81868854e4..c1d1f57a65 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/analysis/TmfAnalysisModuleSources.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/analysis/TmfAnalysisModuleSources.java @@ -58,7 +58,9 @@ public final class TmfAnalysisModuleSources { if (elementName.equals(SOURCE_ELEM)) { try { IAnalysisModuleSource source = (IAnalysisModuleSource) ce.createExecutableExtension(CLASS_ATTR); - sources.add(source); + if (source != null) { + sources.add(source); + } } catch (InvalidRegistryObjectException e) { Activator.logError("Error creating module source", e); //$NON-NLS-1$ } catch (CoreException e) { diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/filter/TmfCollapseFilter.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/filter/TmfCollapseFilter.java index 471bc71b1f..e937676e40 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/filter/TmfCollapseFilter.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/filter/TmfCollapseFilter.java @@ -13,6 +13,7 @@ package org.eclipse.tracecompass.internal.tmf.core.filter; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.event.collapse.ITmfCollapsibleEvent; import org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode; @@ -74,8 +75,8 @@ public class TmfCollapseFilter implements ITmfFilterTreeNode { } @Override - public ITmfFilterTreeNode[] getChildren() { - return new ITmfFilterTreeNode[0]; + public @NonNull ITmfFilterTreeNode[] getChildren() { + return new @NonNull ITmfFilterTreeNode[0]; } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java index e9b269c014..474226858a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java @@ -12,6 +12,9 @@ package org.eclipse.tracecompass.internal.tmf.core.statesystem.backends.partial; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNullContents; + import java.io.File; import java.io.FileInputStream; import java.io.PrintWriter; @@ -19,8 +22,10 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.concurrent.CountDownLatch; +import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend; import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; @@ -204,7 +209,7 @@ public class PartialHistoryBackend implements IStateHistoryBackend { } @Override - public void doQuery(List currentStateInfo, long t) + public void doQuery(List<@Nullable ITmfStateInterval> currentStateInfo, long t) throws TimeRangeException, StateSystemDisposedException { /* Wait for required steps to be done */ waitForCheckpoints(); @@ -222,8 +227,11 @@ public class PartialHistoryBackend implements IStateHistoryBackend { * Set the initial contents of the partial state system (which is the * contents of the query at the checkpoint). */ + List<@NonNull ITmfStateInterval> filledStateInfo = + checkNotNullContents(currentStateInfo.stream()).collect(Collectors.toList()); + fPartialSS.takeQueryLock(); - fPartialSS.replaceOngoingState(currentStateInfo); + fPartialSS.replaceOngoingState(filledStateInfo); /* Send an event request to update the state system to the target time. */ TmfTimeRange range = new TmfTimeRange( @@ -251,11 +259,10 @@ public class PartialHistoryBackend implements IStateHistoryBackend { try { for (int i = 0; i < currentStateInfo.size(); i++) { long start = 0; - ITmfStateValue val = null; start = ((ITmfStateSystem) fPartialSS).getOngoingStartTime(i); - val = ((ITmfStateSystem) fPartialSS).queryOngoingState(i); + ITmfStateValue val = ((ITmfStateSystem) fPartialSS).queryOngoingState(i); - ITmfStateInterval interval = new TmfStateInterval(start, t, i, val); + ITmfStateInterval interval = new TmfStateInterval(start, t, i, checkNotNull(val)); currentStateInfo.set(i, interval); } } catch (AttributeNotFoundException e) { diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/ITmfMipmapFeature.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/ITmfMipmapFeature.java index 4ed606998b..8756de2be3 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/ITmfMipmapFeature.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/ITmfMipmapFeature.java @@ -12,6 +12,7 @@ *******************************************************************************/ package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; /** @@ -32,7 +33,7 @@ public interface ITmfMipmapFeature { * @param ts * The timestamp of the event */ - public void updateMipmap(ITmfStateValue value, long ts); + public void updateMipmap(@NonNull ITmfStateValue value, long ts); /** * Update the mipmap values at all levels before closing. diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/MaxMipmapFeature.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/MaxMipmapFeature.java index 3cc2d8c83a..fde0c44849 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/MaxMipmapFeature.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/MaxMipmapFeature.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.util.List; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; @@ -64,6 +66,6 @@ public class MaxMipmapFeature extends TmfMipmapFeature { } catch (StateValueTypeException e) { e.printStackTrace(); } - return maxValue; + return checkNotNull(maxValue); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/MinMipmapFeature.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/MinMipmapFeature.java index 6c7c3d6fd1..e4a5edc2ef 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/MinMipmapFeature.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/MinMipmapFeature.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.util.List; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; @@ -64,6 +66,6 @@ public class MinMipmapFeature extends TmfMipmapFeature { } catch (StateValueTypeException e) { e.printStackTrace(); } - return minValue; + return checkNotNull(minValue); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/TmfMipmapFeature.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/TmfMipmapFeature.java index f6a1065418..a04ffff274 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/TmfMipmapFeature.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/TmfMipmapFeature.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap; import java.util.ArrayList; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; @@ -34,7 +35,7 @@ import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; public abstract class TmfMipmapFeature implements ITmfMipmapFeature { /** The current state value */ - protected ITmfStateValue currentValue = TmfStateValue.nullValue(); + protected @NonNull ITmfStateValue currentValue = TmfStateValue.nullValue(); /** The current start time for the state value */ protected long currentStartTime; /** The list of ongoing state intervals per mipmap level */ @@ -167,7 +168,7 @@ public abstract class TmfMipmapFeature implements ITmfMipmapFeature { * The end time of the mipmap interval * @return A state value to be stored in the mipmap level attribute */ - protected abstract ITmfStateValue computeMipmapValue(List lowerIntervals, long startTime, long endTime); + protected abstract @NonNull ITmfStateValue computeMipmapValue(List lowerIntervals, long startTime, long endTime); /** * Get the mipmap resolution 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 777be00e28..9d25fbaeae 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 @@ -285,7 +285,7 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements * @return An iterable list of analysis this analyzes depends on. */ protected Iterable getDependentAnalyses() { - return checkNotNull(Collections.EMPTY_LIST); + return Collections.EMPTY_LIST; } private void execute(final ITmfTrace trace) { @@ -519,6 +519,6 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements @Override public Iterable getAnalysisRequirements() { - return checkNotNull(Collections.EMPTY_SET); + return Collections.EMPTY_SET; } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisModuleOutputs.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisModuleOutputs.java index 31fdc1e157..bd78f5897f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisModuleOutputs.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisModuleOutputs.java @@ -19,6 +19,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.InvalidRegistryObjectException; import org.eclipse.core.runtime.Platform; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.core.Activator; /** @@ -64,8 +65,8 @@ public class TmfAnalysisModuleOutputs { * * @return List of {@link ITmfNewAnalysisModuleListener} */ - public static Iterable getOutputListeners() { - List newModuleListeners = new ArrayList<>(); + public static Iterable<@NonNull ITmfNewAnalysisModuleListener> getOutputListeners() { + List<@NonNull ITmfNewAnalysisModuleListener> newModuleListeners = new ArrayList<>(); // Get the sources element from the extension point IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TMF_ANALYSIS_TYPE_ID); for (IConfigurationElement ce : config) { diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisRequirement.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisRequirement.java index 23f7cae944..098a23dd35 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisRequirement.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisRequirement.java @@ -53,7 +53,7 @@ public class TmfAnalysisRequirement { private final String fType; private final Map fValues = new HashMap<>(); - private final Set fInformation = new HashSet<>(); + private final Set<@NonNull String> fInformation = new HashSet<>(); /** * The possible level for each value. They must be listed in ascending order @@ -182,7 +182,7 @@ public class TmfAnalysisRequirement { * @param information * The information to be added */ - public void addInformation(String information) { + public void addInformation(@NonNull String information) { fInformation.add(information); } @@ -244,7 +244,7 @@ public class TmfAnalysisRequirement { * * @return The set of all the information */ - public Set getInformation() { + public Set<@NonNull String> getInformation() { return fInformation; } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/ITmfEventProvider.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/ITmfEventProvider.java index e1dadb9c27..e9db23b1a6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/ITmfEventProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/ITmfEventProvider.java @@ -129,7 +129,7 @@ public interface ITmfEventProvider extends ITmfComponent { * an empty list if no children (return value cannot be null). */ @NonNull - List getChildren(Class clazz); + List<@NonNull T> getChildren(Class clazz); /** * Gets the number of children diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/TmfEventProvider.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/TmfEventProvider.java index a20b2a9f35..6f6f4e51f9 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/TmfEventProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/TmfEventProvider.java @@ -15,6 +15,8 @@ package org.eclipse.tracecompass.tmf.core.component; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -529,11 +531,11 @@ public abstract class TmfEventProvider extends TmfComponent implements ITmfEvent @Override public List getChildren(Class clazz) { - List list = new ArrayList<>(); + List<@NonNull T> list = new ArrayList<>(); synchronized (fChildren) { for (TmfEventProvider child : fChildren) { if (clazz.isAssignableFrom(child.getClass())) { - list.add(clazz.cast(child)); + list.add(checkNotNull(clazz.cast(child))); } } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEvent.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEvent.java index ee2f573df2..12efe5e99f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEvent.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEvent.java @@ -71,5 +71,5 @@ public interface ITmfEvent extends IAdaptable { * @return the name of the event, same as getType().getName() * @since 1.0 */ - String getName(); + @NonNull String getName(); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/ITmfFilterTreeNode.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/ITmfFilterTreeNode.java index 73d0c35b9e..74bbce99a5 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/ITmfFilterTreeNode.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/ITmfFilterTreeNode.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.core.filter.model; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.filter.ITmfFilter; @@ -56,7 +57,7 @@ public interface ITmfFilterTreeNode extends ITmfFilter { * * @return The array (possibly empty) of children nodes. */ - public ITmfFilterTreeNode[] getChildren(); + public @NonNull ITmfFilterTreeNode[] getChildren(); /** *

Get the node by index

diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/TmfFilterTreeNode.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/TmfFilterTreeNode.java index c16223a96e..85ee891371 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/TmfFilterTreeNode.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/TmfFilterTreeNode.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; /** @@ -71,8 +72,8 @@ public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable } @Override - public ITmfFilterTreeNode[] getChildren() { - return children.toArray(new ITmfFilterTreeNode[0]); + public @NonNull ITmfFilterTreeNode[] getChildren() { + return children.toArray(new @NonNull ITmfFilterTreeNode[0]); } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventType.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventType.java index e7a35232d7..08b7c9c7c2 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventType.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventType.java @@ -12,6 +12,8 @@ package org.eclipse.tracecompass.tmf.core.parsers.custom; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; @@ -30,7 +32,7 @@ public abstract class CustomEventType extends TmfEventType { * Trace definition */ public CustomEventType(CustomTraceDefinition definition) { - super(definition.definitionName, getRootField(definition)); + super(checkNotNull(definition.definitionName), getRootField(definition)); } private static ITmfEventField getRootField(CustomTraceDefinition definition) { diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java index 3c2004c64a..f4f6e61aa1 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java @@ -520,7 +520,11 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo @Override public Iterable getStateSystems() { - return checkNotNull(Collections. singleton(fStateSystem)); + ITmfStateSystemBuilder stateSystem = fStateSystem; + if (stateSystem == null) { + return Collections.EMPTY_SET; + } + return Collections.singleton(stateSystem); } /** diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/ITmfStatistics.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/ITmfStatistics.java index f0c4cab8ad..71b6dd1899 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/ITmfStatistics.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/ITmfStatistics.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.core.statistics; import java.util.List; import java.util.Map; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; /** @@ -64,7 +65,7 @@ public interface ITmfStatistics { * * @return The map of , for the whole trace */ - Map getEventTypesTotal(); + Map<@NonNull String, @NonNull Long> getEventTypesTotal(); /** * Retrieve the number of events in the trace in a given time interval. diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfEventsStatistics.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfEventsStatistics.java index 4282b476d0..7c4fca784d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfEventsStatistics.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfEventsStatistics.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent; import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; @@ -104,12 +105,11 @@ public class TmfEventsStatistics implements ITmfStatistics { } @Override - public Map getEventTypesTotal() { + public Map<@NonNull String, @NonNull Long> getEventTypesTotal() { StatsPerTypeRequest request = new StatsPerTypeRequest(trace, TmfTimeRange.ETERNITY); sendAndWait(request); - Map stats = request.getResults(); - return stats; + return request.getResults(); } @Override @@ -182,7 +182,7 @@ public class TmfEventsStatistics implements ITmfStatistics { private class StatsPerTypeRequest extends TmfEventRequest { /* Map in which the results are saved */ - private final Map stats; + private final Map<@NonNull String, @NonNull Long> stats; public StatsPerTypeRequest(ITmfTrace trace, TmfTimeRange range) { super(trace.getEventType(), range, 0, ITmfEventRequest.ALL_DATA, @@ -190,7 +190,7 @@ public class TmfEventsStatistics implements ITmfStatistics { this.stats = new HashMap<>(); } - public Map getResults() { + public Map<@NonNull String, @NonNull Long> getResults() { return stats; } @@ -214,7 +214,7 @@ public class TmfEventsStatistics implements ITmfStatistics { } } - private void incrementStats(String key, long count) { + private void incrementStats(@NonNull String key, long count) { if (stats.containsKey(key)) { long curValue = checkNotNull(stats.get(key)); stats.put(key, curValue + count); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfStateStatistics.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfStateStatistics.java index 9f0825d917..7f57fff7b7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfStateStatistics.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfStateStatistics.java @@ -151,8 +151,8 @@ public class TmfStateStatistics implements ITmfStatistics { } @Override - public Map getEventTypesTotal() { - final Map map = new HashMap<>(); + public Map<@NonNull String, @NonNull Long> getEventTypesTotal() { + final Map<@NonNull String, @NonNull Long> map = new HashMap<>(); long endTime = typesStats.getCurrentEndTime(); try { diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/synchronization/SynchronizationManager.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/synchronization/SynchronizationManager.java index 29f972d0d9..40f044fbbe 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/synchronization/SynchronizationManager.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/synchronization/SynchronizationManager.java @@ -16,6 +16,7 @@ import java.io.File; import java.io.IOException; import java.util.Collection; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.core.Activator; import org.eclipse.tracecompass.tmf.core.component.TmfComponent; import org.eclipse.tracecompass.tmf.core.event.matching.ITmfEventMatching; @@ -45,7 +46,8 @@ public abstract class SynchronizationManager extends TmfComponent { * file * @return The synchronization object */ - public static SynchronizationAlgorithm synchronizeTraces(final File syncFile, final Collection traces, boolean doSync) { + public static SynchronizationAlgorithm synchronizeTraces(final File syncFile, + final Collection<@NonNull ITmfTrace> traces, boolean doSync) { SynchronizationAlgorithm syncAlgo; if (doSync) { @@ -78,7 +80,8 @@ public abstract class SynchronizationManager extends TmfComponent { * file * @return The synchronization object */ - public static SynchronizationAlgorithm synchronizeTraces(final File syncFile, final Collection traces, SynchronizationAlgorithm algo, boolean doSync) { + public static SynchronizationAlgorithm synchronizeTraces(final File syncFile, + final Collection<@NonNull ITmfTrace> traces, SynchronizationAlgorithm algo, boolean doSync) { SynchronizationAlgorithm syncAlgo; if (doSync) { @@ -116,7 +119,8 @@ public abstract class SynchronizationManager extends TmfComponent { return null; } - private static SynchronizationAlgorithm synchronize(final File syncFile, final Collection traces, SynchronizationAlgorithm syncAlgo) { + private static SynchronizationAlgorithm synchronize(final File syncFile, + final Collection<@NonNull ITmfTrace> traces, SynchronizationAlgorithm syncAlgo) { ITmfEventMatching matching = new TmfEventMatching(traces, syncAlgo); matching.matchEvents(); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java index 3cfee8a677..8948bca043 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java @@ -12,6 +12,8 @@ package org.eclipse.tracecompass.tmf.core.trace; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; @@ -78,7 +80,7 @@ public final class TmfTraceUtils { Set<@NonNull T> modules = new HashSet<>(); for (IAnalysisModule module : analysisModules) { if (moduleClass.isAssignableFrom(module.getClass())) { - modules.add(moduleClass.cast(module)); + modules.add(checkNotNull(moduleClass.cast(module))); } } return modules; diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/experiment/TmfExperiment.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/experiment/TmfExperiment.java index 59e1405bef..b2e3cea3a9 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/experiment/TmfExperiment.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/experiment/TmfExperiment.java @@ -31,6 +31,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; 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.internal.tmf.core.trace.experiment.TmfExperimentContext; @@ -242,7 +243,7 @@ public class TmfExperiment extends TmfTrace implements ITmfPersistentlyIndexable * * @return The array of contained traces */ - public List getTraces() { + public List<@NonNull ITmfTrace> getTraces() { return getChildren(ITmfTrace.class); } @@ -525,7 +526,7 @@ public class TmfExperiment extends TmfTrace implements ITmfPersistentlyIndexable final File syncFile = (syncDirectory != null) ? new File(syncDirectory + File.separator + SYNCHRONIZATION_FILE_NAME) : null; - final SynchronizationAlgorithm syncAlgo = SynchronizationManager.synchronizeTraces(syncFile, Collections. singleton(this), doSync); + final SynchronizationAlgorithm syncAlgo = SynchronizationManager.synchronizeTraces(syncFile, Collections.singleton(this), doSync); final TmfTraceSynchronizedSignal signal = new TmfTraceSynchronizedSignal(this, syncAlgo); 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 769c29c3a5..bbd60c9054 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 @@ -13,8 +13,6 @@ package org.eclipse.tracecompass.tmf.core.trace.text; -import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -81,7 +79,7 @@ public class TextTraceEventContent implements ITmfEventField { private TextTraceEventContent(@NonNull String fieldName) { fName = fieldName; fValue = null; - fFields = checkNotNull(Collections.EMPTY_LIST); + fFields = Collections.EMPTY_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 3b40a01bc7..56097510b7 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 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" }; + private static final @NonNull String @NonNull [] CMD_OUTPUT = { "This", "is", "the", "output" }; + private static final @NonNull String @NonNull [] CMD_NO_ERROR_OUTPUT = {}; + private static final @NonNull 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 27065c0024..03b2be25e8 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 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 @NonNull String @NonNull [] CMD_INPUT_UNIX = { "ls", "-l" }; + private static final @NonNull String @NonNull [] CMD_ERROR_INPUT_UNIX = { "ls", "blablablabla" }; + private static final @NonNull 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.tests/stubs/org/eclipse/tracecompass/internal/tmf/remote/core/stubs/shells/TestCommandShell.java b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/stubs/org/eclipse/tracecompass/internal/tmf/remote/core/stubs/shells/TestCommandShell.java index 63d94f4d75..4c0037b337 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/stubs/org/eclipse/tracecompass/internal/tmf/remote/core/stubs/shells/TestCommandShell.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/stubs/org/eclipse/tracecompass/internal/tmf/remote/core/stubs/shells/TestCommandShell.java @@ -14,7 +14,9 @@ package org.eclipse.tracecompass.internal.tmf.remote.core.stubs.shells; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandInput; import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandResult; import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput; @@ -25,6 +27,7 @@ import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandShell; /** * Command shell stub */ +@NonNullByDefault public class TestCommandShell implements ICommandShell { /** If the shell is connected */ @@ -36,16 +39,17 @@ public class TestCommandShell implements ICommandShell { } @Override - public ICommandResult executeCommand(ICommandInput command, IProgressMonitor monitor) throws ExecutionException { + public ICommandResult executeCommand(ICommandInput command, @Nullable IProgressMonitor monitor) throws ExecutionException { return executeCommand(command, monitor, null); } @Override - public ICommandResult executeCommand(ICommandInput command, IProgressMonitor monitor, ICommandOutputListener listener) throws ExecutionException { + public ICommandResult executeCommand(ICommandInput command, @Nullable IProgressMonitor monitor, + @Nullable ICommandOutputListener listener) throws ExecutionException { if (fIsConnected) { - return createCommandResult(0, new String[0], new String[0]); + return createCommandResult(0, new @NonNull String[0], new @NonNull String[0]); } - return createCommandResult(1, new String[0], new String[0]); + return createCommandResult(1, new @NonNull String[0], new @NonNull String[0]); } @Override @@ -64,8 +68,7 @@ public class TestCommandShell implements ICommandShell { * THe error output as an array of strings * @return {@link ICommandResult} instance */ - @NonNullByDefault - protected ICommandResult createCommandResult(int result, String[] output, String[] errorOutput) { + protected ICommandResult createCommandResult(int result, @NonNull String[] output, @NonNull String[] errorOutput) { return new CommandResult(result, output, errorOutput); } -} \ No newline at end of file +} diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandResult.java b/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandResult.java index 8bc9d4ab12..27e8b5a811 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandResult.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandResult.java @@ -11,11 +11,11 @@ **********************************************************************/ package org.eclipse.tracecompass.internal.tmf.remote.core.shell; -import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandResult; @@ -55,10 +55,10 @@ public class CommandResult implements ICommandResult { * @param errorOutput * THe error output as an array of strings */ - public CommandResult(int result, String[] output, String[] errorOutput) { + public CommandResult(int result, @NonNull String[] output, @NonNull String[] errorOutput) { fResult = result; - fOutput = checkNotNull(ImmutableList.copyOf(output)); - fErrorOutput = checkNotNull(ImmutableList.copyOf(errorOutput)); + fOutput = ImmutableList.copyOf(output); + fErrorOutput = ImmutableList.copyOf(errorOutput); } // ------------------------------------------------------------------------ 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 82b0911fcb..42b9fab045 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 @@ -115,14 +115,15 @@ public class CommandShell implements ICommandShell { } } catch (OperationCanceledException e) { } catch (InterruptedException e) { - return new CommandResult(1, new String[0], new String[] {e.getMessage()}); + return new CommandResult(1, new @NonNull String[0], + new @NonNull String[] { checkNotNull(e.getMessage()) }); } finally { stdout.stop(); stderr.stop(); process.destroy(); } } - return new CommandResult(1, new String[0], new String[] {"cancelled"}); //$NON-NLS-1$ + return new CommandResult(1, new @NonNull String[0], new @NonNull String[] { "cancelled" }); //$NON-NLS-1$ } }); @@ -154,12 +155,12 @@ public class CommandShell implements ICommandShell { result = origResult; stdout = origStdout; stderr = origStderr; - String[] output = splitLines(stdout); - String[] error = splitLines(stderr); + @NonNull String[] output = splitLines(stdout); + @NonNull String[] error = splitLines(stderr); return new CommandResult(result, output, error); } - private static String @NonNull [] splitLines(String output) { - return checkNotNull(output.split("\\r?\\n")); //$NON-NLS-1$ + private static @NonNull String @NonNull [] splitLines(String output) { + return output.split("\\r?\\n"); //$NON-NLS-1$ } } diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/TmfRemoteConnectionFactory.java b/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/TmfRemoteConnectionFactory.java index 4b3f734943..c602684c67 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/TmfRemoteConnectionFactory.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/TmfRemoteConnectionFactory.java @@ -53,7 +53,10 @@ public class TmfRemoteConnectionFactory { // Add local services IRemoteServicesManager manager = getService(IRemoteServicesManager.class); if (manager != null) { - CONNECTION_FACTORIES.put(manager.getLocalConnectionType().getId(), new LocalConnectionFactory()); + IRemoteConnectionType type = manager.getLocalConnectionType(); + if (type != null) { + CONNECTION_FACTORIES.put(checkNotNull(type.getId()), new LocalConnectionFactory()); + } } } diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/model/RemoteImportProfilesReader.java b/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/model/RemoteImportProfilesReader.java index ed962f12d2..2b13bda80d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/model/RemoteImportProfilesReader.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/model/RemoteImportProfilesReader.java @@ -29,6 +29,7 @@ import javax.xml.validation.Validator; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.remote.ui.Activator; import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement; import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.importexport.ManifestReader; @@ -48,7 +49,8 @@ public class RemoteImportProfilesReader { private static final String SCHEMA_FOLDER_NAME = "schema"; //$NON-NLS-1$ private static final String PROFILES_SCHEMA_FILE_NAME = "remote-profile.xsd"; //$NON-NLS-1$ - private static final TracePackageElement[] EMPTY_ARRAY = new TracePackageElement[0]; + private static final @NonNull TracePackageElement @NonNull [] EMPTY_ARRAY = + new @NonNull TracePackageElement[0]; /** * Validate the content of the profiles file from an input stream diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/ColorsViewTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/ColorsViewTest.java index 7c3455c7e8..1570a14a8d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/ColorsViewTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/ColorsViewTest.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.swt.graphics.RGB; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; @@ -102,7 +103,7 @@ public class ColorsViewTest { } @Override - public ITmfFilterTreeNode[] getChildren() { + public @NonNull ITmfFilterTreeNode[] getChildren() { return null; } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java index 4b16c75a0a..959a07fe68 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.Messages; @@ -57,8 +58,8 @@ public class TmfBaseColumnDataProviderTest { private static final String fTestName = "ColumnDataProviderTest"; - private final String fTypeId1 = "Some type1"; - private final String fTypeId2 = "Some type2"; + private final @NonNull String fTypeId1 = "Some type1"; + private final @NonNull String fTypeId2 = "Some type2"; private final String fLabel0 = "label1"; private final String fLabel1 = "label2"; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java index 04934b971b..4328b2c2c5 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.Vector; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.Messages; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTree; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; @@ -48,8 +49,8 @@ public class TmfBaseStatisticsDataTest { private static final String fTestName = "StatisticsDataTest"; - private final String fTypeId1 = "Some type1"; - private final String fTypeId2 = "Some type2"; + private final @NonNull String fTypeId1 = "Some type1"; + private final @NonNull String fTypeId2 = "Some type2"; private final String fLabel0 = "label1"; private final String fLabel1 = "label2"; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java index 961b712118..fa9f73cf9c 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.fail; import java.util.Arrays; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.Messages; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTree; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; @@ -46,8 +47,8 @@ public class TmfTreeContentProviderTest { private static final String fTestName = "TreeContentProviderTest"; - private final String fTypeId1 = "Some type1"; - private final String fTypeId2 = "Some type2"; + private final @NonNull String fTypeId1 = "Some type1"; + private final @NonNull String fTypeId2 = "Some type2"; private final String fLabel0 = "label1"; private final String fLabel1 = "label2"; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/importexport/ManifestReader.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/importexport/ManifestReader.java index 3deb4ba1de..62ccbd9ad6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/importexport/ManifestReader.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/importexport/ManifestReader.java @@ -31,6 +31,7 @@ import javax.xml.validation.Validator; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.ui.Activator; import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.ITracePackageConstants; import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageBookmarkElement; @@ -55,7 +56,8 @@ public class ManifestReader { private static final String SCHEMA_FOLDER_NAME = "schema"; //$NON-NLS-1$ private static final String EXPORT_MANIFEST_SCHEMA_FILE_NAME = "export-manifest.xsd"; //$NON-NLS-1$ - private static final TracePackageElement [] EMPTY_ARRAY = new TracePackageElement[0]; + private static final @NonNull TracePackageElement @NonNull [] EMPTY_ARRAY = + new @NonNull TracePackageElement[0]; /** * Validate the content of a manifest from an input stream diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/wizards/SelectRootNodeWizardPage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/wizards/SelectRootNodeWizardPage.java index 751e36e269..8c6635f982 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/wizards/SelectRootNodeWizardPage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/wizards/SelectRootNodeWizardPage.java @@ -186,9 +186,7 @@ public class SelectRootNodeWizardPage extends WizardPage { traces.add((TmfTraceElement) sel); } } - TmfTraceElement[] result = new TmfTraceElement[traces.size()]; - traces.toArray(result); - return result; + return traces.toArray(new @NonNull TmfTraceElement[0]); } /** diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/wizards/SelectTracesWizardPage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/wizards/SelectTracesWizardPage.java index e22c5da36c..1bb99ccfb4 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/wizards/SelectTracesWizardPage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/wizards/SelectTracesWizardPage.java @@ -475,9 +475,7 @@ public class SelectTracesWizardPage extends WizardPage { traces.add((TmfTraceElement) sel); } } - TmfTraceElement[] result = new TmfTraceElement[traces.size()]; - traces.toArray(result); - return result; + return traces.toArray(new @NonNull TmfTraceElement[0]); } } 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 a93eb88099..693b660d20 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 @@ -255,6 +255,9 @@ public class TmfEventPropertySource implements IPropertySource { @Override public Object getPropertyValue(Object id) { + if (!(id instanceof String)) { + return null; + } return event.getCustomAttribute((String) id); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterManager.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterManager.java index 7efcf62539..5f2ba301c6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterManager.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterManager.java @@ -20,6 +20,7 @@ import java.io.IOException; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.runtime.IPath; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.ui.Activator; import org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterRootNode; @@ -89,7 +90,7 @@ public class FilterManager { * * @return The array of filters */ - public static ITmfFilterTreeNode[] getSavedFilters() { + public static @NonNull ITmfFilterTreeNode[] getSavedFilters() { return fRoot.clone().getChildren(); }