AnnotationType.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:gjpf-core 作者:
private AnnotationType(final Class<?> annoCls) {
  if (!annoCls.isAnnotation()) {
    throw new IllegalArgumentException("Not an annotation type");
  }

  Method[] methods = annoCls.getDeclaredMethods();

  for (Method m : methods) {
    if (m.getParameterTypes().length == 0) {
      // cache name -> method assoc
      String mname = m.getName();
      members.put(mname, m);

      // cache member type
      Class<?> type = m.getReturnType();
      memberTypes.put(mname, invocationHandlerReturnType(type));

      // cache member default val (if any)
      Object val = m.getDefaultValue();
      if (val != null) {
        memberDefaults.put(mname, val);
      }
    } else {
      // probably an exception
    }
  }

  if ((annoCls != Retention.class) && (annoCls != Inherited.class)) { // don't get recursive
    inherited = annoCls.isAnnotationPresent(Inherited.class);

    Retention r = annoCls.getAnnotation(Retention.class);
    if (r == null) {
      retention = RetentionPolicy.CLASS;
    } else {
      retention = r.value();
    }
  }

  SharedSecrets.getJavaLangAccess().setAnnotationType(annoCls, this);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号