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.

Case23.aj 570B

1234567891011121314151617181920212223242526272829
  1. // "public field with declare @field"
  2. import java.lang.annotation.*;
  3. import java.lang.reflect.Field;
  4. @Retention(RetentionPolicy.RUNTIME)
  5. @interface anInterface{}
  6. class A23 {
  7. public int a;
  8. }
  9. aspect B23 {
  10. declare @field : int A23.a : @anInterface;
  11. public static void main(String [] args){
  12. Class c = A23.class;
  13. try {
  14. Field m = c.getDeclaredField("a");
  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. }