[abc-users] InterprocConstantPropagator throws IndexOutOfBoundsException when Advice does not apply

From: Thomas Pawlitzki <mailinglist_at_pawlitzki.name>
Date: Tue, 29 Apr 2008 13:54:58 +0200


I have a Problem with my compiler extension. The
InterprocConstantPropagator thorws an IndexOutOfBounceException from
the method findUsedArguments(SootMethod method) in line 229.
                private boolean[] findUsedArguments(SootMethod method) {
                        if (!method.makeRef().toString().equals(methodSig))
                                throw new InternalCompilerError("");
                        boolean[] result=new boolean[method.getParameterCount()];
                        Body body=method.getActiveBody();
                        Chain statements=body.getUnits().getNonPatchingChain();
                        Set usedLocals=new HashSet();
                        for (Iterator it=body.getUseBoxes().iterator(); it.hasNext(); ) {
                                ValueBox b=(ValueBox)it.next();
                                if (b.getValue() instanceof Local)
                        int index=0;
                        for (Iterator itSt=statements.iterator(); itSt.hasNext();) {
                                Stmt s=(Stmt)itSt.next();
                                if (s instanceof IdentityStmt) {
                                        IdentityStmt ids=(IdentityStmt)s;
                                        if (ids.getRightOp() instanceof ParameterRef) {
                                } else
                        return result;

My extension is based on the JastAdd frontend of abc-1.3.0. This
exception is always thrown when an advice does not apply anywhere.

For all advices i check in my compiler extension if they are allowed
to match to certain joinpoints. When they are not allowed to match i
change the pointcut of the advice to a never matching pointcut. When i
do this the named exception is thrown. I experienced with several
pointcut expressions and the result is:

AdviceDecl {
                        // No global Pointcut exists so create a never matching pointcut
                            ArgsPointcutExpr argsPointcut = new ArgsPointcutExpr(bindings);
                            IfPointcutExpr ifPointcut = new IfPointcutExpr(new
                            pointcutExpr = new AndPointcutExpr(argsPointcut,ifPointcut);
                            List<FormalPattern> formalPatterns = new List<FormalPattern>();
                            formalPatterns.add(new WildcardFormalPattern());
                            MethodPattern methodPattern = new MethodPattern(
                                            new List<ModifierPattern>(),
                                            new SimpleNamePattern("*"),
                                            new DotNamePattern(new ExplicitTypeNamePattern(new
TypeAccess("System")), new SimpleNamePattern("*")),
                                            new List<Pattern>()
                            pointcutExpr = new AndPointcutExpr(pointcutExpr, new

Here I simply created a pointcut : call(* System.*(..)) &&
args(<advice arguments>) && if(false)

I found out what the problem is but not how to solve it. Perhaps
someone can give me a hint.

The Problem is that when an advice which is modified by my compiler
extension is passed to the findUsedArguments method it contains only
one parameterType
but 2 IdentityStmt
[test := @parameter0: java.lang.String, thisJoinPoint := @parameter1:
org.aspectj.lang.JoinPoint, return]

So the result[boolean] has only length 1 but accessed is result[0] and

Do anyone know how to solve this problem?

Thanks in advanced?

Received on Tue Apr 29 2008 - 12:55:02 BST

This archive was generated by hypermail 2.2.0 : Tue Apr 29 2008 - 14:20:11 BST