问题描述
java 反射 API 提供了这两种不同的方式来定位注解:
https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AnnotatedElement.html#getAnnotations-- https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AnnotatedElement.html#getDeclaredAnnotations--
第二种方式,getDeclaredAnnotations(),排除那些被继承的注解。
有谁知道使用 https://github.com/classgraph/classgraph 来做同样的事情的方法吗? ...定位声明的注解并排除继承的注解?
我当前的类图代码 (github link) 正在撤回继承的注释,我需要排除它们:
for( MethodInfo methodInfo : methodInfoList) {
if (methodInfo.hasAnnotation(Load.class.getName())) {
AnnotationInfo annotationInfo = methodInfo.getAnnotationInfo(Load.class.getName());
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)