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

Bug 422796

Summary: [compiler][null] boxed boolean reported as potentially null after null test in lazy disjunction
Product: [Eclipse Project] JDT Reporter: Patrice Chalin <chalin>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: chalin, jarthana, martijn.dashorst, shankhba, stephan.herrmann
Version: 4.3.1   
Target Milestone: 4.4 M7   
Hardware: All   
OS: Mac OS X   
Whiteboard:

Description Patrice Chalin CLA 2013-11-28 13:32:25 EST
Consider the code given below. Note the spurious potential NPE reported at (*).

import org.jmlspecs.annotation.NonNullByDefault;
import org.jmlspecs.annotation.Nullable;
import org.junit.Test;

@NonNullByDefault
public class NullExprTest {
	
	private @Nullable Boolean b() { return null; }
	
	@Test
	public void testBoolean() {
		Boolean b1 = b();
		boolean b = b1 == null || 
				b1; // <-- reports potential NPE (*)
		org.junit.Assert.assertTrue(b);
	}

}
Comment 1 Stephan Herrmann CLA 2014-04-29 19:22:31 EDT
Thanks for the test, Patrice.

I have a simple fix under test.
Comment 2 Stephan Herrmann CLA 2014-04-30 03:44:08 EDT
Test & fix released for 4.4 M7 via http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=a6d7d17b7bc9c61b1990ed86d94864463a8a31d4
Comment 3 Jay Arthanareeswaran CLA 2014-04-30 11:30:40 EDT
Verified for 4.4 M7 with build I20140430-0800
Comment 4 Stephan Herrmann CLA 2015-05-21 11:32:08 EDT
*** Bug 415866 has been marked as a duplicate of this bug. ***