This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 222350

Summary: Unable to detect two constant string (or other object) comparision
Product: java Reporter: ecerichter
Component: HintsAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal CC: markiewb
Priority: P3    
Version: 7.3   
Hardware: PC   
OS: Windows 7   
Issue Type: ENHANCEMENT Exception Reporter:

Description ecerichter 2012-11-18 21:18:32 UTC
Product Version = NetBeans IDE Dev (Build 201211150001)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_09
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.5-b02

NetBeans must be able to notify user that he is doing comparision between two constants that will never be true.
For instance, consider the following code:

/** Example with String **/
String acao = request.getParameter("action");

if("doSave".equals("acao")) { // this line should be marked - will never be true.
  // do somethig when true - that means, never!
}


/** Example with Integer **/
Integer i = Integer.valueOf(5);

if(i.equals(new Integer(8))) { // this line should be marked - will never be true.
  // do somethig when true - that means, never!
}


/** Example with BigDecimal **/
BigDecimal d1 = new BigDecimal("10.0");
BigDecimal d2 = new BigDecimal("20.0");

if(d1.compareTo(d2)==0) { // this line should be marked - will never be true.
  // do somethig when true - that means, never!
}
/** end of examples **/



Even if only the first case (string comparision) is covered, then it will be great.

Regards,

Edson