Community
Participate
Working Groups
public class As { void m(int i){ if (true) return; int y= 0; // <<< m(y); } } should the //<<< line be marked as 'unreachable code' or 'unused temp' ? it is 'unused temp' now, which feels somewhat wrong (the temps is used after all - just that code is never called)
Good question. As per spec, the code is officially reachable (no complaint is supposed to be issued). But a warning would still be indicated. The variable is also unused (you could remove it completely), but we could avoid reporting it inside unreachable code...
Defer
This erroneous warning only surfaces when in Window => Preferences => Java => Compiler the item "Unused local variables" is set to "Warning". Another test case used was: public class A { final static boolean DEBUG = false; void foo() { if (DEBUG) { String str = "foo"; System.err.println("error in xyz: " + str); } } }
Seems trivial, reopen.
Fixed, we now only report unused locals defined inside reachable code.