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.

OnOffITD.java 791B

1234567891011121314151617181920212223242526272829303132
  1. import java.lang.annotation.*;
  2. @Retention(RetentionPolicy.RUNTIME)
  3. @interface Anno {}
  4. aspect Foo {
  5. // one way round
  6. declare @field: * OnOffITD.field: -@Anno;
  7. declare @field: * OnOffITD.field: @Anno;
  8. // the other way round
  9. declare @field: * OnOffITD.field2: @Anno;
  10. declare @field: * OnOffITD.field2: -@Anno;
  11. }
  12. aspect B {
  13. public static int OnOffITD.field;
  14. public int OnOffITD.field2;
  15. }
  16. public class OnOffITD {
  17. public static void main(String[]argv) throws Exception {
  18. Object o = OnOffITD.class.getDeclaredField("field").getAnnotation(Anno.class);
  19. System.out.println("field annotated? "+(o==null?"no":"yes"));
  20. o = OnOffITD.class.getDeclaredField("field2").getAnnotation(Anno.class);
  21. System.out.println("field2 annotated? "+(o==null?"no":"yes"));
  22. }
  23. }