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

Bug 180925

Summary: [compiler][null][correlation] Invalid null reference with ternary operator
Product: [Eclipse Project] JDT Reporter: NoName <utilisateur_182>
Component: CoreAssignee: Maxime Daniel <maxime_daniel>
Status: RESOLVED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P3 CC: stephan.herrmann
Version: 3.3Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description NoName CLA 2007-04-04 07:42:03 EDT
Build ID: I20070323-1616

Steps To Reproduce:
Pasting the following code:


public class Test {
	public static void main(String[] args) {
		if (args.length >= 1) {
			String value = System.getProperty(args[0]);
			String s = value != null ? value.trim() : null;
			
			if (s != null)
				System.err.println("s.length() = " + value.length()); // warning on value
			// warning is "Potential null pointer access: The variable value may be null at this location"
		}
	}
}


More information:
if s is not null, value cannot be null
Comment 1 Maxime Daniel CLA 2007-04-04 09:45:40 EDT

*** This bug has been marked as a duplicate of bug 128806 ***
Comment 2 Stephan Herrmann CLA 2018-08-30 10:44:22 EDT

*** This bug has been marked as a duplicate of bug 538421 ***