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.
Product Version: NetBeans IDE Dev (Build 201605260002) Java: 1.8.0_92; Java HotSpot(TM) 64-Bit Server VM 25.92-b14 Runtime: Java(TM) SE Runtime Environment 1.8.0_92-b14 System: Windows 10 version 10.0 running on amd64; Cp1252; en_CA (nb) User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev Given: public void clear() { return ConcurrentLinkedHashMap.this.clear(); } Netbeans flags the method body with "remove unnecessary return statement". Invoking the hint removes the entire line. I am expecting it to remove "return" and leave "ConcurrentLinkedHashMap.this.clear();" unchanged.
There are cases when the entire statement could be removed; the choice mainly depends on the user. However removing 'return' could be quite tricky - not all expressions can be interpreted as statement, c.f. statements like return s.length() + 1; return empty ? s : null; return checkFoo() || checkBar(); Even in the best case ;) the transformed code will likely break synchronization rules, i.e. private volatile int foo; ... return s.length() + foo; will transform into s.length(); and will not trigger the half-synchronization on 'foo'.
If you can't apply the hint safely then the hint shouldn't be provided in the first place :) Either way, the hint should never result in data loss :)
fixed in jet-main#fe39387af38a(In reply to _ gtzabari from comment #2) > If you can't apply the hint safely then the hint shouldn't be provided in > the first place :) Either way, the hint should never result in data loss :) Well, the fix did exactly what its label said: it removed the [entire] return statement. New hint fix added in jet-main#fe39387af38a
Integrated into 'main-silver', will be available in build *201607190002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/fe39387af38a User: Svata Dedic <sdedic@netbeans.org> Log: #262290: Return expression can be retained as series of statements