summaryrefslogtreecommitdiffstats
path: root/tests/bugs163/pr256669/Four.java
blob: 5d2a6747afe9efd40b934830f8e6043e866f8a88 (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
34
35
36
37
38
39
40
import java.lang.reflect.*;
import java.lang.annotation.*;


interface I {}

class D implements I {}

aspect Introduction {
  // ITD onto interface
  public String I.helloWorld( @SomeAnnotation("xyz") String who) {
    return "Hello " + who;
  }
}

public class Four {
  public static void main(String[] argv) throws Exception {
    Class<D> clazz = D.class;
    Method m = clazz.getMethod("helloWorld", String.class);
    Annotation[] ann = m.getAnnotations();
    for (int i = 0; i < m.getParameterAnnotations().length; i++) {
      int count = m.getParameterAnnotations()[i].length;
      System.out.println("Class D parameter " + i + " has " + count + " parameter annotations");
    }
    Class<I> clazzI = I.class;
    m = clazzI.getMethod("helloWorld", String.class);
    ann = m.getAnnotations();
    for (int i = 0; i < m.getParameterAnnotations().length; i++) {
      int count = m.getParameterAnnotations()[i].length;
      System.out.println("Interface I parameter " + i + " has " + count + " parameter annotations");
    }

  }
}

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@interface SomeAnnotation {
        String value() default "";
}