title: Unable to override static final variable of a final class using PowerMock
body: <p>I'm trying to use PowerMock Whitebox setInternalState api to override a static final variable of a final class. But it doesn't seems to be working. Please see sample code below:</p>
  
  <p><strong>A final class with static final variable:</strong></p>
  
  <pre><code>public final class BuildConfig {
      public static final String BUILD_TYPE = "debug";
  }
  </code></pre>
  
  <p><strong>A helper class to return the above variable:</strong></p>
  
  <pre><code>public class BuildConfigHelperClass {
      public String getBuildType() {
          return BuildConfig.BUILD_TYPE;
      }
  }
  </code></pre>
  
  <p><strong>Test class</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.powermock.core.classloader.annotations.PrepareForTest;
  import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
  import org.powermock.modules.junit4.PowerMockRunner;
  import org.powermock.reflect.Whitebox;
  
  import static org.junit.Assert.*;
  import static org.powermock.api.mockito.PowerMockito.mockStatic;
  
  @RunWith(PowerMockRunner.class)
  @SuppressStaticInitializationFor("BuildConfig")
  @PrepareForTest({BuildConfigHelperClassTest.class, BuildConfigHelperClass.class, BuildConfig.class})
  public class BuildConfigHelperClassTest {
  
      private BuildConfigHelperClass subject;
  
      @Before
      public void setUp() {
          subject = new BuildConfigHelperClass();
      }
  
      @Test
      public void shouldReturnDebugBuildType() {
          assertEquals("debug", subject.getBuildType());
      }
  
      @Test
      public void shouldReturnProductionBuildType() {
          mockStatic(BuildConfig.class);
          Whitebox.setInternalState(BuildConfig.class, "BUILD_TYPE", "production");
          assertEquals("production", subject.getBuildType());
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>In above test class, for second test <code>subject.getBuildType()</code> method should return "production" as I am overriding it through Whitebox, but it always fails because of return value i.e. "debug". </p>
  
  <p>Can anyone please guide me on what I'm missing. </p>