Class AnnotationInvocationHandler

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.reflect.InvocationHandler

    final class AnnotationInvocationHandler
    extends java.lang.Object
    implements java.lang.reflect.InvocationHandler, java.io.Serializable
    InvocationHandler for dynamic proxy implementation of Annotation.
    Since:
    1.5
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.reflect.Method[] memberMethods  
      private java.util.Map<java.lang.String,​java.lang.Object> memberValues  
      private static long serialVersionUID  
      private java.lang.Class<? extends java.lang.annotation.Annotation> type  
    • Constructor Summary

      Constructors 
      Constructor Description
      AnnotationInvocationHandler​(java.lang.Class<? extends java.lang.annotation.Annotation> type, java.util.Map<java.lang.String,​java.lang.Object> memberValues)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private AnnotationInvocationHandler asOneOfUs​(java.lang.Object o)
      Returns an object's invocation handler if that object is a dynamic proxy with a handler of type AnnotationInvocationHandler.
      private static java.lang.Object cloneArray​(java.lang.Object array)
      This method, which clones its array argument, would not be necessary if Cloneable had a public clone method.
      private java.lang.Boolean equalsImpl​(java.lang.Object o)
      Implementation of dynamicProxy.equals(Object o)
      private java.lang.reflect.Method[] getMemberMethods()
      Returns the member methods for our annotation type.
      private int hashCodeImpl()
      Implementation of dynamicProxy.hashCode()
      java.lang.Object invoke​(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)  
      private static boolean memberValueEquals​(java.lang.Object v1, java.lang.Object v2)
      Returns true iff the two member values in "dynamic proxy return form" are equal using the appropriate equality function depending on the member type.
      private static int memberValueHashCode​(java.lang.Object value)
      Computes hashCode of a member value (in "dynamic proxy return form")
      private static java.lang.String memberValueToString​(java.lang.Object value)
      Translates a member value (in "dynamic proxy return form") into a string
      private void readObject​(java.io.ObjectInputStream s)  
      private java.lang.String toStringImpl()
      Implementation of dynamicProxy.toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • type

        private final java.lang.Class<? extends java.lang.annotation.Annotation> type
      • memberValues

        private final java.util.Map<java.lang.String,​java.lang.Object> memberValues
      • memberMethods

        private transient volatile java.lang.reflect.Method[] memberMethods
    • Constructor Detail

      • AnnotationInvocationHandler

        AnnotationInvocationHandler​(java.lang.Class<? extends java.lang.annotation.Annotation> type,
                                    java.util.Map<java.lang.String,​java.lang.Object> memberValues)
    • Method Detail

      • invoke

        public java.lang.Object invoke​(java.lang.Object proxy,
                                       java.lang.reflect.Method method,
                                       java.lang.Object[] args)
        Specified by:
        invoke in interface java.lang.reflect.InvocationHandler
      • cloneArray

        private static java.lang.Object cloneArray​(java.lang.Object array)
        This method, which clones its array argument, would not be necessary if Cloneable had a public clone method.
      • toStringImpl

        private java.lang.String toStringImpl()
        Implementation of dynamicProxy.toString()
      • memberValueToString

        private static java.lang.String memberValueToString​(java.lang.Object value)
        Translates a member value (in "dynamic proxy return form") into a string
      • equalsImpl

        private java.lang.Boolean equalsImpl​(java.lang.Object o)
        Implementation of dynamicProxy.equals(Object o)
      • asOneOfUs

        private AnnotationInvocationHandler asOneOfUs​(java.lang.Object o)
        Returns an object's invocation handler if that object is a dynamic proxy with a handler of type AnnotationInvocationHandler. Returns null otherwise.
      • memberValueEquals

        private static boolean memberValueEquals​(java.lang.Object v1,
                                                 java.lang.Object v2)
        Returns true iff the two member values in "dynamic proxy return form" are equal using the appropriate equality function depending on the member type. The two values will be of the same type unless one of 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.
      • getMemberMethods

        private java.lang.reflect.Method[] getMemberMethods()
        Returns the member methods for our annotation type. These are obtained lazily and cached, as they're expensive to obtain, and we only need them if our `equals` method is invoked (which should be rare).
      • hashCodeImpl

        private int hashCodeImpl()
        Implementation of dynamicProxy.hashCode()
      • memberValueHashCode

        private static int memberValueHashCode​(java.lang.Object value)
        Computes hashCode of a member value (in "dynamic proxy return form")
      • readObject

        private void readObject​(java.io.ObjectInputStream s)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException