8277672: Better invocation handler handling

Reviewed-by: yan
Backport-of: 0691804665559f1935b7361d5f1207ac46f823f0
This commit is contained in:
Aleksei Voitylov 2022-03-14 14:33:28 +03:00 committed by Andrew Brygin
parent ee04280526
commit f7b710fcb3

View File

@ -457,8 +457,8 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
if (!(memberType.isInstance(value) ||
value instanceof ExceptionProxy)) {
value = new AnnotationTypeMismatchExceptionProxy(
value.getClass() + "[" + value + "]").setMember(
annotationType.members().get(name));
objectToString(value))
.setMember(annotationType.members().get(name));
}
}
mv.put(name, value);
@ -468,6 +468,15 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
UnsafeAccessor.setMemberValues(this, mv);
}
/*
* Create a textual representation of the argument without calling
* any overridable methods of the argument.
*/
private static String objectToString(Object value) {
return value.getClass().getName() + "@" +
Integer.toHexString(System.identityHashCode(value));
}
private static class UnsafeAccessor {
private static final sun.misc.Unsafe unsafe;
private static final long typeOffset;