Class AnnotationImpl

  • All Implemented Interfaces:
    java.lang.reflect.InvocationHandler

    public class AnnotationImpl
    extends java.lang.Object
    implements java.lang.reflect.InvocationHandler
    Internal-use only. This is a helper class internally used for implementing toAnnotationType() in Annotation.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static int arrayHashCode​(java.lang.Object object)
      Calculates the hashCode of an array using the same algorithm as java.util.Arrays.hashCode()
      private boolean checkEquals​(java.lang.Object obj)
      Check that another annotation equals ourselves.
      Annotation getAnnotation()
      Obtains the internal data structure representing the annotation.
      private java.lang.Class getAnnotationType()
      Get the annotation type
      private java.lang.Object getDefault​(java.lang.String name, java.lang.reflect.Method method)  
      java.lang.String getTypeName()
      Obtains the name of the annotation type.
      int hashCode()
      Returns a hash code value for this object.
      java.lang.Object invoke​(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
      Executes a method invocation on a proxy instance.
      static java.lang.Object make​(java.lang.ClassLoader cl, java.lang.Class clazz, ClassPool cp, Annotation anon)
      Constructs an annotation object.
      • Methods inherited from class java.lang.Object

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

      • JDK_ANNOTATION_CLASS_NAME

        private static final java.lang.String JDK_ANNOTATION_CLASS_NAME
        See Also:
        Constant Field Values
      • JDK_ANNOTATION_TYPE_METHOD

        private static java.lang.reflect.Method JDK_ANNOTATION_TYPE_METHOD
      • classLoader

        private java.lang.ClassLoader classLoader
      • annotationType

        private transient java.lang.Class annotationType
      • cachedHashCode

        private transient int cachedHashCode
    • Constructor Detail

      • AnnotationImpl

        private AnnotationImpl​(Annotation a,
                               ClassPool cp,
                               java.lang.ClassLoader loader)
    • Method Detail

      • make

        public static java.lang.Object make​(java.lang.ClassLoader cl,
                                            java.lang.Class clazz,
                                            ClassPool cp,
                                            Annotation anon)
        Constructs an annotation object.
        Parameters:
        cl - class loader for obtaining annotation types.
        clazz - the annotation type.
        cp - class pool for containing an annotation type (or null).
        anon - the annotation.
        Returns:
        the annotation
      • getTypeName

        public java.lang.String getTypeName()
        Obtains the name of the annotation type.
        Returns:
        the type name
      • getAnnotationType

        private java.lang.Class getAnnotationType()
        Get the annotation type
        Returns:
        the annotation class
        Throws:
        java.lang.NoClassDefFoundError - when the class could not loaded
      • getAnnotation

        public Annotation getAnnotation()
        Obtains the internal data structure representing the annotation.
        Returns:
        the annotation
      • invoke

        public java.lang.Object invoke​(java.lang.Object proxy,
                                       java.lang.reflect.Method method,
                                       java.lang.Object[] args)
                                throws java.lang.Throwable
        Executes a method invocation on a proxy instance. The implementations of toString(), equals(), and hashCode() are directly supplied by the AnnotationImpl. The annotationType() method is also available on the proxy instance.
        Specified by:
        invoke in interface java.lang.reflect.InvocationHandler
        Throws:
        java.lang.Throwable
      • getDefault

        private java.lang.Object getDefault​(java.lang.String name,
                                            java.lang.reflect.Method method)
                                     throws java.lang.ClassNotFoundException,
                                            java.lang.RuntimeException
        Throws:
        java.lang.ClassNotFoundException
        java.lang.RuntimeException
      • hashCode

        public int hashCode()
        Returns a hash code value for this object.
        Overrides:
        hashCode in class java.lang.Object
      • checkEquals

        private boolean checkEquals​(java.lang.Object obj)
                             throws java.lang.Exception
        Check that another annotation equals ourselves.
        Parameters:
        obj - the other annotation
        Returns:
        the true when equals false otherwise
        Throws:
        java.lang.Exception - for any problem
      • arrayHashCode

        private static int arrayHashCode​(java.lang.Object object)
        Calculates the hashCode of an array using the same algorithm as java.util.Arrays.hashCode()
        Parameters:
        object - the object
        Returns:
        the hashCode