package aspects; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import classe.C; // Les deux implémentations marchent. public aspect A { static final int MAX = 1000; before(int x, C c): call(void C.incI(int)) && target(c) && args(x) { System.out.println("Before"); if (c.i + x > MAX) throw new RuntimeException(); } } /* @Aspect public class A { private static final int MAX = 1000; @Around("execution(void C.incI(int)) && args(x)") // AutourDeCoupureIncI renvoie le même type que C.incI. public void AutourDeCoupureIncI(ProceedingJoinPoint joinPoint, int x) throws Throwable { System.out.println("début"); if (((C) joinPoint.getTarget()).i + x > MAX) throw new RuntimeException(); joinPoint.proceed(new Object[] { x }); System.out.println("Fin"); } } */