| Summary: | [1.8][null] NPE trying to report bogus null annotation conflict | ||
|---|---|---|---|
| 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, shankhba, srikanth_sankaran, stephan.herrmann |
| Version: | 4.4 | ||
| Target Milestone: | 4.5 M1 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 438458 | ||
Thanks, I can reproduce. I have a fix under test: The NPE occurred when trying to report contradiction against an annotation that doesn't exist: the type bound 'extends Runnable' is implicitly nonnull via the @NonNullByDefault, but there's no explicit annotation to complain about. Fixed by detecting the situation where a type parameter has an explicit null annotation and one of its bound has an implicit null annotation. Instead of trying to report contradiction, let the explicit annotation override the implicit one. OIOW: if a type parameter already has a null annotation, there's no use for a applying a default any more. |
For the following program (with annotation-based null analysis enabled), one get a NullPointerException from the compiler: Internal compiler error: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.contradictoryNullAnnotationsOnBounds(ProblemReporter.java:9522) @org.eclipse.jdt.annotation.NonNullByDefault(org.eclipse.jdt.annotation.DefaultLocation.TYPE_BOUND) public interface FooBar { <@org.eclipse.jdt.annotation.Nullable R extends Runnable> R foobar(R r); }