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 243713 - Inspect and transform: "Remove redundant cast to int" removes cast with side effect
Summary: Inspect and transform: "Remove redundant cast to int" removes cast with side ...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: PC Linux
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-09 21:13 UTC by xzel23
Modified: 2014-06-19 02:36 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 xzel23 2014-04-09 21:13:24 UTC
Product Version = NetBeans IDE 8.0 (Build 201403101706)
Operating System = Linux version 3.11.0-19-generic running on amd64
Java; VM; Vendor = 1.7.0_51
Runtime = Java HotSpot(TM) 64-Bit Server VM 24.51-b03

Running "Inspect and Transform" removes cast from double to integer which may lead to incorrect code. This should only be done when no side effects might be introduced, for example when casting from int to long. 

public double foo(double x) {
    return (int) x; // inspect and transform will simply remove the cast producing different results for non-integral values
}
Comment 1 Jiri Prox 2014-04-14 09:04:03 UTC
reproducible

the related hint is: "Type cast is too String"
Comment 2 xzel23 2014-04-14 16:00:55 UTC
Slight correction. The related hint is: "Type cast is too strong"
Comment 3 Svata Dedic 2014-06-13 12:16:25 UTC
Should be fixed by jet-main#fe50bb70d305
Comment 4 Quality Engineering 2014-06-19 02:36:40 UTC
Integrated into 'main-silver', will be available in build *201406190001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/fe50bb70d305
User: Svata Dedic <sdedic@netbeans.org>
Log: #243713: do not report precision losing casts, casts where the result primitive gets boxed