mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-08 19:14:52 +00:00
address the invalidity of null annotation members
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1073995 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9e4b248d48
commit
ad549f8f34
@ -148,7 +148,12 @@ public static int hashCode(Annotation a) throws IllegalArgumentException,
|
||||
int result = 0;
|
||||
Class<? extends Annotation> type = a.annotationType();
|
||||
for (Method m : type.getDeclaredMethods()) {
|
||||
result += hashMember(m.getName(), m.invoke(a));
|
||||
Object value = m.invoke(a);
|
||||
if (value == null) {
|
||||
throw new IllegalStateException(String.format("Annotation method %s returned null",
|
||||
m));
|
||||
}
|
||||
result += hashMember(m.getName(), value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -198,9 +203,6 @@ public static boolean isValidAnnotationMemberType(Class<?> type) {
|
||||
private static int hashMember(String name, Object value) throws IllegalArgumentException,
|
||||
IllegalAccessException, InvocationTargetException {
|
||||
int part1 = name.hashCode() * 127;
|
||||
if (value == null) {
|
||||
return part1;
|
||||
}
|
||||
if (value.getClass().isArray()) {
|
||||
return part1 ^ arrayMemberHash(value.getClass().getComponentType(), value);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user