Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 501601

Summary: Null annotation not show for external annotations
Product: [Eclipse Project] JDT Reporter: Clovis Seragiotto <clovis.seragiotto>
Component: UIAssignee: Stephan Herrmann <stephan.herrmann>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: stephan.herrmann
Version: 4.7   
Target Milestone: 4.16 M1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Clovis Seragiotto CLA 2016-09-16 08:46:55 EDT
If you place the mouse pointer on the invocation of a method with external annotations, you don't always see all the annotations:

import java.util.Set;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;

import com.google.common.collect.Sets;

@NonNullByDefault({})
public class Foo {
    static <E> @NonNull Set<E> union(
            final @NonNull Set<? extends E> set1, final @NonNull Set<? extends E> set2) {
        throw new Error();
    }
    
    void test(@NonNull Set<Integer> a, @NonNull Set<Integer> b) {
        union(a, b); // (1)
        Sets.union(a, b); // (2)
    }
}

By hovering over the method invocation (1), the result is:

@NonNull Set<Integer> Foo.union(@NonNull Set<? extends Integer> set1, @NonNull Set<? extends Integer> set2)

By hovering over the method invocation (2), however, which has the @NonNull annotations for the return value and for both parameters, the result is:

@NonNull SetView<Integer> com.google.common.collect.Sets.union(@NonNull Set<? extends Integer> set1, Set<? extends Integer> set2)

That is, for (2), @NonNull is missing for the second parameter.
Comment 1 Stephan Herrmann CLA 2016-09-16 12:07:36 EDT
Just so that I understand: the bug title speaks of external annotations, but comment 0 only shows regular (source) annotations. With generics in the picture, your annotations should propagate into individual method signatures. Is that what you are expecting, or do you additionally have external annotations that should be taken into account? If the latter, could you include the .eea file?
Comment 2 Clovis Seragiotto CLA 2016-09-19 01:26:32 EDT
class com/google/common/collect/Sets
union
 <E:Ljava/lang/Object;>(Ljava/util/Set<+TE;>;Ljava/util/Set<+TE;>;)Lcom/google/common/collect/Sets$SetView<TE;>;
 <E:Ljava/lang/Object;>(L1java/util/Set<+TE;>;L1java/util/Set<+TE;>;)L1com/google/common/collect/Sets$SetView<TE;>;
Comment 3 Eclipse Genie CLA 2020-03-31 04:02:00 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Stephan Herrmann CLA 2020-03-31 15:11:19 EDT
(In reply to Clovis Seragiotto from comment #0)
> If you place the mouse pointer on the invocation of a method with external
> annotations, you don't always see all the annotations:
> 
> import java.util.Set;
> 
> import org.eclipse.jdt.annotation.NonNull;
> import org.eclipse.jdt.annotation.NonNullByDefault;
> 
> import com.google.common.collect.Sets;
> 
> @NonNullByDefault({})
> public class Foo {
>     static <E> @NonNull Set<E> union(
>             final @NonNull Set<? extends E> set1, final @NonNull Set<?
> extends E> set2) {
>         throw new Error();
>     }
>     
>     void test(@NonNull Set<Integer> a, @NonNull Set<Integer> b) {
>         union(a, b); // (1)
>         Sets.union(a, b); // (2)
>     }
> }
> 
> By hovering over the method invocation (1), the result is:
> 
> @NonNull Set<Integer> Foo.union(@NonNull Set<? extends Integer> set1,
> @NonNull Set<? extends Integer> set2)
> 
> By hovering over the method invocation (2), however, which has the @NonNull
> annotations for the return value and for both parameters, the result is:
> 
> @NonNull SetView<Integer> com.google.common.collect.Sets.union(@NonNull
> Set<? extends Integer> set1, Set<? extends Integer> set2)
> 
> That is, for (2), @NonNull is missing for the second parameter.

Using today's HEAD, hovering over (2) says:

@NonNull SetView<Integer> com.google.common.collect.Sets.union(@NonNull Set<? extends Integer> set1, @NonNull Set<? extends Integer> set2)

Something must have been fixed :)