[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Around advice and return type

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() {};

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.