src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java

Print this page

        

*** 38,58 **** * * @author Josh Bloch * @since 1.5 */ class AnnotationInvocationHandler implements InvocationHandler, Serializable { ! private final Class type; private final Map<String, Object> memberValues; ! AnnotationInvocationHandler(Class type, Map<String, Object> memberValues) { this.type = type; this.memberValues = memberValues; } public Object invoke(Object proxy, Method method, Object[] args) { String member = method.getName(); ! Class[] paramTypes = method.getParameterTypes(); // Handle Object and Annotation methods if (member.equals("equals") && paramTypes.length == 1 && paramTypes[0] == Object.class) return equalsImpl(args[0]); --- 38,58 ---- * * @author Josh Bloch * @since 1.5 */ class AnnotationInvocationHandler implements InvocationHandler, Serializable { ! private final Class<? extends Annotation> type; private final Map<String, Object> memberValues; ! AnnotationInvocationHandler(Class<? extends Annotation> type, Map<String, Object> memberValues) { this.type = type; this.memberValues = memberValues; } public Object invoke(Object proxy, Method method, Object[] args) { String member = method.getName(); ! Class<?>[] paramTypes = method.getParameterTypes(); // Handle Object and Annotation methods if (member.equals("equals") && paramTypes.length == 1 && paramTypes[0] == Object.class) return equalsImpl(args[0]);
*** 82,92 **** /** * This method, which clones its array argument, would not be necessary * if Cloneable had a public clone method. */ private Object cloneArray(Object array) { ! Class type = array.getClass(); if (type == byte[].class) { byte[] byteArray = (byte[])array; return byteArray.clone(); } --- 82,92 ---- /** * This method, which clones its array argument, would not be necessary * if Cloneable had a public clone method. */ private Object cloneArray(Object array) { ! Class<?> type = array.getClass(); if (type == byte[].class) { byte[] byteArray = (byte[])array; return byteArray.clone(); }
*** 149,159 **** /** * Translates a member value (in "dynamic proxy return form") into a string */ private static String memberValueToString(Object value) { ! Class type = value.getClass(); if (!type.isArray()) // primitive, string, class, enum const, // or annotation return value.toString(); if (type == byte[].class) --- 149,159 ---- /** * Translates a member value (in "dynamic proxy return form") into a string */ private static String memberValueToString(Object value) { ! Class<?> type = value.getClass(); if (!type.isArray()) // primitive, string, class, enum const, // or annotation return value.toString(); if (type == byte[].class)
*** 227,237 **** * the containing annotations is ill-formed. If one of the containing * annotations is ill-formed, this method will return false unless the * two members are identical object references. */ private static boolean memberValueEquals(Object v1, Object v2) { ! Class type = v1.getClass(); // Check for primitive, string, class, enum const, annotation, // or ExceptionProxy if (!type.isArray()) return v1.equals(v2); --- 227,237 ---- * the containing annotations is ill-formed. If one of the containing * annotations is ill-formed, this method will return false unless the * two members are identical object references. */ private static boolean memberValueEquals(Object v1, Object v2) { ! Class<?> type = v1.getClass(); // Check for primitive, string, class, enum const, annotation, // or ExceptionProxy if (!type.isArray()) return v1.equals(v2);
*** 299,309 **** /** * Computes hashCode of a member value (in "dynamic proxy return form") */ private static int memberValueHashCode(Object value) { ! Class type = value.getClass(); if (!type.isArray()) // primitive, string, class, enum const, // or annotation return value.hashCode(); if (type == byte[].class) --- 299,309 ---- /** * Computes hashCode of a member value (in "dynamic proxy return form") */ private static int memberValueHashCode(Object value) { ! Class<?> type = value.getClass(); if (!type.isArray()) // primitive, string, class, enum const, // or annotation return value.hashCode(); if (type == byte[].class)
*** 338,352 **** } catch(IllegalArgumentException e) { // Class is no longer an annotation type; all bets are off return; } ! Map<String, Class> memberTypes = annotationType.memberTypes(); for (Map.Entry<String, Object> memberValue : memberValues.entrySet()) { String name = memberValue.getKey(); ! Class memberType = memberTypes.get(name); if (memberType != null) { // i.e. member still exists Object value = memberValue.getValue(); if (!(memberType.isInstance(value) || value instanceof ExceptionProxy)) { memberValue.setValue( --- 338,352 ---- } catch(IllegalArgumentException e) { // Class is no longer an annotation type; all bets are off return; } ! Map<String, Class<?>> memberTypes = annotationType.memberTypes(); for (Map.Entry<String, Object> memberValue : memberValues.entrySet()) { String name = memberValue.getKey(); ! Class<?> memberType = memberTypes.get(name); if (memberType != null) { // i.e. member still exists Object value = memberValue.getValue(); if (!(memberType.isInstance(value) || value instanceof ExceptionProxy)) { memberValue.setValue(