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

Bug 438250

Summary: [1.8][null] NPE trying to report bogus null annotation conflict
Product: [Eclipse Project] JDT Reporter: Clovis Seragiotto <clovis.seragiotto>
Component: CoreAssignee: 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    

Description Clovis Seragiotto CLA 2014-06-26 07:31:14 EDT
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);
}
Comment 1 Stephan Herrmann CLA 2014-06-28 14:11:36 EDT
Thanks, I can reproduce.
Comment 2 Stephan Herrmann CLA 2014-07-22 10:04:57 EDT
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.
Comment 4 Srikanth Sankaran CLA 2014-08-05 04:54:15 EDT
Verified that no NPE is seen for the test case in comment#0 using 
Version: Mars (4.5)
Build id: I20140804-2000