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();
}
else if (methodName == "hashCode")
{
return Integer.valueOf(hashCode());
}
else if (methodName == "annotationType")
{
return type;
}
else
{
Object val = memberValues.get(methodName);
if (val == null)
{
throw new IncompleteAnnotationException(type, methodName);
}
try
{
if (val.getClass().isArray())
val = coerce((Object[])val, method.getReturnType());
}
catch (ArrayStoreException _)
{
throw new AnnotationTypeMismatchException
(method, val.getClass().getName());
}
if (! getBoxedReturnType(method).isInstance(val))
throw (new AnnotationTypeMismatchException
(method, val.getClass().getName()));
return val;
}
}
else if (args.length == 1)
{
if (methodName == "equals")
{
return Boolean.valueOf(equals(proxy, args[0]));
}
}
throw new InternalError("Invalid annotation proxy");
}
AnnotationInvocationHandler.java 文件源码
java
阅读 39
收藏 0
点赞 0
评论 0
项目:javify
作者:
评论列表
文章目录