cafejojo/schaapi

JimpleNode equals method checks only for structural equivalence

Closed this issue · 1 comments

This means that the equals method also returns true on two statements that have different references but the same structure. In some cases this is desirable, but in others (such as the DFSIterator, as described in #110) this can cause issues. We should refactor the functionality of this equals method to a separate method.

Could we make a list of which classes use either functionality? (Please tell me if I forgot something.)

  • DsfIterator uses referential equality (explicitly) and referential hashcodes (implicitly in a HashSet).
  • jimple.GeneralizedNodeComparator uses structural equality (explicitly).
  • DotGraphRenderer uses referential hashcodes (implicitly in a HashSet).
  • FrequentSequenceFinder uses structural equality (explicitly) and structural hashcodes (implicitly in a HashSet).

It looks like most users expect the equality to be referential, which I suppose makes sense.

The only real conflict is between DfsIterator and FrequentSequenceFinder, which implicitly expect a different kind of hashcode. A solution would be to use a HashMap that uses a custom hashing function. I'm sure there exists a library that does that for us.

What do you think?