Bug 53028 - Documentation claims around advice can be declared with void return value to automatically return whatever the join point returned
Summary: Documentation claims around advice can be declared with void return value to ...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Docs (show other bugs)
Version: 1.1.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.2.1   Edit
Assignee: Erik Hilsdale CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 63177 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-02-25 04:12 EST by Antti Karanta CLA
Modified: 2004-10-21 04:32 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Karanta CLA 2004-02-25 04:12:01 EST
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.
Comment 1 Adrian Colyer CLA 2004-08-06 05:17:36 EDT
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. 
Comment 2 Andrew Clement CLA 2004-08-09 06:27:22 EDT
*** Bug 63177 has been marked as a duplicate of this bug. ***
Comment 3 Adrian Colyer CLA 2004-10-21 04:32:31 EDT
Fix released as part of AspectJ 1.2.1