This topic has not yet been written. The content below is from the topic description.
Around Advices When using an annotated-parameter signature, around advices are obliged to return a value. This is pretty much the same as with the default signature. However, here it must return a value with the same type as the joinpoint return value, or a subtype. Notice that, if the joinpoint return type is void, the around advice should be void too. To illustrate all this, let's look at the around advices contained in this example, by starting with this one: public int aroundAnnotatedParam(@JoinPoint MethodInvocation invocation) throws Throwable { ... return 5000; } Aspect.aroundAnnotatedParam() advice overwrites the method return value with the 5000 int value. This advice intercepts a method that returns an int value, and has the same return type as it. On the other hand, Aspect.aroundArrayList() does not return the same type of the joinpoint it intercepts. It returns a subtype instead: public ArrayList aroundArrayList(@JoinPoint MethodInvocation invocation) throws Throwable { ... } This advice intercepts a method whose return type is java.util.List and, so, its return type is valid. It wouldn't be valid if it was a superclass of java.util.List, like java.util.Collection. This avoids the advice returning a java.util.Vector, for example, when the joinpoint return value is expected to be of type java.util.List. Finally, take a look at aroundVoid: public void aroundVoid(@JoinPoint MethodInvocation invocation) throws Throwable { ... } This advice is void and can be applied only to joinpoints that don't return values. This is the case of void POJO.doNothing() method execution, and it would also be the case of a void method call, or a field read/write joinpoint.