[Soot-list] NaiveSideEffectTester

Navindra Umanee navindra at cs.mcgill.ca
Mon Nov 8 10:34:15 EST 2004


Hi Phung,

This makes me wonder what "side-effect" means in this context.

>From The Free On-line Dictionary of Computing, I get:

          A language construct that modifies the state of the system.
          The most common side-effects are {assignment}, input and
          output.  A language without side-effects is
          {purely-functional} - execution consists of the evaluation of
          an expression and all subexpressions are {referentially
          transparent}.

Now, it's certainly possible for an invoke expression to modify the
state of a final field, right?  Doesn't that count as a side-effect,
or are you only considering whole re-assignments to the field?

Maybe your code should check that the field is holding a primitive
type?

public class SideEffectTest
{
        static final SideEffectTest set = new SideEffectTest();

        public static void main(String[] args)
        {
                set.hashCode = 10;
        }

        public int hashCode = 5;

        public int hashCode()
        {
                return hashCode;
        }

        public boolean equals(Object o)
        {
                return (hashCode == o.hashCode());
        }
}

Cheers,
Navin.

Phung Hua Nguyen <nhp at cse.unsw.edu.au> wrote:
> I think NaiveSideEffectTester is a simple and cheap side effect tester but 
> it is so weak. I think we can improve the effect of the tester but still 
> keep it cheap by exploiting the final property of fields.
> 
> Particlarly, we can change:
> 
> if (s.containsInvokeExpr()) {
>  	if (!(v instnaceof Local))
>  	return true;
> }
> 
> into
> 
> if (s.containsInvokeExpr()) {
>  	if (!(v instanceof Local ||
>  	     ((v instanceof FieldRef) && ((FieldRef)v).getField().isFinal()))
>  	return true;
> }
> 
> Am I correct ? I think it can improve significantly the effect of 
> NaiveSideEffectTester.
> 
> 
> Nguyen Hua Phung
> University of New South Wales
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://www.sable.mcgill.ca/mailman/listinfo/soot-list


More information about the Soot-list mailing list