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.

Bug2.java 959B

123456789101112131415161718192021222324252627282930
  1. import java.lang.annotation.*;
  2. public class Bug2 {
  3. public static void main(String[] args) {
  4. MonitorMyAnnotationExecution.aspectOf().executionCount = 0;
  5. new ClassImplementingSubInterfaceWithInheritedAnnotation();
  6. if (MonitorMyAnnotationExecution.aspectOf().executionCount!=1) {
  7. throw new RuntimeException();
  8. }
  9. }
  10. }
  11. @Retention(RetentionPolicy.RUNTIME)
  12. @Inherited
  13. @interface InheritedAnnotation { }
  14. @InheritedAnnotation
  15. interface InterfaceWithInheritedAnnotation { }
  16. interface SubInterfaceOfInterfaceWithInheritedAnnotation extends InterfaceWithInheritedAnnotation {}
  17. class ClassImplementingSubInterfaceWithInheritedAnnotation implements SubInterfaceOfInterfaceWithInheritedAnnotation { }
  18. aspect MonitorMyAnnotationExecution {
  19. int executionCount;
  20. before() : execution((@InheritedAnnotation *)+.new(..)) && !within(Monitor*) && !within(Bug2) {
  21. executionCount++;
  22. }
  23. }