org.jikesrvm.classloader
Class RVMAnnotation

java.lang.Object
  extended by org.jikesrvm.classloader.RVMAnnotation

public final class RVMAnnotation
extends Object

Internal representation of an annotation. We use a proxy class to implement actual annotations RVMClass.


Nested Class Summary
private  class RVMAnnotation.AnnotationFactory
          Class used to implement annotations as proxies
private static class RVMAnnotation.AnnotationMember
          A class to decode and hold the name and its associated value for an annotation member
 
Field Summary
private  RVMAnnotation.AnnotationMember[] elementValuePairs
          Members of this annotation
private static Object NO_VALUE
          Encoding of when a result cannot be returned
private  TypeReference type
          The type of the annotation.
private static ImmutableEntryHashMapRVM<RVMAnnotation,RVMAnnotation> uniqueMap
          Remembered unique annotations
private  Annotation value
          The concrete annotation represented by this RVMAnnotation
 
Constructor Summary
private RVMAnnotation(TypeReference type, RVMAnnotation.AnnotationMember[] elementValuePairs)
          Construct a read annotation
 
Method Summary
private  boolean annotationEquals(Annotation a, Annotation b)
          Are two annotations equal?
private  int annotationHashCode()
          Hash code for annotation value
(package private)  TypeReference annotationType()
          Return the TypeReference of the declared annotation, ie an interface and not the class object of this instance
private  Annotation createValue()
          Create an instance of this type of annotation with the values given in the members
private  String elementString(String name, Object value)
          String representation of the value pair of the form "name=value"
 boolean equals(Object o)
           
(package private) static Object firstUse(Object value)
          Handle late resolution of class value annotations
private  Object getElementValue(String name, Class<?> valueType)
          Find the value for an annotation
(package private)  Annotation getValue()
          Return the annotation represented by this RVMAnnotation.
 int hashCode()
           
(package private) static RVMAnnotation readAnnotation(int[] constantPool, DataInputStream input, ClassLoader classLoader)
          Read an annotation attribute from the class file
(package private) static
<T> Object
readValue(TypeReference type, int[] constantPool, DataInputStream input, ClassLoader classLoader)
          Read the element_value field of an annotation
private static
<T> Object
readValue(TypeReference type, int[] constantPool, DataInputStream input, ClassLoader classLoader, byte elementValue_tag)
           
 String toString()
          Return a string representation of the annotation of the form "@type(name1=val1, ...nameN=valN)"
private static String toStringHelper(Object value)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

type

private final TypeReference type
The type of the annotation. This is an interface name that the annotation value will implement


elementValuePairs

private final RVMAnnotation.AnnotationMember[] elementValuePairs
Members of this annotation


uniqueMap

private static final ImmutableEntryHashMapRVM<RVMAnnotation,RVMAnnotation> uniqueMap
Remembered unique annotations


value

private Annotation value
The concrete annotation represented by this RVMAnnotation


NO_VALUE

private static final Object NO_VALUE
Encoding of when a result cannot be returned

Constructor Detail

RVMAnnotation

private RVMAnnotation(TypeReference type,
                      RVMAnnotation.AnnotationMember[] elementValuePairs)
Construct a read annotation

Parameters:
type - the name of the type this annotation's value will implement
elementValuePairs - values for the fields in the annotation that override the defaults
Method Detail

readAnnotation

static RVMAnnotation readAnnotation(int[] constantPool,
                                    DataInputStream input,
                                    ClassLoader classLoader)
                             throws IOException,
                                    ClassNotFoundException
Read an annotation attribute from the class file

Parameters:
constantPool - from constant pool being loaded
input - the data being read
Throws:
IOException
ClassNotFoundException

getValue

Annotation getValue()
Return the annotation represented by this RVMAnnotation. If this is the first time this annotation has been accessed the subclass of annotation this class represents needs creating.

Returns:
the annotation represented

createValue

private Annotation createValue()
Create an instance of this type of annotation with the values given in the members

Returns:
the created annotation

readValue

static <T> Object readValue(TypeReference type,
                            int[] constantPool,
                            DataInputStream input,
                            ClassLoader classLoader)
                 throws IOException,
                        ClassNotFoundException
Read the element_value field of an annotation

Parameters:
type - the type of the value to read or null
constantPool - the constant pool for the class being read
input - stream to read from
Returns:
object representing the value read
Throws:
IOException
ClassNotFoundException

readValue

private static <T> Object readValue(TypeReference type,
                                    int[] constantPool,
                                    DataInputStream input,
                                    ClassLoader classLoader,
                                    byte elementValue_tag)
                         throws IOException,
                                ClassNotFoundException
Throws:
IOException
ClassNotFoundException

firstUse

static Object firstUse(Object value)
Handle late resolution of class value annotations


annotationType

TypeReference annotationType()
Return the TypeReference of the declared annotation, ie an interface and not the class object of this instance

Returns:
TypeReferernce of interface annotation object implements

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Return a string representation of the annotation of the form "@type(name1=val1, ...nameN=valN)"

Overrides:
toString in class Object

elementString

private String elementString(String name,
                             Object value)
String representation of the value pair of the form "name=value"


toStringHelper

private static String toStringHelper(Object value)

getElementValue

private Object getElementValue(String name,
                               Class<?> valueType)
Find the value for an annotation


annotationHashCode

private int annotationHashCode()
Hash code for annotation value


annotationEquals

private boolean annotationEquals(Annotation a,
                                 Annotation b)
Are two annotations equal?