Class JimpleComparator

java.lang.Object
sootup.core.jimple.basic.JimpleComparator
Direct Known Subclasses:
IgnoreLocalNameComparator

public class JimpleComparator extends Object
This class contains the equivalence implementations for the individual EquivTo.equivTo(Object) methods of the Jimple IR. You can use it as your base class if your use case needs an adjustment for checking structural equivalence. This follows a contract weaker than Object.equals(Object):

X x = ...; Y y = ...; x.equivTo(y); will check whether y is an instance of X and whether the properties known to X are equal in both objects.

  • It is reflexive: for any non-null reference value x, x.equivTo(x) should return true.
  • In contrast to Object.equals(Object) it is not necessarily symmetric: Consider reference values Foo x and Bar y where class Bar extends Foo. If x.equivTo(y) returns true, it is still valid for y.equivTo(x) to return false. This is because x.equivTo(y) will only compare the properties defined in Foo. If Bar has added any other properties, it will also take these into consideration for the comparison. Since Foo does not contain them, y.equivTo(x) will return false in this case.
  • In contrast to Object.equals(Object) it is not necessarily transitive. This is because it is reflexive, but not necessarily symmetric. This means that when x.equivTo(y) == true and y.equivTo(z) == true, this does not imply x.equivTo(z) == true. A trivial example showing this is when x refers to the same object as z, since equivTo is not always symmetric.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equivTo(y) consistently return true or consistently return false, provided no information used in equivTo comparisons on the objects is modified.
  • For any non-null reference value x, x.equivTo(null) should return false.

Author:
Markus Schmidt