aspect CodeGen { public void JPITypeDecl.jimplify1phase1(){ if(!registerJPIWithoutAdvice().isEmpty()){ registerDummyAspect(); } } public void JPITypeDecl.jimplify1phase2() { if (jpiWithoutAdvice.contains(this)){ Collection localExhibitDecls = getExhibitDecls(); if(!localExhibitDecls.isEmpty()){ registerDummyAdviceDecl(); } jpiWithoutAdvice.remove(this); } } public static void JPITypeDecl.registerDummyAspect(){ if (abc.ja.jpi.weaving.DummyAspect.createDummyAspect("$dummyAspect$")){ globalAspectInfo().addWeavableClass(abc.ja.jpi.weaving.DummyAspect.getDummyAspectAbcClass()); globalAspectInfo().addAspect(abc.ja.jpi.weaving.DummyAspect.getDummyAspect()); } } public static Aspect JPITypeDecl.getDummyAspect(){ return abc.ja.jpi.weaving.DummyAspect.getDummyAspect(); } public static SootClass JPITypeDecl.getSootClassDummyAspect(){ return abc.ja.jpi.weaving.DummyAspect.getDummyAspectSootClass(); } protected static Collection JPITypeDecl.jpiWithoutAdvice = null; public static void JPITypeDecl.reset(){ jpiWithoutAdvice = null; } public Collection JPITypeDecl.registerJPIWithoutAdvice(){ if(jpiWithoutAdvice == null){ jpiWithoutAdvice = getJPIWithoutAdviceDeclaration(); } return jpiWithoutAdvice; } public int JPITypeDecl.getAdviceNumParameter(){ return adviceParameterList.getNumChild(); } public ParameterDeclaration JPITypeDecl.getAdviceParameter(int i){ return adviceParameterList.getChild(i); } protected List JPITypeDecl.adviceParameterList = null; @SuppressWarnings({ "unchecked", "rawtypes", "unused" }) public void JPITypeDecl.registerDummyAdviceDecl(){ adviceParameterList = getParameterList(); Pointcut pointcut = abc.ja.jpi.utils.PointcutCombination.synthesizedPointcutsFromJPIWithoutAdviceDecl(getExhibitDecls(), adviceParameterList, pos()); doRegisterDummyAdviceDecl(pointcut); } public void JPITypeDecl.doRegisterDummyAdviceDecl(Pointcut pointcut){ Value returnValue = null; TypeAccess returnType = (TypeAccess)getTypeAccess(); if(!returnType.type().isPrimitiveType()){ returnValue = soot.jimple.NullConstant.v(); } else{ if (!returnType.type().isVoid()){ returnValue = IntegerLiteral.emitConstant(Constant.create(0)); } } abc.ja.jpi.weaving.DummyAdvice.createDummyAroundAdvice(1, adviceParameterList, returnType.type().getSootType(), getExceptionList()); int[] jp_params = abc.ja.jpi.weaving.DummyAdvice.implicitParameters(adviceParameterList); Pointcut pc = pointcut; LinkedList methods = new LinkedList(); //getBlock().addAllEnclosedMethodSigs(methods); //TypeAccess jpiAccess = new TypeAccess(this.name()); //jpiAccess.setParent(this); globalAspectInfo().addAdviceDecl(new abc.ja.jpi.weaving.CJPAdviceDecl( abc.ja.jpi.weaving.DummyAdvice.adviceSpec(returnType.type().getSootType(), adviceParameterList, this), pc, abc.ja.jpi.weaving.DummyAdvice.methodSig(returnType.type().getSootType(), adviceParameterList), abc.ja.jpi.weaving.DummyAspect.getDummyAspect(), jp_params[0] /*jp*/, jp_params[1] /*jpsp*/, jp_params[2] /*ejp*/, methods, pos(), this )); //jimplify1phase2 adviceSpec abc.ja.jpi.weaving.DummyAspect.getDummyAspectSootClass().addMethod(abc.ja.jpi.weaving.DummyAdvice.createProceedMethod(adviceParameterList)); abc.ja.jpi.weaving.DummyAdvice.jimplify2(adviceParameterList,returnType.type(),returnValue); } refine CodeGenCJP eq CJPPointcutExpr.pointcut() { Pointcut cjpPointcut = CodeGenCJP.CJPPointcutExpr.pointcut(); TypeAccess jpiAccess = (TypeAccess)getJPIAccess(); JPITypeDecl jpiTypeDecl; if (!jpiAccess.type().isJPITypeDecl()){ return null; } jpiTypeDecl = (JPITypeDecl)jpiAccess.type(); return synthesizedPointcut(jpiTypeDecl, cjpPointcut); } public Pointcut CJPPointcutExpr.synthesizedPointcut(JPITypeDecl jpiTypeDecl, Pointcut cjpPointcut){ Pointcut pointcutPolymorphism, pointcutOverriden; CJPAdviceDecl currentAdvice = (CJPAdviceDecl)getCurrentAdvice(); Collection exhibitsDecls = getAllExhibitDecls(); Collection cjpAdviceDecls = getCJPAdviceDecls(); cjpAdviceDecls.remove(currentAdvice); pointcutPolymorphism = abc.ja.jpi.utils.PointcutCombination.combinePointcutsPolymorphism(currentAdvice, exhibitsDecls); //include pointcut to match on closure joinpoints pointcutPolymorphism = OrPointcut.construct(cjpPointcut, pointcutPolymorphism, pos()); pointcutOverriden = abc.ja.jpi.utils.PointcutCombination.combinePointcutsOverriden(currentAdvice, cjpAdviceDecls, exhibitsDecls); return AndPointcut.construct(pointcutPolymorphism, NotPointcut.construct(pointcutOverriden, pos()), pos()); } }