8277672: Better invocation handler handling

Reviewed-by: skoivu, mchung, rhalade
This commit is contained in:
Joe Darcy 2022-01-19 18:43:41 +00:00 committed by Henry Jen
parent 9ce2d75d0b
commit ee0743801e

View file

@ -666,8 +666,8 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
if (!(memberType.isInstance(value) || if (!(memberType.isInstance(value) ||
value instanceof ExceptionProxy)) { value instanceof ExceptionProxy)) {
value = new AnnotationTypeMismatchExceptionProxy( value = new AnnotationTypeMismatchExceptionProxy(
value.getClass() + "[" + value + "]").setMember( objectToString(value))
annotationType.members().get(name)); .setMember(annotationType.members().get(name));
} }
} }
mv.put(name, value); mv.put(name, value);
@ -677,6 +677,15 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
UnsafeAccessor.setMemberValues(this, mv); 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 class UnsafeAccessor {
private static final jdk.internal.misc.Unsafe unsafe private static final jdk.internal.misc.Unsafe unsafe
= jdk.internal.misc.Unsafe.getUnsafe(); = jdk.internal.misc.Unsafe.getUnsafe();