Summary: | @AdviceName is ignored in Aspect | ||
---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Karsten Becker <java> |
Component: | Compiler | Assignee: | aspectj inbox <aspectj-inbox> |
Status: | NEW --- | QA Contact: | |
Severity: | enhancement | ||
Priority: | P5 | CC: | aclement |
Version: | unspecified | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Karsten Becker
2006-08-16 11:04:14 EDT
clarify for 1.5.3 The javadoc for @AdviceName is: "Used to annotated code-style advice to name it Name is used by reflection api if present, may in future be used in adviceexecution() pcd. It is an error to use the @AdviceName annotation on an annotation-style advice declaration." (http://www.eclipse.org/aspectj/doc/released/aspectj5rt-api/org/aspectj/lang/annotation/AdviceName.html) Does that mean it is simply not implemented yet? What would be the purpose of this annotation other then defining it on an Aspect Advice. As the javadoc says (perhaps not too clearly...), the purpose of this annotation is to provide a name for the advice when it is accessed through the AspectJ reflection mechanism. It is not used to name the method generated in the code. Here is a program that shows how to use the AspectJ reflection mechanism: import org.aspectj.lang.annotation.AdviceName; import org.aspectj.lang.reflect.Advice; import org.aspectj.lang.reflect.AdviceKind; import org.aspectj.lang.reflect.AjType; import org.aspectj.lang.reflect.AjTypeSystem; public class C { public static void main(String[] args) { AjType t = AjTypeSystem.getAjType(MyAspect.class); Advice[] advice = t.getAdvice(); for (int i = 0; i < advice.length; i++) { Advice advice2 = advice[i]; System.err.println("Advice: ["+advice2+"] name="+advice2.getName()); } } } aspect MyAspect { before(): execution(* F*(..)) { } @AdviceName("AndysAdvice") after(): execution(* F*(..)) { } } You can see 'AdviceName' has been used to name the after advice, when run this prints: Advice: [before() : execution(* F*(..))] name= Advice: [@AdviceName("AndysAdvice") after() : execution(* F*(..))] name=AndysAdvice Ahh ok. I expected that reflection would mean the usal java reflection. Because the name of an annotated advice is the same as the method name. Wouldn't it be possible to influence the method name by this annoation? It would make an annotated aspect more consistent with the aspect language. moving to possible enhancement |