Community
Participate
Working Groups
The following code results in a warning that "the local variable i is never used." Since DEBUG is a final variable set to false, the variable i will never be hit, however, this is only part of the truth which is that none of the code inside the if statement will be run. If we're going to be this smart about detecting when code won't be run, we need to give the whole truth. I suggest that in this case we should either give no warning or give a warning that the code in the if statement is unreachable. public class Foo { private static final boolean DEBUG= false; public void foo() { if (DEBUG) { for (int i= 0; i < 10; i++) { // Warning appears here System.out.println(new Integer(i)); } } } }
Thought these intempestive warnings were already disabled. Need to investigate
Was testing the IsReachableMASK bit, which is always set to true by default, and cleared on non reachable statements. Nested nodes aren't set correctly, and are supposed to be tested (code gen will not investigate unreachable statement subnodes). Fixed by using a distinct bit for LocalDeclaration reachability.