[Soot-list] hashCode() generates different values

Alvin Yan feiya200 at cs.uregina.ca
Sun Mar 30 14:34:11 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.

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().

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.


Alvin


--------------------------------------------------
From: "Eric Bodden" <eric.bodden at mail.mcgill.ca>
Sent: Sunday, March 30, 2008 4:43 AM
To: "Alvin Yan" <feiya200 at cs.uregina.ca>
Cc: <soot-list at sable.mcgill.ca>
Subject: Re: [Soot-list] hashCode() generates different values

> Hi.
>
> Normally, Units do not implement hashCode(), which means that you get
> different hash codes because you have different Unit objects in the
> different passes.
>
> So something between your two passes is replacing units by other
> (equivalent) units. You have to figure out what's doing the
> replacement.
>
> When do you execute your 1st and 2nd pass? What's running in between?
> Why do you need to keep trac kof units anyway?
>
> Eric
>
> On 30/03/2008, Alvin Yan <feiya200 at cs.uregina.ca> wrote:
>>
>>
>> Dear all,
>>
>> I was trying to run hashCode() on Unit objects to get a "index" of the 
>> Unit
>> for further use. However when I iterating over the unit chain and 
>> printing
>> out the hashCode(), they're different at different times! How do I 
>> maintain
>> the same value every time I get the hashCode?
>>
>> For e.g. pass 1 I got
>> 10607274 r0 := @parameter0: java.lang.String[]
>> 10574362 r1 = null
>> 19045313 $r4 = new java.util.Vector
>> 8542488 specialinvoke $r4.<java.util.Vector: void <init>()>()
>> 27738150 r2 = $r4
>> 8255364 $i1 = lengthof r0
>>
>> and pass 2 I got
>> 21369517 r0 := @parameter0: java.lang.String[]
>> 23486952 r1 = null
>> 10866763 $r4 = new java.util.Vector
>> 17923496 specialinvoke $r4.<java.util.Vector: void <init>()>()
>> 22070539 r2 = $r4
>> 17530016 $i1 = lengthof r0
>>
>> The hashcodes are completely different.
>> Anyone can help me on this?
>>
>> Alvin
>> _______________________________________________
>>  Soot-list mailing list
>>  Soot-list at sable.mcgill.ca
>>  http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>
>>
>
>
> -- 
> Eric Bodden
> Sable Research Group
> McGill University, Montréal, Canada
> 


More information about the Soot-list mailing list