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 233017 - "Use JDK 5 for-loop" ("Convert to for-loop") removes assignments to the array
Summary: "Use JDK 5 for-loop" ("Convert to for-loop") removes assignments to the array
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.4
Hardware: PC Windows 8
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
: 235545 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-07-18 17:47 UTC by xehpuk
Modified: 2013-10-14 13:25 UTC (History)
1 user (show)

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 xehpuk 2013-07-18 17:47:58 UTC
Product Version = NetBeans IDE 7.4 Beta (Build 201307092200)
Operating System = Windows 8 version 6.2 running on x86
Java; VM; Vendor = 1.7.0_25
Runtime = Java HotSpot(TM) Client VM 23.25-b01

Consider this method:
/** Trims all strings in the array. */
void trimArray(String[] s) {
	for (int i = 0; i < s.length; i++) {
		s[i] = s[i].trim(); // Alters the array.
	}
}

NetBeans shows the hint "Use JDK 5 for-loop" ("Convert to for-loop").
This renders the method useless:
void trimArray(String[] s) {
	for (String item : s) {
		item = item.trim(); // Does not do much.
	}
}

In these situations with array assignments this hint should not be shown.
Comment 1 Quality Engineering 2013-07-21 02:17:44 UTC
Integrated into 'main-silver', will be available in build *201307202300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/33690b8725cd
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #233017: "Use JDK 5 for-loop" ("Convert to for-loop") removes assignments to the array
Comment 2 Jan Lahoda 2013-07-21 06:03:30 UTC
Good catch, thanks. Fixed by the above changeset.
Comment 3 Svata Dedic 2013-10-14 13:25:22 UTC
*** Bug 235545 has been marked as a duplicate of this bug. ***