| Summary: | [1.8][null] Bogus Warning: The nullness annotation is redundant with a default that applies to this location | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Clovis Seragiotto <clovis.seragiotto> |
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | clovis.seragiotto, srikanth_sankaran, stephan.herrmann |
| Version: | 4.4 | ||
| Target Milestone: | 4.5 M1 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 438458 | ||
In fact,
@NonNullByDefault({ RETURN_TYPE, TYPE_PARAMETER })
suffices to reproduce the error.
I have a fix under test: By using a default for TYPE_PARAMETER, V is a nonnull type. When we fill in the defaults for the signature of getV() we find: - the return type is already nonnull - a nonnull default shall be applied to the return type This _looks_ like redundant specification. Fixed by checking whether the method return has an explicit annotation (AST). Since the parser associates top-level return annotations to the method, that's where we actually look. Similar change is also made for parameters. Released for 4.5 M1 via http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=68b132a771077222c8a489923225ada23ba86a6a Verified for 4.5 M1 using Version: Mars (4.5) Build id: I20140804-2000 |
For the program below (which has no nullness annotation except for @NonNullByDefault), the compiler issues the warning "The nullness annotation is redundant with a default that applies to this location" import org.eclipse.jdt.annotation.NonNullByDefault; import static org.eclipse.jdt.annotation.DefaultLocation.*; @NonNullByDefault({ PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT, TYPE_PARAMETER }) interface Bar<V> { V getV(); } By choosing the quick fix "remove redundant nullness annotation", one gets: An exception occurred while applying the quick fix: The fix 'Remove redundant nullness annotation' generated a null change.