| Summary: | [1.8][null] @NonNullByDefault illegally tries to affect "throws E" | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Stephan Herrmann <stephan.herrmann> |
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | chris, kivancmuslu, srikanth_sankaran |
| Version: | 4.4 | ||
| Target Milestone: | 4.5 M1 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 438458 | ||
Example should be:
//----
@org.eclipse.jdt.annotation.NonNullByDefault
public class Test<E extends Exception> {
void test() throws E {}
}
//----
Now the default clearly applies to the explicit upper bound of E.
Root cause of the bug: this analysis for illegal location of null type annotation uses information from the binding, where it should use information from the AST.
*** Bug 437050 has been marked as a duplicate of this bug. *** I have a fix under test: By providing a new TypeReference.hasNullTypeAnnotation() we can now query the AST for explicit null type annotations. In particular STB.resolveTypesFor(..) now uses this new query when analysing the method's exceptionTypes. Other updates along the same lines: - ReferenceExpression.lhs (if it's a TypeReference) - AbstractMethodDeclaration.receiver - InstanceOfExpression - Argument (as catch argument) Released for 4.5 M1 via http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=6dc3139df48b05a697942ac75c097b0346555e03 Verified for 4.5 M1 using Version: Mars (4.5) Build id: I20140804-2000 |
//---- @org.eclipse.jdt.annotation.NonNullByDefault public class Test<E> { void test() throws E {} } //---- Error: void test() throws E {} ^ Nullness annotations are not applicable at this location