org.jikesrvm.classloader
Class AnnotatedElement

java.lang.Object
  extended by org.jikesrvm.classloader.AnnotatedElement
All Implemented Interfaces:
AnnotatedElement
Direct Known Subclasses:
RVMMember, RVMType

public abstract class AnnotatedElement
extends Object
implements AnnotatedElement

A common abstract super class for all elements that can be annotated within the JVM. Namely classes, methods and fields.


Field Summary
protected  Object declaredAnnotationDatas
          Annotations from the class file that are described as runtime visible.
private  Annotation[] declaredAnnotations
          Cached array of declared annotations.
private static Annotation[] emptyAnnotationArray
          Empty annotation array
 
Constructor Summary
protected AnnotatedElement(RVMAnnotation[] annotations)
          Constructor used by all annotated elements
 
Method Summary
private  Annotation[] cloneAnnotations(Annotation[] internal)
          Copy array of annotations so can be safely returned to user.
<T extends Annotation>
T
getAnnotation(Class<T> annotationClass)
          Get the annotation implementing the specified class or null
 Annotation[] getAnnotations()
          Get the annotations for this and all super annotated elements.
(package private)  Annotation[] getAnnotationsInternal()
           
 Annotation[] getDeclaredAnnotations()
          Get the annotations for this annotated element
(package private)  Annotation[] getDeclaredAnnotationsInternal()
           
 boolean hasAnnotations()
          Does the element have any annotations?
 boolean hasBaselineNoRegistersAnnotation()
          Return true if this element has a BaselineNoRegisters annotation.
 boolean hasBaselineSaveLSRegistersAnnotation()
          Return true if this element has a BaselineSaveLSRegisters annotation.
 boolean hasInlineAnnotation()
          Return true if this element has a Inline annotation.
 boolean hasInterruptibleAnnotation()
          Return true if this element has a Interruptible annotation.
 boolean hasLogicallyUninterruptibleAnnotation()
          Return true if this element has a LogicallyUninterruptible annotation.
 boolean hasNoBoundsCheckAnnotation()
          Return true if this element has a NoBoundsCheck annotation.
 boolean hasNoCheckStoreAnnotation()
          Return true if this element has a NoCheckStore annotation.
 boolean hasNoEscapesAnnotation()
          Return true if this element has a NoEscapes annotation.
 boolean hasNoInlineAnnotation()
          Return true if this element has a NoInline annotation.
 boolean hasNonMovingAllocationAnnotation()
          Return true if this element has a NonMovingAllocation annotation.
 boolean hasNonMovingAnnotation()
          Return true if this element has a NonMoving annotation.
 boolean hasNoNullCheckAnnotation()
          Return true if this element has a NoNullCheck annotation.
 boolean hasNoOptCompileAnnotation()
          Return true if this element has a NoOptCompile annotation.
 boolean hasPreemptibleAnnotation()
          Return true if this element has a Preemptible annotation.
 boolean hasPureAnnotation()
          Return true if this element has a Pure annotation.
 boolean hasRuntimeFinalAnnotation()
          Return true if this element has a RuntimeFinal annotation.
 boolean hasRuntimePureAnnotation()
          Return true if this element has a RuntimePure annotation.
 boolean hasUninterruptibleAnnotation()
          Return true if this element has a Uninterruptible annotation.
 boolean hasUninterruptibleNoWarnAnnotation()
          Return true if this element has a UninterruptibleNoWarn annotation.
 boolean hasUnpreemptibleAnnotation()
          Return true if this element has a Unpreemptible annotation.
 boolean hasUnpreemptibleNoWarnAnnotation()
          Return true if this element has a UninterruptibleNoWarn annotation.
 boolean hasUntracedAnnotation()
          Return true if this element has a Untraced annotation.
(package private)  boolean isAnnotationDeclared(TypeReference annotationTypeRef)
          Return true if annotation present.
 boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
          Is there an annotation of this type implemented on this annotated element?
protected static RVMAnnotation[] readAnnotations(int[] constantPool, DataInputStream input, ClassLoader classLoader)
          Read annotations from a class file and package in an array
(package private)  Annotation[] toAnnotations(Object datas)
          Convert annotations from internal format to annotation instances.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

declaredAnnotationDatas

protected final Object declaredAnnotationDatas
Annotations from the class file that are described as runtime visible. These annotations are available to the reflection API. This is either null, a RVMAnnotation if a single annotation is present, or an array of RVMAnnotation if there is >1


declaredAnnotations

private Annotation[] declaredAnnotations
Cached array of declared annotations.


emptyAnnotationArray

private static final Annotation[] emptyAnnotationArray
Empty annotation array

Constructor Detail

AnnotatedElement

protected AnnotatedElement(RVMAnnotation[] annotations)
Constructor used by all annotated elements

Parameters:
annotations - array of runtime visible annotations
Method Detail

readAnnotations

protected static RVMAnnotation[] readAnnotations(int[] constantPool,
                                                 DataInputStream input,
                                                 ClassLoader classLoader)
                                          throws IOException
Read annotations from a class file and package in an array

Parameters:
constantPool - the constantPool of the RVMClass object that's being constructed
input - the DataInputStream to read the method's attributes from
Returns:
an array of read annotations
Throws:
IOException

getAnnotations

public final Annotation[] getAnnotations()
Get the annotations for this and all super annotated elements.

Specified by:
getAnnotations in interface AnnotatedElement

getAnnotationsInternal

Annotation[] getAnnotationsInternal()

getDeclaredAnnotations

public final Annotation[] getDeclaredAnnotations()
Get the annotations for this annotated element

Specified by:
getDeclaredAnnotations in interface AnnotatedElement

getDeclaredAnnotationsInternal

final Annotation[] getDeclaredAnnotationsInternal()

cloneAnnotations

private Annotation[] cloneAnnotations(Annotation[] internal)
Copy array of annotations so can be safely returned to user.


toAnnotations

final Annotation[] toAnnotations(Object datas)
Convert annotations from internal format to annotation instances.

Parameters:
datas - the annotations.
Returns:
the annotation instances.

getAnnotation

public final <T extends Annotation> T getAnnotation(Class<T> annotationClass)
Get the annotation implementing the specified class or null

Specified by:
getAnnotation in interface AnnotatedElement

isAnnotationPresent

public final boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
Is there an annotation of this type implemented on this annotated element?

Specified by:
isAnnotationPresent in interface AnnotatedElement

isAnnotationDeclared

final boolean isAnnotationDeclared(TypeReference annotationTypeRef)
Return true if annotation present. This is provided as an alternative to isAnnotationPresent() as isAnnotationPresent() may require classloading and instantiation of annotations. Classloading would mean that it would not be @Uninterruptible. Instantiation is not desirable as checking of annotations occurs prior to the bootimage compiler being ready to instantiate objects.


hasAnnotations

public final boolean hasAnnotations()
Does the element have any annotations?


hasInterruptibleAnnotation

public final boolean hasInterruptibleAnnotation()
Return true if this element has a Interruptible annotation.

See Also:
Interruptible

hasLogicallyUninterruptibleAnnotation

public final boolean hasLogicallyUninterruptibleAnnotation()
Return true if this element has a LogicallyUninterruptible annotation.

See Also:
LogicallyUninterruptible

hasPreemptibleAnnotation

public final boolean hasPreemptibleAnnotation()
Return true if this element has a Preemptible annotation.

See Also:
Preemptible

hasUninterruptibleNoWarnAnnotation

public final boolean hasUninterruptibleNoWarnAnnotation()
Return true if this element has a UninterruptibleNoWarn annotation.

See Also:
UninterruptibleNoWarn

hasUnpreemptibleNoWarnAnnotation

public final boolean hasUnpreemptibleNoWarnAnnotation()
Return true if this element has a UninterruptibleNoWarn annotation.

See Also:
UninterruptibleNoWarn

hasUninterruptibleAnnotation

public final boolean hasUninterruptibleAnnotation()
Return true if this element has a Uninterruptible annotation.

See Also:
Uninterruptible

hasNoCheckStoreAnnotation

public final boolean hasNoCheckStoreAnnotation()
Return true if this element has a NoCheckStore annotation.

See Also:
NoCheckStore

hasUnpreemptibleAnnotation

public final boolean hasUnpreemptibleAnnotation()
Return true if this element has a Unpreemptible annotation.

See Also:
Unpreemptible

hasNoOptCompileAnnotation

public final boolean hasNoOptCompileAnnotation()
Return true if this element has a NoOptCompile annotation.

See Also:
NoOptCompile

hasInlineAnnotation

public final boolean hasInlineAnnotation()
Return true if this element has a Inline annotation.

See Also:
Inline

hasNoInlineAnnotation

public final boolean hasNoInlineAnnotation()
Return true if this element has a NoInline annotation.

See Also:
NoInline

hasBaselineNoRegistersAnnotation

public final boolean hasBaselineNoRegistersAnnotation()
Return true if this element has a BaselineNoRegisters annotation.

See Also:
BaselineNoRegisters

hasBaselineSaveLSRegistersAnnotation

public final boolean hasBaselineSaveLSRegistersAnnotation()
Return true if this element has a BaselineSaveLSRegisters annotation.

See Also:
BaselineSaveLSRegisters

hasPureAnnotation

public final boolean hasPureAnnotation()
Return true if this element has a Pure annotation.

See Also:
Pure

hasRuntimePureAnnotation

public final boolean hasRuntimePureAnnotation()
Return true if this element has a RuntimePure annotation.

See Also:
RuntimePure

hasNoNullCheckAnnotation

public final boolean hasNoNullCheckAnnotation()
Return true if this element has a NoNullCheck annotation.

See Also:
NoNullCheck

hasNoBoundsCheckAnnotation

public final boolean hasNoBoundsCheckAnnotation()
Return true if this element has a NoBoundsCheck annotation.

See Also:
NoBoundsCheck

hasRuntimeFinalAnnotation

public final boolean hasRuntimeFinalAnnotation()
Return true if this element has a RuntimeFinal annotation.

See Also:
RuntimeFinal

hasNoEscapesAnnotation

public final boolean hasNoEscapesAnnotation()
Return true if this element has a NoEscapes annotation.

See Also:
NoEscapes

hasUntracedAnnotation

public final boolean hasUntracedAnnotation()
Return true if this element has a Untraced annotation.

See Also:
Untraced

hasNonMovingAnnotation

public final boolean hasNonMovingAnnotation()
Return true if this element has a NonMoving annotation.

See Also:
NonMoving

hasNonMovingAllocationAnnotation

public final boolean hasNonMovingAllocationAnnotation()
Return true if this element has a NonMovingAllocation annotation.

See Also:
NonMovingAllocation