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 251080 - Skip transformation for boxed values which are compared with equality operators in "Inspect and Transform"
Summary: Skip transformation for boxed values which are compared with equality operato...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-10 19:45 UTC by kalle1
Modified: 2015-08-05 13:55 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 kalle1 2015-03-10 19:45:21 UTC
The code

    Deque<List<Object>> list = new LinkedList<List<Object>>();
    List<Object> lastRemoved = list.getLast();
    while (((Long) list.getFirst().get(0)).longValue() == ((Long) lastRemoved.get(0)).longValue()) {
        return;
    }
    throw new RuntimeException();

would be transformed into 

    Deque<List<Object>> list = new LinkedList<List<Object>>();
    List<Object> lastRemoved = list.getLast();
    while (((Long) list.getFirst().get(0)) == ((Long) lastRemoved.get(0))) {
        return;
    }
    throw new RuntimeException();

which causes the programmer to fix the comparison manually (i.e. add a `@SuppressWarning` in the case the comparison really should take place with `==` and `!=` or change the code.

This is especially annoying in conjunction with https://netbeans.org/bugzilla/show_bug.cgi?id=251078 because "Inspect and Transform" breaks your code and you won't even realize it.
Comment 1 Svata Dedic 2015-08-05 13:55:07 UTC
Fixed as part of issue #243581