You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Case02.aj 598B

12345678910111213141516171819202122232425
  1. //"public method on the aspect that declares @method on it"
  2. import java.lang.annotation.*;
  3. import java.lang.reflect.Method;
  4. @Retention(RetentionPolicy.RUNTIME)
  5. @interface anInterface{}
  6. aspect B02 {
  7. public void a(){}
  8. declare @method : void B02.a(..) : @anInterface;
  9. public static void main(String [] args){
  10. Class c = B02.class;
  11. try {
  12. Method m = c.getDeclaredMethod("a", new Class [0]);
  13. Annotation [] anns = m.getDeclaredAnnotations();
  14. for (int i = 0;i < anns.length;i++){
  15. System.out.println(anns[i]);
  16. }
  17. } catch (Exception e){
  18. System.out.println("exceptional!");
  19. }
  20. }
  21. }