Top Description Fields Constructors Methods
javassist.bytecode.annotation

public Class AnnotationImpl

extends Object
implements InvocationHandler
Class Inheritance
All Implemented Interfaces
java.lang.reflect.InvocationHandler
Imports
java.lang.reflect.InvocationHandler, .Method, .Proxy, javassist.ClassPool, .CtClass, .NotFoundException, javassist.bytecode.AnnotationDefaultAttribute, .ClassFile, .MethodInfo

Internal-use only. This is a helper class internally used for implementing toAnnotationType() in Annotation.
Authors
Shigeru Chiba, Bill Burke, Adrian Brock

Field Summary

Modifier and TypeField and Description
private Annotation
private transient Class<?>
private transient int
private ClassLoader
private static final String
private static Method
private ClassPool

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static int

Returns:

the hashCode
arrayHashCode
(Object
the object
object
)

Calculates the hashCode of an array using the same algorithm as java.util.Arrays.hashCode()

private boolean

Returns:

the true when equals false otherwise
checkEquals
(Object
the other annotation
obj
)

Check that another annotation equals ourselves.

public Annotation

Returns:

the annotation
getAnnotation
()

Obtains the internal data structure representing the annotation.

private Class<?>

Returns:

the annotation class
getAnnotationType
()

Get the annotation type

private Object
getDefault(String name, Method method)

public String

Returns:

the type name
getTypeName
()

Obtains the name of the annotation type.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public Object
invoke(Object
the proxy instance that the method was invoked on
proxy
,
Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
method
,
Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Executes a method invocation on a proxy instance.

public static Object

Returns:

the annotation
make
(ClassLoader
class loader for obtaining annotation types.
cl
,
Class<?>
the annotation type.
clazz
,
ClassPool
class pool for containing an annotation type (or null).
cp
,
Annotation
the annotation.
anon
)

Constructs an annotation object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationback to summary
private Annotation annotation
annotationTypeback to summary
private transient Class<?> annotationType
cachedHashCodeback to summary
private transient int cachedHashCode
classLoaderback to summary
private ClassLoader classLoader
JDK_ANNOTATION_CLASS_NAMEback to summary
private static final String JDK_ANNOTATION_CLASS_NAME
JDK_ANNOTATION_TYPE_METHODback to summary
private static Method JDK_ANNOTATION_TYPE_METHOD
poolback to summary
private ClassPool pool

Constructor Detail

AnnotationImplback to summary
private AnnotationImpl(Annotation a, ClassPool cp, ClassLoader loader)

Method Detail

arrayHashCodeback to summary
private static int arrayHashCode(Object object)

Calculates the hashCode of an array using the same algorithm as java.util.Arrays.hashCode()

Parameters
object:Object

the object

Returns:int

the hashCode

checkEqualsback to summary
private boolean checkEquals(Object obj) throws Exception

Check that another annotation equals ourselves.

Parameters
obj:Object

the other annotation

Returns:boolean

the true when equals false otherwise

Exceptions
Exception:
for any problem
getAnnotationback to summary
public Annotation getAnnotation()

Obtains the internal data structure representing the annotation.

Returns:Annotation

the annotation

getAnnotationTypeback to summary
private Class<?> getAnnotationType()

Get the annotation type

Returns:Class<?>

the annotation class

Exceptions
NoClassDefFoundError:
when the class could not loaded
getDefaultback to summary
private Object getDefault(String name, Method method) throws ClassNotFoundException, RuntimeException
getTypeNameback to summary
public String getTypeName()

Obtains the name of the annotation type.

Returns:String

the type name

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

Annotations
@Override
invokeback to summary
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

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.

Parameters
proxy:Object

Doc from java.lang.reflect.InvocationHandler.invoke.

the proxy instance that the method was invoked on

method:Method

Doc from java.lang.reflect.InvocationHandler.invoke.

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

Doc from java.lang.reflect.InvocationHandler.invoke.

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

Doc from java.lang.reflect.InvocationHandler.invoke.

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Annotations
@Override
Exceptions
Throwable:

Doc from java.lang.reflect.InvocationHandler.invoke.

the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.

makeback to summary
public static Object make(ClassLoader cl, Class<?> clazz, ClassPool cp, Annotation anon) throws IllegalArgumentException

Constructs an annotation object.

Parameters
cl:ClassLoader

class loader for obtaining annotation types.

clazz:Class<?>

the annotation type.

cp:ClassPool

class pool for containing an annotation type (or null).

anon:Annotation

the annotation.

Returns:Object

the annotation