2

I'm writing a Java class that extends AbstractList because it has a lot of methods I want to inherit.

It has two methods I don't want to inherit: equals and hashCode. I would like to just call the default Object versions of those.

The syntax for calling an inherited method is e.g. super.hashCode() but that would just get the AbstractList version. What's the syntax for skipping over that and calling the grandfather version? Object.hashCode() doesn't work.

rwallace
  • 31,405
  • 40
  • 123
  • 242
  • Possible duplicate of [Why is super.super.method(); not allowed in Java?](https://stackoverflow.com/questions/586363/why-is-super-super-method-not-allowed-in-java) – pirho Nov 15 '18 at 19:46

1 Answers1

4

There isn't a way to access grandfather method implementations. On the other hand, you can use System.identityHashCode(this) and this == o to get the object-based equality behavior.

(Note, however, that it violates the List contract to use identity-based hash codes or equality for any type that implements the List interface.)

Louis Wasserman
  • 191,574
  • 25
  • 345
  • 413