if (!(onMember instanceof AccessibleObject)) return Collections.EMPTY_SET;
// here we really want both the runtime visible AND the class visible 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.Annotation[] anns = new org.aspectj.apache.bcel.classfile.annotation.Annotation[0];
if (onMember instanceof Method) {
org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method)onMember);
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();
if (anns == null) anns = new org.aspectj.apache.bcel.classfile.annotation.Annotation[0];