Fix new errors due to automatic annotation of Class<T> types
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Sun, 29 Nov 2015 03:36:40 +0000 (22:36 -0500)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Thu, 3 Dec 2015 05:37:11 +0000 (00:37 -0500)
commit2f79cfbc5d8b9d6ed627f76d4b1f1b24383c6c4f
treeecf4df17951839217ba2107ded781d195d179e92
parent615b21456c1020d91db5ef6e6076fb67fea18307
Fix new errors due to automatic annotation of Class<T> types

The null analysis now automatically assumes that generic class types
(the "T" in Class<T>) are always @NonNull. See bug 477719.
This clears a bunch of warnings we had due to using Something.class
as parameters. Great!

However, this introduces a new problem. When a generic type parameter
is used both as parameter and as return value, and the client specifies
an annotation on the parameter during a call, the default behaviour is
to assume this annotation on the return type too.

In some cases this assumption is correct:

    List<@NonNull String>.get() returns a @NonNull String

But in some others it is not:

    Map<@NonNull K, @NonNull V>.get() should *NOT* return a @NonNull V.

Now some methods of the form:

    V something(Class<V> type);

also follow this pattern, and the "automatic" @NonNull applied to V
also gets applies to the return value. In some (most?) cases this is
incorrect, and we have to supply external annotations to change the
return value to @Nullable. Just like we did for Map.get().

See bug 483143 for more information.

The return values of the following methods are now annotated as
@Nullable:

Class.getAnnotation()
DsfServicesTracker.getService()
IRemoteConnection.getService()
IRemoteConnectionType.getService()

and related null-checks were added.

Change-Id: I2c60835160a46e88ff293a5fd68774021c2b00a9
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/61521
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
14 files changed:
common/org.eclipse.tracecompass.common.core/annotations/java/lang/Class.eea [new file with mode: 0644]
common/org.eclipse.tracecompass.common.core/annotations/org/eclipse/cdt/dsf/service/DsfServicesTracker.eea [new file with mode: 0644]
common/org.eclipse.tracecompass.common.core/annotations/org/eclipse/remote/core/IRemoteConnection.eea [new file with mode: 0644]
common/org.eclipse.tracecompass.common.core/annotations/org/eclipse/remote/core/IRemoteConnectionType.eea [new file with mode: 0644]
gdbtrace/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/NewConnectionDialog.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/ImportHandler.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/model/impl/TargetNodeComponent.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/property/TargetNodePropertySource.java
releng/org.eclipse.tracecompass.alltests/build.properties
tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/messages/Messages.java
tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/messages/messages.properties
tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/internal/tmf/remote/core/shell/CommandShell.java
tmf/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/TmfRemoteConnectionFactory.java
This page took 0.026458 seconds and 5 git commands to generate.