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.
The "use functional operations" hint will convert List<Object> target = new ArrayList(); for (Object o : collection) target.add(o); into collection.stream().forEach((o) -> { target.add(o); }); but this is incorrect because Stream.forEach does not preserve encounter order, possibly leading to the elements being added out of order. The Stream.forEach Javadoc is mildly ambiguous, but Brian Goetz has confirmed that Stream.forEach does not preserve encounter order even for sequential streams in the answer to this Stack Overflow question: http://stackoverflow.com/q/34247318/3614835 Iterable.forEach does preserve order, as does Stream.forEachOrdered, so the hint should be changed to use one of those two.
Increasing priority; such transformation may create hard to spot bugs - ideally surfacing with some new JDK version or fancy collection which really cares about stream performance. I am tempted, ;) for your this very case, to change NB's behaviour to rewrite to collection.forEach(target::add) ... which will rule out streams altogether but that obviously does not solve the more complicated ones.
I've fixed this issue. After a LOT of thinking I just changed forEach into forEachOrdered without adding much of logic and filed an issue #262189, which seems to take a LOT of time to fix. I fixed just some little but annoing bugs this time. Committed as jet-main#035ef8f5311b
Integrated into 'main-silver', will be available in build *201605250002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/035ef8f5311b User: Svata Dedic <sdedic@netbeans.org> Log: #257129: use forEachOrdered to maintain iteration order; fixed linearization when a statement follows a nested block.