title: How to extend a final class in Java
body: <p>Here is my problem actually I'm facing now. 
  I have a class, let's say <code>Foo</code> and this class defines a method called <code>getBar</code> that returns a <code>Bar</code> instance. The class <code>Bar</code> is defined inside <code>Foo</code> and and is declared <code>public static final</code>. What I want to do is to define a class <code>MyFoo</code> that extends <code>Foo</code> but I also want to extend <code>Bar</code> with <code>MyBar</code> by adding my own functionalities (methods, properties,etc). 
  I also want <code>getBar</code> to return <code>MyBar</code>.</p>
  
  <p>The problem is <code>Bar</code> is final. Here is an illustration of what I want to do :</p>
  
  <pre><code>public class Foo {
  
    Bar bar = new Bar();
  
    public Bar getBar(){
        return bar;
    } 
  
     ....
  
     public static final class Bar {
  
      } 
  }
  </code></pre>
  
  <p>What I want to do is :</p>
  
  <pre><code>public class MyFoo extends Foo {
  
  
     public MyBar getBar(){ // here I want to return an instance of MyBar
  
     }
  
    public static final class MyBar extends Bar { // That's impossible since Bar is final
  
    } 
  }
  </code></pre>
  
  <p>How can I achieve that?</p>
  
  <p>[EDIT] I am adding more details to my question. 
  I am actually developing a plugin for Jenkins and after searching, I realize there is a plugin that offers the base functionalities that I want to do, <code>Foo</code> and <code>Bar</code>. I want to custom <code>Foo</code> and <code>Bar</code>,  so it can fits my needs. 
  Foo is the main class of the plugin and extends a class called Builder. Foo defines a method called <code>perform</code> which contains all the operations for performing a build. 
  <code>Bar</code> contains operations for configurations purposes and Foo needs Bar to get those informations. </p>
  
  <p>So what I want to do is to extend Foo with <code>MyFoo</code> and add some configurations with <code>MyBar</code>. And as you see, <code>MyFoo</code> will need to get those configuations by calling <code>getBar();</code></p>
  
  <p>The second thing is I have no control of the instanciation of <code>MyFoo</code> and <code>MyBar</code></p>
  
  <p>What blocks me, is that I cannot extend Bar. How can I achieve that? </p>