aboutsummaryrefslogtreecommitdiffstats
path: root/tests/multiIncremental/pr328121/base/src/TestRequirements/TestRequirements.java
blob: 3d4c29f185f38e6882fb41a8889a366ea7e0d9c6 (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
31
32
33
package TestRequirements;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;


@Retention(RetentionPolicy.RUNTIME)
@interface AnnotatedMethod {}

@Retention(RetentionPolicy.RUNTIME)
@interface NewAnnotatedMethod {
    boolean newValue();
}

aspect X {
    declare @method: !@AnnotatedMethod * TestRequirements.*(..) : @NewAnnotatedMethod(newValue = true);
}

public class TestRequirements {
    @AnnotatedMethod
    public void dontMatchMe() {}

    public void matchMe() {}

  public static void foo() throws Exception {
    if (TestRequirements.class.getDeclaredMethod("dontMatchMe").getAnnotation(NewAnnotatedMethod.class)!=null) {
      throw new IllegalStateException();
    }
    if (TestRequirements.class.getDeclaredMethod("matchMe").getAnnotation(NewAnnotatedMethod.class)==null) {
      throw new IllegalStateException();
    }
  }
}