Hi all,

This is probably a beginner question.
In the following code snippet I would like to
catch all calls to methods that return an instance of class A
and all derived classes, do some operations on the object
and return it back.

@Pointcut("call(A+ *.*(..))")
void matchGetA() {};

@Around("matchGetA()")
public A processA(ProceedingJoinPoint thisJoinPoint) {
        try {
                A result = (A)thisJoinPoint.proceed();
                ...
                return result;
        } catch (Throwable e) {
                throw new Exception(e);
        }
}

This snippet does not compile when I have a method
public B getB() {}
and B is derived from A.

The only option I can think of is to set the return type of processA () advice to Object. Does a better (more type save) method exist to build this kind of advices.

Thanks,
Adam


_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to