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

Bug 369319

Summary: [junit] interesting warning in JUnitPropertyTester
Product: [Eclipse Project] JDT Reporter: Stephan Herrmann <stephan.herrmann>
Component: UIAssignee: Dani Megert <daniel_megert>
Status: RESOLVED FIXED QA Contact:
Severity: trivial    
Priority: P3 CC: daniel_megert
Version: 3.8   
Target Milestone: 3.8 M5   
Hardware: All   
OS: All   
Whiteboard:

Description Stephan Herrmann CLA 2012-01-21 16:06:06 EST
While playing with null analysis for more kinds of expressions (bug 331649 and bug 364326) I tried my current implementation against  org.eclipse.jdt.junit.core to find the following interesting warning:

1. WARNING in src/org/eclipse/jdt/internal/junit/JUnitPropertyTester.java (in line 47):
	throw new IllegalArgumentException("Element must be of type 'IAdaptable', is " + receiver == null ? "null" : receiver.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
	                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Null comparison always yields false: this expression cannot be null

I hope the above renders correctly in bugzilla so that you can see what the compiler sees :)
Comment 1 Stephan Herrmann CLA 2012-01-21 16:09:26 EST
(In reply to comment #0)
> I hope the above renders correctly in bugzilla so that you can see what the
> compiler sees :)

Automatic line wrapping didn't help, so here's the relevant part again:

"Element must be of type 'IAdaptable', is " + receiver == null
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Null comparison always yields false: this expression cannot be null
Comment 2 Dani Megert CLA 2012-01-23 06:35:13 EST
That's a nice one.

Fixed in master: 423f052c415eff05a9d05be3cf02e69b1d938ec6