Class AnnotationImpl

java.lang.Object
javassist.bytecode.annotation.AnnotationImpl
All Implemented Interfaces:
InvocationHandler

public class AnnotationImpl extends Object implements InvocationHandler
Internal-use only. This is a helper class internally used for implementing toAnnotationType() in Annotation.
  • Field Details

    • JDK_ANNOTATION_CLASS_NAME

      private static final String JDK_ANNOTATION_CLASS_NAME
      See Also:
    • JDK_ANNOTATION_TYPE_METHOD

      private static Method JDK_ANNOTATION_TYPE_METHOD
    • annotation

      private Annotation annotation
    • pool

      private ClassPool pool
    • classLoader

      private ClassLoader classLoader
    • annotationType

      private transient Class<?> annotationType
    • cachedHashCode

      private transient int cachedHashCode
  • Constructor Details

  • Method Details

    • make

      public static Object make(ClassLoader cl, Class<?> clazz, ClassPool cp, Annotation anon) throws IllegalArgumentException
      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
      Throws:
      IllegalArgumentException
    • getTypeName

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

      private Class<?> getAnnotationType()
      Get the annotation type
      Returns:
      the annotation class
      Throws:
      NoClassDefFoundError - when the class could not loaded
    • getAnnotation

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

      public Object invoke(Object proxy, Method method, Object[] args) throws 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 InvocationHandler
      Throws:
      Throwable
    • getDefault

      private Object getDefault(String name, Method method) throws ClassNotFoundException, RuntimeException
      Throws:
      ClassNotFoundException
      RuntimeException
    • hashCode

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

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

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