Bug 70923

Summary: warning for a suspicious == or !=
Product: [Eclipse Project] JDT Reporter: Adam Kiezun <akiezun>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: enhancement    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Adam Kiezun CLA 2004-07-27 13:26:06 EDT
3.0
when two expressions of types that are not cast-compatible are compared by == 
_the only_ way for them to be identical is that they are both null.

so code like that uses == to compare a String with an Integer
is almost certainly buggy.

it would be nice to have a warning for that
Comment 1 Philipe Mulet CLA 2004-07-27 16:22:12 EDT
This is already flagged as an error, since by JLS operands have to be cast 
compatible.

public class X {
	public static void main(String[] args) {
		String s = "aaa";
		Integer i = new Integer(0);
		if (s == i) {} // incompatible types
	}
}
Comment 2 Adam Kiezun CLA 2004-07-27 16:36:51 EDT
silly me - sumbitted a bug without checking first
sory and thanks