title: override java final methods via reflection or other means?
body: <p>This question arise while trying to write test cases. Foo is a class within the framework library which I dont have source access to.</p>
  
  <pre><code>public class Foo{
    public final Object getX(){
    ...
    }
  }
  </code></pre>
  
  <p>my applications will </p>
  
  <pre><code>public class Bar extends Foo{
    public int process(){
      Object value = getX();
      ...
    }
  }
  </code></pre>
  
  <p>The unit test case is unable to initalize as I can't create a Foo object due to other dependencies. The BarTest throws a null pointer as value is null. </p>
  
  <pre><code>public class BarTest extends TestCase{
    public testProcess(){
      Bar bar = new Bar();        
      int result = bar.process();
      ...
    }
  }
  </code></pre>
  
  <p>Is there a way i can use reflection api to set the getX() to non-final? or how should I go about testing? </p>