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 179398 - Assertion rewrite rule mangles negation syntax
Summary: Assertion rewrite rule mangles negation syntax
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P2 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-11 17:47 UTC by _ tboudreau
Modified: 2010-01-21 03:02 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2010-01-11 17:47:36 UTC
Say you have a

    public void setPropertyColumns(String... namesAndDisplayNames) {
        assert namesAndDisplayNames.length % 2 == 0 :
            "Odd number of names and display names: " + //NOI18N
            Arrays.asList(namesAndDisplayNames);

You get a hint to rewrite it to use exceptions (not sure why assertions are bad...).

If you accept the hint, you get:
        if (!namesAndDisplayNames.length % 2 == 0) {
            throw new IllegalStateException("Odd number of names and display names: " + Arrays.asList(namesAndDisplayNames));
        }

It needs to generate either
if (!(namesAndDisplayNames.length % 2 == 0)) {
which is ugly, or
if (namesAndDisplayNames.length % 2 != 0) {
which would be more correct.
Comment 1 Jan Lahoda 2010-01-21 03:02:07 UTC
The hint was removed during a cleanup:
http://hg.netbeans.org/jet-main/rev/80bdf9e29ada