Board index » jbuilder » is this a bug or a feature? It should be an error. if statement with "=" instead of "==".

is this a bug or a feature? It should be an error. if statement with "=" instead of "==".


2005-03-30 09:52:04 PM
jbuilder9
booelan doNotDoItemStateChange;
if (doNotDoItemStateChange == false && e.getStateChange() == e.SELECTED)
{
}
By mistake I typed this as
if (doNotDoItemStateChange = false && e.getStateChange() == e.SELECTED)
and it is accepted by JBuilder 7, JBuilder X which of course did not do the
job.
 
 

Re:is this a bug or a feature? It should be an error. if statement with "=" instead of "==".

Mehmet F. Erten wrote:
Quote
booelan doNotDoItemStateChange;

if (doNotDoItemStateChange == false && e.getStateChange() == e.SELECTED)
{

}

By mistake I typed this as

if (doNotDoItemStateChange = false && e.getStateChange() == e.SELECTED)

and it is accepted by JBuilder 7, JBuilder X which of course did not do the
job.



This is a syntactically valid statement, and is a common cause of errors
and bugs.
Code checkers generally find such things for you. Code Audits feature
in JBuilder (Enterprise, maybe Developer) *should* (I don't use it, so I
can't say for sure) and PMD (SourceForge project) definitely would catch it.
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
www.google.ca/advanced_group_search
Other Newsgroup Searches:
www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
www.visi.com/~gyles19/fom-serve/cache/1.html