[Soot-list] hashCode() generates different values

Eric Bodden eric.bodden at mail.mcgill.ca
Mon Mar 31 03:10:18 EDT 2008


> Thank you Eric. The difference between the two passes was I called
>  loadClassAndSupport to load some other additional classes at the second
>  pass. I dont know why that made the hashcode different.

That does not make much sense. This should normally not change any
method body nor hash codes in it. Can you email us your driver code?

>  The reason I want to identify units is I'm putting units and my analysis
>  result into a database, therefore I need a id (primary key) for units.
>
>  Now I generate a pseudo id with a index of the unit in the unit chain and
>  its defining method's equivHashCode().

Beware that the hash code hast be by no means unique, i.e. you can get
different codes for different units. Better generate your own keys for
such purposes...

>  BTW, the implementation of equivHashCode, returnType.hashCode() * 101 +
>  modifiers * 17 + name.hashCode(), sometimes return the same value for
>  different methods because the name.hashCode() is only the hashcode of the
>  simple name String. I think it's better to combine the name with its
>  defining class.

I think the problem is that a unit has no knowledge about the method
that it is in (and it shouldn't).


Eric


-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


More information about the Soot-list mailing list