// annotations
// so we bail out to Bcel and then chuck away the JavaClass so that we
// don't hog
// memory.
try {
JavaClass jc = bcelRepository.loadClass(onMember.getDeclaringClass());
org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[] anns = new org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[0];
if (onMember instanceof Method) {
org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method) onMember);
if (bcelMethod == null) {
// fallback on reflection - see pr220430
// System.err.println(
// "Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method '"
// +
// onMember.getName()+"' in class '"+jc.getClassName()+"'");
} else {
anns = bcelMethod.getAnnotations();
}
} else if (onMember instanceof Constructor) {
org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember);
anns = bcelCons.getAnnotations();
} else if (onMember instanceof Field) {
org.aspectj.apache.bcel.classfile.Field bcelField = jc.getField((Field) onMember);
anns = bcelField.getAnnotations();
}
// the answer is cached and we don't want to hold on to memory
bcelRepository.clear();
// OPTIMIZE make this a constant 0 size array