title: Correctly override Grandparent method, already implemented in Parent method
body: <p>Edit: It appears that my problem is coming from somewhere else entirely. If you haven't read the rest of this topic yet, I have a <code>class A</code>, a <code>class B</code> extending <code>class A</code>, and a <code>class BDecorator</code> extending <code>class B</code>.
  I thought I couldn't override a specific function from <code>class B</code> within my decorator, but after days of testing and trials it seems my issue lies with the way I am creating threads.
  <code>class A</code> implements Runnable, and has a function <code>listen()</code> creating the thread and calling <code>start()</code>.
  I create the thread with the argument <code>this</code>. This is important because at the specific time the thread is created, <code>this</code> will be of type <code>class B</code>.</p>
  <pre class="lang-java prettyprint-override"><code>new BDecorator(new B());
  //             ^ The thread is created with the creation of this object, before it can be passed as an argument to BDecorator
  </code></pre>
  <p>Since the thread is of <code>class B</code>, it will call the <code>foo()</code> of the <code>B object</code> used for creating it.</p>
  <p>While I wouldn't say that this issue is solved, it is now an entirely different problem and has nothing to do with polymorphism. Thank you
  @akuzminykh, @dreamcrash and @Itay Dumay for helping me try solving this issue, as well as correctly formatting this post.</p>
  <hr />
  <p>I have an abstract <code>class A</code>, implementing Runnable. <code>A</code> does the following in the <code>run()</code> method (shortened):</p>
  <pre class="lang-java prettyprint-override"><code>final public void run() {
      try {
          this.foo(message);
      }
      //...
  }
  </code></pre>
  <p><code>Class A</code> also has the following function:</p>
  <pre class="lang-java prettyprint-override"><code>protected abstract void foo(String message);
  </code></pre>
  <p><strong>First iteration of the decorator: Overriding the foo function.</strong></p>
  <p>I have then created a class B, which isn't abstract, doing this:</p>
  <pre class="lang-java prettyprint-override"><code>public class B extends A {
      // Constructors and getters/setters go here
      
      protected void foo(String message) {
          System.out.println(message);
      }
  }
  </code></pre>
  <p>This code works fine. I have since decided to add functionalities to <code>B</code> that wouldn't change the way the whole app works, by creating a decorator.</p>
  <pre class="lang-java prettyprint-override"><code>public class BDecorator extends B {
      B decoratedB;
      
      public BDecorator(B b) {
          this.decoratedB = b;
      }
      
      @Override
      protected void foo(String message) {
          this.decoratedB.foo(&quot;Testing a foo decorator: &quot; + message);
      }
  }
  </code></pre>
  <p>To make things short, I'm trying to override a method from a parent, that was already implementing said method from their own parent (grandchild overring method from parent, implementing method from grandparent).</p>
  <p><strong>Second iteration of the decorator: Overriding a new bar function created in <code>B</code>.</strong></p>
  <p>What's weird is that I also have a method written in <code>B</code> like so:</p>
  <pre class="lang-java prettyprint-override"><code>public class B extends A {
      // Constructors and getters/setters go here
  
      protected void foo(String message) {
          System.out.println(message);
      }
  
      protected void bar(String message) {
        System.out.println(message);
      }
  }
  </code></pre>
  <p><code>bar</code> doesn't exist anywhere in <code>class A</code>.
  I can confirm that the program will actually call <code>BDecorator::bar()</code> with the following override (when I place breakpoints):</p>
  <pre class="lang-java prettyprint-override"><code>public class BDecorator extends B {
      B decoratedB;
      
      public BDecorator(B b) {
          this.decoratedB = b;
      }
      
      @Override
      protected void foo(String message) {
          this.decoratedB.foo(&quot;Testing a foo decorator: &quot; + message);
      }
  
      // This method wasn't in A. It was only present in B, and for some reasons it gets called.
      @Override
      protected void bar(String message) {
          this.decoratedB.bar(&quot;Testing a bar decorator: &quot; + message);
      }
  }
  </code></pre>
  <p>Here's what happens in my main:</p>
  <pre class="lang-java prettyprint-override"><code>B firstTestSubject = new BDecorator(new B(...));
  BDecorator secondTestSubject = new BDecorator(new B(...));
  
  // Let's test both foo functions
  firstTestSubject.foo(&quot;Hello world!&quot;);
  secondTestSubject.foo(&quot;Hello world!&quot;);
  
  // Now let's test both bar functions
  firstTestSubject.bar(&quot;Goodbye world!&quot;);
  secondTestSubject.bar(&quot;Goodbye world!)&quot;;
  </code></pre>
  <p>Output:</p>
  <pre><code>&gt; Hello world!
  &gt; Hello world!
  &gt; Testing a bar decorator: Goodbye world!
  &gt; Testing a bar decorator: Goodbye world!
  </code></pre>
  <p>The question is: Why is the <code>foo override</code> from <code>BDecorator</code> never called?</p>