aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs163/pr128664/Bug2.java
blob: eb6878f2066616fd20b629f1bf90dc1573b64eef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.lang.annotation.*;

public class Bug2 {
    public static void main(String[] args) {		
        MonitorMyAnnotationExecution.aspectOf().executionCount = 0;
        new ClassImplementingSubInterfaceWithInheritedAnnotation();
        if (MonitorMyAnnotationExecution.aspectOf().executionCount!=1) {
        	throw new RuntimeException();
        }
    }
}

@Retention(RetentionPolicy.RUNTIME)
@Inherited
@interface InheritedAnnotation { }

@InheritedAnnotation
interface InterfaceWithInheritedAnnotation { }

interface SubInterfaceOfInterfaceWithInheritedAnnotation extends InterfaceWithInheritedAnnotation {}

class ClassImplementingSubInterfaceWithInheritedAnnotation implements SubInterfaceOfInterfaceWithInheritedAnnotation { }

aspect MonitorMyAnnotationExecution {
        int executionCount;

        before() : execution((@InheritedAnnotation *)+.new(..)) && !within(Monitor*) && !within(Bug2) {
                executionCount++;
        }
}