Below is a snippet of my code:
class A {
private boolean debug = false;
// Called when server boots up.
public void init (property) {
debug = property.getBoolean ("debug_var"); // read debug from a config file.
}
// some other function
public void foo () {
if (debug) {
System.out.println ("From inside the debug block");
}
}
}
When I run the code, if (debug) actually prints out "From inside debug block" if debug == true in the config file.
Two Questions:
So, in this case does the compiler include the if block in the .class file just because the value of variable debug might change on run time?
If this is true, then how can I eliminate some code from being added to the .class file on certain environments?