FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
java.lang.reflect.Parameter.getAnnotations() fails for inner classes with
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at java.lang.reflect.Parameter.getDeclaredAnnotations(Parameter.java:300)
at java.lang.reflect.Parameter.getAnnotations(Parameter.java:328)
at Err.main(Err.java:30)
Looks like a deeper bug in how annotations on inner classes are handled since:
System.out.println(p.getDeclaringExecutable().getParameterTypes().length);
returns 2
but System.out.println(p.getDeclaringExecutable().getParameterAnnotations().length);
returns 1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public class Err {
public static void main(String[] args) {
Parameter p = E.class.getConstructors()[0].getParameters()[1];
p.getAnnotations();
}
@Retention(RetentionPolicy.RUNTIME)
public @interface Ann {}
public class E {
public E(@Ann Object o) {}
}
}
REPRODUCIBILITY :
This bug can be reproduced always.