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 java source static analysis believes that done is not referenced in the "bad" method. Using "done = done |" rather than "done |=" works as expected. public class FlowFailure { public static void bad(String... args) { boolean done = false; long counting = 0; while (!(done |= Thread.currentThread().isInterrupted())) { counting++; done = counting > 1_000_000_000; } } public static void good(String... args) { boolean done = false; long counting = 0; while (!(done = done | Thread.currentThread().isInterrupted())) { counting++; done = counting > 1_000_000_000; } } }
Good catch. In addition, the 'bad' method does not report that the value assigned to 'done' is actually unused. Done itself _is_ used, the _value_ of the |= operation is also used (to control the cycle) but the copy assigned to 'done' variable is never fetched again. I'll make an additional hint + fix for this case, in addition to fixing the reported error.
Implemented as jet-main#3842dbadbb65
Integrated into 'main-silver', will be available in build *201611130001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/3842dbadbb65 User: Svata Dedic <sdedic@netbeans.org> Log: #267508: unused values from compound assignments are reported. Fix to change comp. assignment to expression provided.