Community
Participate
Working Groups
In the AspectJ Programming guide, Appendix B: Language Semantics: Advice: http://dev.eclipse.org/viewcvs/indextech. cgi/~checkout~/aspectj-home/doc/progguide/semantics-advice.html quote: "A piece of around advice may be declared void, in which case it is not allowed to return a value, and instead whatever value the join point returned will be returned by the around advice (unless the around advice throws an exception of its own)." Yet this does not seem to work: public class AroundSample { public static void main(String[] args) { AroundSample s = new AroundSample(); int x = s.aMethod(); } public int aMethod() { System.out.println("Hello"); return 0; } } aspect AroundSampleAspect { pointcut sampleOperations(): call(* AroundSample.*(..)); void around(): sampleOperations() { System.out.println("before " + thisJoinPointStaticPart); proceed(); System.out.println("after " + thisJoinPointStaticPart); } } It results in compilation error: > ajc -Xlint -d classes src/testipaketti/AroundSample.java /home/akaranta/workspace/aspektitesti/src/testipaketti/AroundSample.java:21 applying to join point that doesn't return void: method-call(int testipaketti. AroundSample.aMethod()) /home/akaranta/workspace/aspektitesti/src/testipaketti/AroundSample.java:7 applying to join point that doesn't return void: method-call(int testipaketti. AroundSample.aMethod()) 2 errors So either the compiler or the documentation is wrong, my guess is the documentation in this case.
Fixed in docs tree and on website. This was a hang-over from a very early release of AspectJ, and has been lurking in the docs ever since.
*** Bug 63177 has been marked as a duplicate of this bug. ***
Fix released as part of AspectJ 1.2.1