title: Will java compiler optimize static functions which are conditionalized based on static variable?
body: <p>For an android application, I am using a logging function which looks like this -</p>
  
  <pre><code>public static void logData(String str) {
    if (BuildConfig.DEBUG) Log.d("MYTAG", str);
  }
  </code></pre>
  
  <p>Here, <code>BuildConfig.DEBUG</code> is a static variable which sets to true when compiling the code for debug mode and to false while compiling for release.</p>
  
  <p>I know if I use <code>if(BuildConfig.DEBUG) Log.d("MYTAG", msg);</code> anywhere in my code directly, the compiler would optimize and strip the call completely in release mode.</p>
  
  <p>I would like to know if a function like logData which depends entirely on a single static variable would also get optimized and it's calls removed completely by the compiler. Or would the compiler only make logData to be an empty function and keep all the calls?</p>