org.aspectj.weaver
Class ReferenceType

java.lang.Object
  extended by org.aspectj.weaver.UnresolvedType
      extended by org.aspectj.weaver.ResolvedType
          extended by org.aspectj.weaver.ReferenceType
All Implemented Interfaces:
AnnotatedElement, Traceable, TypeVariableDeclaringElement
Direct Known Subclasses:
ArrayReferenceType, BoundedReferenceType, TypeVariableReferenceType

public class ReferenceType
extends ResolvedType

A reference type represents some 'real' type, not a primitive, not an array - but a real type, for example java.util.List. Each ReferenceType has a delegate that is the underlying artifact - either an eclipse artifact or a bcel artifact. If the type represents a raw type (i.e. there is a generic form) then the genericType field is set to point to the generic type. If it is for a parameterized type then the generic type is also set to point to the generic form.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.aspectj.weaver.UnresolvedType
UnresolvedType.TypeKind
 
Field Summary
static ReferenceType[] EMPTY_ARRAY
           
 
Fields inherited from class org.aspectj.weaver.ResolvedType
crosscuttingMembers, EMPTY_RESOLVED_TYPE_ARRAY, interTypeMungers, MISSING, NONE, PARAMETERIZED_TYPE_IDENTIFIER, temporaryAnnotationTypes, validBoxing, world
 
Fields inherited from class org.aspectj.weaver.UnresolvedType
ANNOTATION, ARRAY_WITH_JUST_OBJECT, AT_INHERITED, AT_RETENTION, AT_TARGET, BOOLEAN, BYTE, CHAR, CLONEABLE, DOUBLE, ENUM, ERROR, FLOAT, INT, JAVA_LANG_ANNOTATION, JAVA_LANG_CLASS_ARRAY, JAVA_LANG_REFLECT_CONSTRUCTOR, JAVA_LANG_REFLECT_FIELD, JAVA_LANG_REFLECT_METHOD, JL_CLASS, JL_EXCEPTION, JL_STRING, JOINPOINT_ENCLOSINGSTATICPART, JOINPOINT_STATICPART, LONG, MISSING_NAME, OBJECT, OBJECTARRAY, RUNTIME_EXCEPTION, SERIALIZABLE, SHORT, signature, signatureErasure, SOMETHING, SUPPRESS_AJ_WARNINGS, THROWABLE, typeKind, typeParameters, typeVariables, VOID
 
Constructor Summary
ReferenceType(ResolvedType theGenericType, ResolvedType[] theParameters, World aWorld)
          Constructor used when creating a parameterized type.
ReferenceType(java.lang.String signature, java.lang.String signatureErasure, World world)
           
ReferenceType(java.lang.String signature, World world)
           
ReferenceType(UnresolvedType genericType, World world)
          Create a reference type for a generic type
 
Method Summary
 void addAnnotation(AnnotationAJ annotationX)
           
 void addParent(ResolvedType newParent)
           
 boolean canAnnotationTargetType()
          Note: Only overridden by ReferenceType subtype
 void checkDuplicates(ReferenceType newRt)
           
 void demoteToSimpleType()
           
 boolean doesNotExposeShadowMungers()
           
 void ensureConsistent()
          Undo any temporary modifications to the type (for example it may be holding annotations temporarily whilst some matching is occurring - These annotations will be added properly during weaving but sometimes for type completion they need to be held here for a while).
 ReferenceType findDerivativeType(ResolvedType[] typeParameters)
          Look for a derivative type with the specified type parameters.
static ReferenceType fromTypeX(UnresolvedType tx, World world)
           
 AnnotationAJ getAnnotationOfType(UnresolvedType ofType)
           
 AnnotationAJ[] getAnnotations()
           
 AnnotationTargetKind[] getAnnotationTargetKinds()
          Note: Only overridden by ReferenceType subtype
 ResolvedType[] getAnnotationTypes()
           
 int getCompilerVersion()
          return the weaver version used to build this type - defaults to the most recent version unless discovered otherwise.
 ResolvedMember[] getDeclaredFields()
           
 java.lang.String getDeclaredGenericSignature()
           
 ResolvedType[] getDeclaredInterfaces()
          Find out from the generic signature the true signature of any interfaces I implement.
 ResolvedMember[] getDeclaredMethods()
           
 ResolvedMember[] getDeclaredPointcuts()
           
 java.util.Collection<Declare> getDeclares()
           
 ReferenceTypeDelegate getDelegate()
           
 int getEndPos()
           
 java.lang.String getGenericSignature()
           
 ReferenceType getGenericType()
          Overridden by ReferenceType to return a sensible answer for parameterized and raw types.
 int getModifiers()
           
 java.lang.String getNameAsIdentifier()
           
 ResolvedType getOuterClass()
           
 PerClause getPerClause()
           
 java.util.Collection<ResolvedMember> getPrivilegedAccesses()
           
 java.lang.String getRetentionPolicy()
           
 java.lang.String getSignatureForAttribute()
           
 ISourceContext getSourceContext()
           
 ISourceLocation getSourceLocation()
           
 int getStartPos()
           
 ResolvedType getSuperclass()
           
 java.util.Collection<ConcreteTypeMunger> getTypeMungers()
           
 TypeVariable[] getTypeVariables()
           
 WeaverStateInfo getWeaverState()
           
 boolean hasAnnotation(UnresolvedType ofType)
           
 boolean hasNewInterfaces()
           
 boolean isAnnotation()
          Note: Only overridden by Name subtype.
 boolean isAnnotationStyleAspect()
           
 boolean isAnnotationWithRuntimeRetention()
          Note: Only overridden by Name subtype.
 boolean isAnonymous()
           
 boolean isAspect()
           
 boolean isAssignableFrom(ResolvedType other)
          Determines if the variables of this type could be assigned values of another type without casting.
 boolean isAssignableFrom(ResolvedType other, boolean allowMissing)
           
 boolean isClass()
           
 boolean isCoerceableFrom(ResolvedType o)
          Determines if values of another type could possibly be cast to this type.
 boolean isEnum()
          Note: Only overridden by Name subtype.
 boolean isExposedToWeaver()
           
 boolean isGenericType()
           
 boolean isNested()
           
 void setDelegate(ReferenceTypeDelegate delegate)
           
 void setEndPos(int endPos)
           
 void setGenericType(ReferenceType rt)
           
 void setStartPos(int startPos)
           
 
Methods inherited from class org.aspectj.weaver.ResolvedType
addInterTypeMunger, ajMembersNeedParameterization, checkInterTypeMungers, checkLegalOverride, clearInterTypeMungers, collectCrosscuttingMembers, collectDeclares, collectInterTypeMungers, conflictingSignature, discoverActualOccurrenceOfTypeInHierarchy, equals, fillInAnyTypeParameters, findPointcut, getAjMemberParameterizationMap, getBinaryPath, getDeclaredAdvice, getDeclaredJavaFields, getDeclaredJavaMethods, getDeclaredShadowMungers, getDeclaringType, getDirectSupertypes, getExposedPointcuts, getFields, getHierarchy, getHierarchy, getHierarchyWithoutIterator, getInterTypeMungers, getInterTypeMungersIncludingSupers, getInterTypeParentMungers, getInterTypeParentMungersIncludingSupers, getMemberParameterizationMap, getMethods, getMethodsIncludingIntertypeDeclarations, getMethodsWithoutIterator, getPointcuts, getRawType, getResolvedComponentType, getResolvedTypeParameters, getSize, getTopmostImplementor, getWorld, isAbstract, isCacheable, isCheckedException, isConvertableFrom, isException, isFinal, isGroovyObject, isInheritedAnnotation, isInterface, isMissing, isMissing, isMoreVisible, isParameterizedWithTypeVariable, isPrimitiveArray, isSynthetic, isTopmostImplementor, isTypeHierarchyComplete, isVisible, lookupDirectlyDeclaredMemberNoSupers, lookupField, lookupMemberIncludingITDsOnInterfaces, lookupMemberNoSupers, lookupMemberWithSupersAndITDs, lookupMethod, lookupMethodInITDs, lookupResolvedMember, lookupSyntheticMember, makeArray, matches, needsNoConversionFrom, parameterize, parameterizedWith, setBinaryPath, tagAsTypeHierarchyComplete
 
Methods inherited from class org.aspectj.weaver.UnresolvedType
add, forGenericType, forGenericTypeSignature, forGenericTypeVariables, forName, forNames, forPrimitiveType, forRawTypeName, forSignature, forSignatures, getBaseName, getClassName, getComponentType, getErasureSignature, getName, getNames, getOutermostType, getPackageName, getPackageNameAsIdentifier, getRawName, getSignature, getSimpleBaseName, getSimpleName, getTypekind, getTypeParameters, getTypeVariableNamed, hashCode, insert, isArray, isGenericWildcard, isParameterizedOrGenericType, isParameterizedOrRawType, isParameterizedType, isPrimitiveType, isRawType, isSimpleType, isTypeVariableReference, isVoid, makeArray, needsModifiableDelegate, read, readArray, resolve, setNeedsModifiableDelegate, toDebugString, toString, toTraceString, write, writeArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final ReferenceType[] EMPTY_ARRAY
Constructor Detail

ReferenceType

public ReferenceType(java.lang.String signature,
                     World world)

ReferenceType

public ReferenceType(java.lang.String signature,
                     java.lang.String signatureErasure,
                     World world)

ReferenceType

public ReferenceType(ResolvedType theGenericType,
                     ResolvedType[] theParameters,
                     World aWorld)
Constructor used when creating a parameterized type.


ReferenceType

public ReferenceType(UnresolvedType genericType,
                     World world)
Create a reference type for a generic type

Method Detail

fromTypeX

public static ReferenceType fromTypeX(UnresolvedType tx,
                                      World world)

checkDuplicates

public void checkDuplicates(ReferenceType newRt)

getSignatureForAttribute

public java.lang.String getSignatureForAttribute()
Overrides:
getSignatureForAttribute in class ResolvedType

isClass

public boolean isClass()
Overrides:
isClass in class ResolvedType

getCompilerVersion

public int getCompilerVersion()
Description copied from class: ResolvedType
return the weaver version used to build this type - defaults to the most recent version unless discovered otherwise.

Overrides:
getCompilerVersion in class ResolvedType
Returns:
the (major) version, AjAttribute.WeaverVersionInfo

isGenericType

public boolean isGenericType()
Overrides:
isGenericType in class UnresolvedType

getGenericSignature

public java.lang.String getGenericSignature()

getAnnotations

public AnnotationAJ[] getAnnotations()
Overrides:
getAnnotations in class ResolvedType

addAnnotation

public void addAnnotation(AnnotationAJ annotationX)
Overrides:
addAnnotation in class ResolvedType

hasAnnotation

public boolean hasAnnotation(UnresolvedType ofType)

getAnnotationTypes

public ResolvedType[] getAnnotationTypes()
Specified by:
getAnnotationTypes in interface AnnotatedElement
Overrides:
getAnnotationTypes in class ResolvedType

getNameAsIdentifier

public java.lang.String getNameAsIdentifier()
Overrides:
getNameAsIdentifier in class UnresolvedType

getAnnotationOfType

public AnnotationAJ getAnnotationOfType(UnresolvedType ofType)
Specified by:
getAnnotationOfType in interface AnnotatedElement
Overrides:
getAnnotationOfType in class ResolvedType

isAspect

public boolean isAspect()
Overrides:
isAspect in class ResolvedType

isAnnotationStyleAspect

public boolean isAnnotationStyleAspect()
Overrides:
isAnnotationStyleAspect in class ResolvedType

isEnum

public boolean isEnum()
Description copied from class: ResolvedType
Note: Only overridden by Name subtype.

Overrides:
isEnum in class ResolvedType

isAnnotation

public boolean isAnnotation()
Description copied from class: ResolvedType
Note: Only overridden by Name subtype.

Overrides:
isAnnotation in class ResolvedType

isAnonymous

public boolean isAnonymous()
Overrides:
isAnonymous in class ResolvedType

isNested

public boolean isNested()
Overrides:
isNested in class ResolvedType

getOuterClass

public ResolvedType getOuterClass()

getRetentionPolicy

public java.lang.String getRetentionPolicy()

isAnnotationWithRuntimeRetention

public boolean isAnnotationWithRuntimeRetention()
Description copied from class: ResolvedType
Note: Only overridden by Name subtype.

Overrides:
isAnnotationWithRuntimeRetention in class ResolvedType

canAnnotationTargetType

public boolean canAnnotationTargetType()
Description copied from class: ResolvedType
Note: Only overridden by ReferenceType subtype

Overrides:
canAnnotationTargetType in class ResolvedType

getAnnotationTargetKinds

public AnnotationTargetKind[] getAnnotationTargetKinds()
Description copied from class: ResolvedType
Note: Only overridden by ReferenceType subtype

Overrides:
getAnnotationTargetKinds in class ResolvedType

isCoerceableFrom

public boolean isCoerceableFrom(ResolvedType o)
Description copied from class: ResolvedType
Determines if values of another type could possibly be cast to this type. The rules followed are from JLS 2ed 5.5, "Casting Conversion".

This method should be commutative, i.e., for all UnresolvedType a, b and all World w:

 a.isCoerceableFrom(b, w) == b.isCoerceableFrom(a, w)
 

Specified by:
isCoerceableFrom in class ResolvedType
Parameters:
o - the other type
Returns:
true iff values of other could possibly be cast to this type.

isAssignableFrom

public boolean isAssignableFrom(ResolvedType other)
Description copied from class: ResolvedType
Determines if the variables of this type could be assigned values of another type without casting. This still allows for assignment conversion as per JLS 2ed 5.2. For object types, this means supertypeOrEqual(THIS, OTHER).

Specified by:
isAssignableFrom in class ResolvedType
Parameters:
other - the other type
Returns:
true iff variables of this type could be assigned values of other without casting

isAssignableFrom

public boolean isAssignableFrom(ResolvedType other,
                                boolean allowMissing)
Specified by:
isAssignableFrom in class ResolvedType

getSourceContext

public ISourceContext getSourceContext()
Specified by:
getSourceContext in class ResolvedType

getSourceLocation

public ISourceLocation getSourceLocation()
Overrides:
getSourceLocation in class ResolvedType

isExposedToWeaver

public boolean isExposedToWeaver()
Overrides:
isExposedToWeaver in class ResolvedType

getWeaverState

public WeaverStateInfo getWeaverState()
Overrides:
getWeaverState in class ResolvedType

getDeclaredFields

public ResolvedMember[] getDeclaredFields()
Specified by:
getDeclaredFields in class ResolvedType

getDeclaredInterfaces

public ResolvedType[] getDeclaredInterfaces()
Find out from the generic signature the true signature of any interfaces I implement. If I am parameterized, these may then need to be parameterized before returning.

Specified by:
getDeclaredInterfaces in class ResolvedType

getDeclaredMethods

public ResolvedMember[] getDeclaredMethods()
Specified by:
getDeclaredMethods in class ResolvedType

getDeclaredPointcuts

public ResolvedMember[] getDeclaredPointcuts()
Specified by:
getDeclaredPointcuts in class ResolvedType

getTypeVariables

public TypeVariable[] getTypeVariables()
Overrides:
getTypeVariables in class UnresolvedType

getPerClause

public PerClause getPerClause()
Overrides:
getPerClause in class ResolvedType

getDeclares

public java.util.Collection<Declare> getDeclares()
Overrides:
getDeclares in class ResolvedType

getTypeMungers

public java.util.Collection<ConcreteTypeMunger> getTypeMungers()
Overrides:
getTypeMungers in class ResolvedType

getPrivilegedAccesses

public java.util.Collection<ResolvedMember> getPrivilegedAccesses()
Overrides:
getPrivilegedAccesses in class ResolvedType

getModifiers

public int getModifiers()
Specified by:
getModifiers in class ResolvedType

getSuperclass

public ResolvedType getSuperclass()
Specified by:
getSuperclass in class ResolvedType
Returns:
the superclass of this type, or null (if this represents a jlObject, primitive, or void)

getDelegate

public ReferenceTypeDelegate getDelegate()

setDelegate

public void setDelegate(ReferenceTypeDelegate delegate)

getEndPos

public int getEndPos()

getStartPos

public int getStartPos()

setEndPos

public void setEndPos(int endPos)

setStartPos

public void setStartPos(int startPos)

doesNotExposeShadowMungers

public boolean doesNotExposeShadowMungers()
Overrides:
doesNotExposeShadowMungers in class ResolvedType

getDeclaredGenericSignature

public java.lang.String getDeclaredGenericSignature()

setGenericType

public void setGenericType(ReferenceType rt)

demoteToSimpleType

public void demoteToSimpleType()

getGenericType

public ReferenceType getGenericType()
Description copied from class: ResolvedType
Overridden by ReferenceType to return a sensible answer for parameterized and raw types.

Overrides:
getGenericType in class ResolvedType
Returns:

ensureConsistent

public void ensureConsistent()
Description copied from class: ResolvedType
Undo any temporary modifications to the type (for example it may be holding annotations temporarily whilst some matching is occurring - These annotations will be added properly during weaving but sometimes for type completion they need to be held here for a while).

Overrides:
ensureConsistent in class ResolvedType

addParent

public void addParent(ResolvedType newParent)
Overrides:
addParent in class ResolvedType

findDerivativeType

public ReferenceType findDerivativeType(ResolvedType[] typeParameters)
Look for a derivative type with the specified type parameters. This can avoid creating an unnecessary new (duplicate) with the same information in it. This method also cleans up any reference entries that have been null'd by a GC.

Parameters:
typeParameters - the type parameters to use when searching for the derivative type.
Returns:
an existing derivative type or null if there isn't one

hasNewInterfaces

public boolean hasNewInterfaces()