title: What will go wrong when superclass does not redeclare equals() and hashCode()?
body: <p>Suppose there are two classes like this:</p>
  
  <pre><code>abstract class A { /* some irrelevant methods */ }
  
  class B extends A {
      public final int x;
  
      public B(final int x) {
          this.x = x;
      }
  
      /* some more irrelevant methods */
  }
  </code></pre>
  
  <p>Then I generate the <code>equals()</code> and <code>hashCode()</code> methods on class <code>B</code> using Eclipse's "Source → Generate hashCode() and equals()...". But Eclipse warns me that:</p>
  
  <blockquote>
    <p>The super class 'com.example.test2.A' does not redeclare equals() and hashCode() - the resulting code may not work correctly.</p>
  </blockquote>
  
  <p>So, <strong>what will make the resulting code not working correctly with the generated methods?</strong> </p>
  
  <hr>
  
  <p>(BTW, the generated methods look like this:</p>
  
  <pre><code>@Override
  public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result + x;
      return result;
  }
  
  @Override
  public boolean equals(Object obj) {
      if (this == obj)
          return true;
      if (obj == null)
          return false;
      if (getClass() != obj.getClass())
          return false;
      B other = (B) obj;
      if (x != other.x)
          return false;
      return true;
  }
  </code></pre>
  
  <p>)</p>