AnnotationInvocationHandler.java 文件源码

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

项目:jvm-stm 作者:
public Object invoke(Object proxy, Method method, Object[] args)
    throws Throwable
  {
      String methodName = method.getName().intern();
      if (args == null || args.length == 0)
      {
          if (methodName == "toString")
          {
              return toString(type, memberValues);
          }
          else if (methodName == "hashCode")
          {
              return Integer.valueOf(hashCode(type, memberValues));
          }
          else if (methodName == "annotationType")
          {
              return type;
          }
          else
          {
              Object val = memberValues.get(methodName);
              if (val == null)
              {
                  throw new IncompleteAnnotationException(type, methodName);
              }
              if (! getBoxedReturnType(method).isInstance(val))
              {
                  throw new AnnotationTypeMismatchException(method,
                      val.getClass().getName());
              }
if (val.getClass().isArray())
{
    val = arrayClone(val);
}
              return val;
          }
      }
      else if (args.length == 1)
      {
          if (methodName == "equals")
          {
              return Boolean.valueOf(equals(type, memberValues, args[0]));
          }
      }
      throw new InternalError("Invalid annotation proxy");
  }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号