title: When a SubClass which is a spring bean calls method of SuperClass which is also a spring bean, the autowired field in SuperClass is null
body: <p>I have a SuperClass.</p>
  
  <pre><code>@Component
  public class SuperClass {
      private TestBeanSuper testBeanSuper;
  
      public SuperClass(){}
  
      @Autowired
      public SuperClass(TestBeanSuper testBeanSuper) {
          this.testBeanSuper = testBeanSuper;
      }
  
      public void test() {
          testBeanSuper.test();
      }
  }
  </code></pre>
  
  <p>a SubClass.</p>
  
  <pre><code>@Component
  public class SubClass extends SuperClass{
      private TestBeanSub testBeanSub;
  
      public SubClass(){}
  
      @Autowired
      public SubClass(TestBeanSub testBeanSub) {
          this.testBeanSub = testBeanSub;
      }
  
      public void test() {
          super.test();
      }
  }
  </code></pre>
  
  <p>When I call subClass.test(), NullPointerException occurred.
  The testBeanSuper in SuperClass test method is null.</p>
  
  <pre><code>java.lang.NullPointerException: null
      at com.spring.demo.SuperClass.test(SuperClass.java:18) ~[classes/:na]
      at com.spring.demo.SubClass.test(SubClass.java:18) ~[classes/:na]
      at com.spring.demo.TestController.test(TestController.java:19) ~[classes/:na]
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/oSr1P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oSr1P.png" alt="enter image description here"></a></p>
  
  <p>Could someone tell me why this happened?</p>
  
  <p>And when I debugged, I found that testBeanSuper is inside the SubClass instance. The testBeanSuper is defined as private in SuperClass, why it is inside the SubClass instance?
  <a href="https://i.stack.imgur.com/7M0VI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7M0VI.png" alt="enter image description here"></a></p>