[abc] tm peculiarity

From: Eric Bodden <eric.bodden@mail.mcgill.ca>
Date: Tue Oct 10 2006 - 13:51:15 BST

Hi.

I just tried to write a tracematch that captures direct calls to a collection that has been put into Collections.synchronizedCollection(..) before (as this is an error).

The code looks as follows:

//most common supertype of Map anc Collection is Object unfortunately
pointcut createSync(Object toSync):
        call(* Collections.synchr*(..)) && args(toSync);

tracematch(Object orig, Object sync) {

        sym sync after returning(sync): createSync(orig);

        sym asyncCall before: call(* *(..)) && target(orig) && !this(sync);

        sync asyncCall {
                throw new IllegalStateException("Collection "+System.identityHashCode(orig)+
                                " was synchronized. Use instance "+System.identityHashCode(sync)+" instead!");
        }

}

Here, abc complains that it cannot bind "sync" under negation in the asyncCall symbol. This is certainly true, but here we know for sure that sync is bound at that point. So is there no way to make the TM implementation recognize and correctly handle this? (J-Lo could handle it with no problems ;-)) If not, is there any easy workaround?

Eric

--
Eric Bodden
Sable Research Group, McGill University
Montréal, Québec, Canada
Received on Tue Oct 10 13:51:29 2006

This archive was generated by hypermail 2.1.8 : Tue Mar 06 2007 - 16:13:30 GMT