Bug 70923 - warning for a suspicious == or !=
Summary: warning for a suspicious == or !=
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 enhancement (vote)
Target Milestone: 3.1 M1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-27 13:26 EDT by Adam Kiezun CLA
Modified: 2005-01-11 11:03 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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