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.

Case03.aj 549B

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