SWI-Prolog / packages-jpl

JPL: The Prolog <-> Java interface
BSD 2-Clause "Simplified" License
52 stars 32 forks source link

Correct class checks in equals methods #83

Closed Venorcis closed 3 years ago

Venorcis commented 3 years ago

Fix the class comparison in all Java equals() methods in order to allow working inheritance.

Also commented out 1 line that gave a warning about being unused.

Tested working (this resolves some issues with how GOAL uses JPL).

JanWielemaker commented 3 years ago

Thanks. The implications are a bit beyond me though and I vaguely recall some earlier discussion about equality. @ssardina? @anionic?

Venorcis commented 3 years ago

Thanks. The implications are a bit beyond me though and I vaguely recall some earlier discussion about equality.

In GOAL we extend the JPL objects to add some of our own functionality (i.e. to comply with generic KR interfaces). The getClass comparisons fail on those (sub)objects, making them all non-equal. The instanceof checks work correctly on those subclasses.