[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Inconsistent Handling for args when null

Hi All,

We just ran into a case where AspectJ (both 1.2.1 and CVS HEAD) is
inconsistent in how it handles args on a field setter where there's a null
value. I believe args should *not* match if you set a value to null (also a
possible surprise/gotcha, but consistent with instanceof semantics).

The following test program fairly shows inconsistent behavior in my mind.
The output from this program is
around set firing for null at set(Map InstanceOfArgs.val)

I.e., just the one set to null matches, not the version that gets set
through a method call nor the version that is set on a field that isn't
statically determinable to be of type Map. I believe this program should
produce *no* output. I'd like to flag this for some discussion before
submitting to bugzilla.

import java.util.*;

public aspect InstanceOfArgs {
    private static Map val;
    private static Object pval;

    public static void main(String args[]) {
	setVal(null);
	val = null; // MATCHES!
	pval = null;
    }

    public static void setVal(Object val) {
        val = (Map)val;
    }

    void around(Map map) : set(* *.*) && args(map) {
	System.out.println("around set firing for "+map+" at
"+thisJoinPoint);
	proceed(new HashMap());
    }

    void around(Map map) : call(* setVal(*)) && args(map) {
	System.out.println("around call firing for "+map+" at
"+thisJoinPoint);
	proceed(new HashMap());
    }

}

Ron Bodkin
Chief Technology Officer
New Aspects of Software
w: (415) 824-4690