org.aspectj.weaver
Class UnresolvedType

java.lang.Object
  extended by org.aspectj.weaver.UnresolvedType
All Implemented Interfaces:
Traceable, TypeVariableDeclaringElement
Direct Known Subclasses:
ResolvedType, UnresolvedTypeVariableReferenceType, WildcardedUnresolvedType

public class UnresolvedType
extends java.lang.Object
implements Traceable, TypeVariableDeclaringElement

A UnresolvedType represents a type to the weaver. UnresolvedTypes are resolved in some World (a type repository). When a UnresolvedType is resolved it turns into a ResolvedType which may be a primitive type, or a ReferenceType. ReferenceTypes may refer to simple, generic, parameterized or type-variable based reference types. A ReferenceType is backed by a delegate that provides information about the type based on some repository (for example an Eclipse based delegate, a bytecode based delegate or a reflection based delegate).

Every UnresolvedType has a signature, the unique key for the type in the world.


Nested Class Summary
static class UnresolvedType.TypeKind
           
 
Field Summary
static UnresolvedType ANNOTATION
           
static UnresolvedType[] ARRAY_WITH_JUST_OBJECT
           
static UnresolvedType AT_INHERITED
           
static UnresolvedType AT_RETENTION
           
static UnresolvedType AT_TARGET
           
static UnresolvedType BOOLEAN
           
static UnresolvedType BYTE
           
static UnresolvedType CHAR
           
static UnresolvedType CLONEABLE
           
static UnresolvedType DOUBLE
           
static UnresolvedType ENUM
           
static UnresolvedType ERROR
           
static UnresolvedType FLOAT
           
static UnresolvedType INT
           
static UnresolvedType JAVA_LANG_ANNOTATION
           
static UnresolvedType JAVA_LANG_CLASS_ARRAY
           
static UnresolvedType JAVA_LANG_REFLECT_CONSTRUCTOR
           
static UnresolvedType JAVA_LANG_REFLECT_FIELD
           
static UnresolvedType JAVA_LANG_REFLECT_METHOD
           
static UnresolvedType JL_CLASS
           
static UnresolvedType JL_EXCEPTION
           
static UnresolvedType JL_STRING
           
static UnresolvedType JOINPOINT_ENCLOSINGSTATICPART
           
static UnresolvedType JOINPOINT_STATICPART
           
static UnresolvedType LONG
           
static java.lang.String MISSING_NAME
           
static UnresolvedType[] NONE
           
static UnresolvedType OBJECT
           
static UnresolvedType OBJECTARRAY
           
static UnresolvedType RUNTIME_EXCEPTION
           
static UnresolvedType SERIALIZABLE
           
static UnresolvedType SHORT
           
protected  java.lang.String signature
           
protected  java.lang.String signatureErasure
          The erasure of the signature.
static UnresolvedType SOMETHING
           
static UnresolvedType SUPPRESS_AJ_WARNINGS
           
static UnresolvedType THROWABLE
           
protected  UnresolvedType.TypeKind typeKind
           
protected  UnresolvedType[] typeParameters
          Iff isParameterized(), then these are the type parameters
protected  TypeVariable[] typeVariables
          Iff isGeneric(), then these are the type variables declared on the type Iff isParameterized(), then these are the type variables bound as parameters in the type
static UnresolvedType VOID
           
 
Constructor Summary
protected UnresolvedType(java.lang.String signature)
           
protected UnresolvedType(java.lang.String signature, java.lang.String signatureErasure)
           
  UnresolvedType(java.lang.String signature, java.lang.String signatureErasure, UnresolvedType[] typeParams)
           
 
Method Summary
static UnresolvedType[] add(UnresolvedType[] types, UnresolvedType end)
          Creates a new type array with a fresh type appended to the end.
 boolean equals(java.lang.Object other)
          Equality is checked based on the underlying signature.
static UnresolvedType forGenericType(java.lang.String name, TypeVariable[] tvbs, java.lang.String genericSig)
           
static UnresolvedType forGenericTypeSignature(java.lang.String sig, java.lang.String declaredGenericSig)
           
static UnresolvedType forGenericTypeVariables(java.lang.String sig, TypeVariable[] tVars)
           
static UnresolvedType forName(java.lang.String name)
          NOTE: Use forSignature() if you can, it'll be cheaper ! Constructs a UnresolvedType for a java language type name.
static UnresolvedType[] forNames(java.lang.String[] names)
          Constructs a UnresolvedType for each java language type name in an incoming array.
static UnresolvedType forPrimitiveType(java.lang.String signature)
           
static UnresolvedType forRawTypeName(java.lang.String name)
           
static UnresolvedType forSignature(java.lang.String signature)
          Constructs a Type for a JVM bytecode signature string.
static UnresolvedType[] forSignatures(java.lang.String[] sigs)
          Constructs a UnresolvedType for each JVM bytecode type signature in an incoming array.
 java.lang.String getBaseName()
           
 java.lang.String getClassName()
           
 UnresolvedType getComponentType()
          Returns a UnresolvedType object representing the component type of this array, or null if this type does not represent an array type.
 java.lang.String getErasureSignature()
          For parameterized types, return the signature for the raw type
 java.lang.String getName()
          Returns the name of this type in java language form (e.g.
 java.lang.String getNameAsIdentifier()
           
static java.lang.String[] getNames(UnresolvedType[] types)
          Returns an array of strings representing the java langauge names of an array of types.
 UnresolvedType getOutermostType()
          Returns a UnresolvedType object representing the effective outermost enclosing type for a name type.
 java.lang.String getPackageName()
           
 java.lang.String getPackageNameAsIdentifier()
           
 java.lang.String getRawName()
           
 UnresolvedType getRawType()
           
 java.lang.String getSignature()
          Returns the name of this type in JVM signature form.
 java.lang.String getSimpleBaseName()
           
 java.lang.String getSimpleName()
           
 int getSize()
          This is the size of this type as used in JVM.
 UnresolvedType.TypeKind getTypekind()
           
 UnresolvedType[] getTypeParameters()
           
 TypeVariable getTypeVariableNamed(java.lang.String name)
           
 TypeVariable[] getTypeVariables()
           
 int hashCode()
          Equality is checked based on the underlying signature, so the hash code of a particular type is the hash code of its signature string.
static UnresolvedType[] insert(UnresolvedType start, UnresolvedType[] types)
          Creates a new type array with a fresh type inserted at the beginning.
 boolean isArray()
           
 boolean isGenericType()
           
 boolean isGenericWildcard()
           
 boolean isParameterizedOrGenericType()
           
 boolean isParameterizedOrRawType()
           
 boolean isParameterizedType()
           
 boolean isPrimitiveType()
           
 boolean isRawType()
           
 boolean isSimpleType()
           
 boolean isTypeVariableReference()
           
 boolean isVoid()
           
static UnresolvedType makeArray(UnresolvedType base, int dims)
           
 boolean needsModifiableDelegate()
           
 UnresolvedType parameterize(java.util.Map<java.lang.String,UnresolvedType> typeBindings)
          Return a version of this parameterized type in which any type parameters that are type variable references are replaced by their matching type variable binding.
static UnresolvedType read(java.io.DataInputStream s)
          Read in an UnresolvedType - just read the signature and rebuild the UnresolvedType.
static UnresolvedType[] readArray(java.io.DataInputStream s)
           
 ResolvedType resolve(World world)
          Returns a resolved version of this type according to a particular world.
 void setNeedsModifiableDelegate(boolean b)
           
 java.lang.String toDebugString()
           
 java.lang.String toString()
          Returns a java language string representation of this type.
 java.lang.String toTraceString()
           
 void write(CompressingDataOutputStream s)
          Write out an UnresolvedType - the signature should be enough.
static void writeArray(UnresolvedType[] types, CompressingDataOutputStream stream)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final UnresolvedType[] NONE

OBJECT

public static final UnresolvedType OBJECT

OBJECTARRAY

public static final UnresolvedType OBJECTARRAY

CLONEABLE

public static final UnresolvedType CLONEABLE

SERIALIZABLE

public static final UnresolvedType SERIALIZABLE

THROWABLE

public static final UnresolvedType THROWABLE

RUNTIME_EXCEPTION

public static final UnresolvedType RUNTIME_EXCEPTION

ERROR

public static final UnresolvedType ERROR

AT_INHERITED

public static final UnresolvedType AT_INHERITED

AT_RETENTION

public static final UnresolvedType AT_RETENTION

ENUM

public static final UnresolvedType ENUM

ANNOTATION

public static final UnresolvedType ANNOTATION

JL_CLASS

public static final UnresolvedType JL_CLASS

JAVA_LANG_CLASS_ARRAY

public static final UnresolvedType JAVA_LANG_CLASS_ARRAY

JL_STRING

public static final UnresolvedType JL_STRING

JL_EXCEPTION

public static final UnresolvedType JL_EXCEPTION

JAVA_LANG_REFLECT_METHOD

public static final UnresolvedType JAVA_LANG_REFLECT_METHOD

JAVA_LANG_REFLECT_FIELD

public static final UnresolvedType JAVA_LANG_REFLECT_FIELD

JAVA_LANG_REFLECT_CONSTRUCTOR

public static final UnresolvedType JAVA_LANG_REFLECT_CONSTRUCTOR

JAVA_LANG_ANNOTATION

public static final UnresolvedType JAVA_LANG_ANNOTATION

SUPPRESS_AJ_WARNINGS

public static final UnresolvedType SUPPRESS_AJ_WARNINGS

AT_TARGET

public static final UnresolvedType AT_TARGET

SOMETHING

public static final UnresolvedType SOMETHING

ARRAY_WITH_JUST_OBJECT

public static final UnresolvedType[] ARRAY_WITH_JUST_OBJECT

JOINPOINT_STATICPART

public static final UnresolvedType JOINPOINT_STATICPART

JOINPOINT_ENCLOSINGSTATICPART

public static final UnresolvedType JOINPOINT_ENCLOSINGSTATICPART

BOOLEAN

public static final UnresolvedType BOOLEAN

BYTE

public static final UnresolvedType BYTE

CHAR

public static final UnresolvedType CHAR

DOUBLE

public static final UnresolvedType DOUBLE

FLOAT

public static final UnresolvedType FLOAT

INT

public static final UnresolvedType INT

LONG

public static final UnresolvedType LONG

SHORT

public static final UnresolvedType SHORT

VOID

public static final UnresolvedType VOID

MISSING_NAME

public static final java.lang.String MISSING_NAME
See Also:
Constant Field Values

typeKind

protected UnresolvedType.TypeKind typeKind

signature

protected java.lang.String signature

signatureErasure

protected java.lang.String signatureErasure
The erasure of the signature. Contains only the Java signature of the type with all supertype, superinterface, type variable, and parameter information removed.


typeParameters

protected UnresolvedType[] typeParameters
Iff isParameterized(), then these are the type parameters


typeVariables

protected TypeVariable[] typeVariables
Iff isGeneric(), then these are the type variables declared on the type Iff isParameterized(), then these are the type variables bound as parameters in the type

Constructor Detail

UnresolvedType

protected UnresolvedType(java.lang.String signature)

UnresolvedType

protected UnresolvedType(java.lang.String signature,
                         java.lang.String signatureErasure)

UnresolvedType

public UnresolvedType(java.lang.String signature,
                      java.lang.String signatureErasure,
                      UnresolvedType[] typeParams)
Method Detail

isPrimitiveType

public boolean isPrimitiveType()

isVoid

public boolean isVoid()

isSimpleType

public boolean isSimpleType()

isRawType

public boolean isRawType()

isGenericType

public boolean isGenericType()

isParameterizedType

public boolean isParameterizedType()

isParameterizedOrGenericType

public boolean isParameterizedOrGenericType()

isParameterizedOrRawType

public boolean isParameterizedOrRawType()

isTypeVariableReference

public boolean isTypeVariableReference()

isGenericWildcard

public boolean isGenericWildcard()

getTypekind

public UnresolvedType.TypeKind getTypekind()

isArray

public final boolean isArray()

equals

public boolean equals(java.lang.Object other)
Equality is checked based on the underlying signature.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Equality is checked based on the underlying signature, so the hash code of a particular type is the hash code of its signature string.

Overrides:
hashCode in class java.lang.Object

getSize

public int getSize()
This is the size of this type as used in JVM.


forName

public static UnresolvedType forName(java.lang.String name)
NOTE: Use forSignature() if you can, it'll be cheaper ! Constructs a UnresolvedType for a java language type name. For example:
   UnresolvedType.forName("java.lang.Thread[]")
   UnresolvedType.forName("int")
 
Types may equivalently be produced by this or by forSignature(String).
   UnresolvedType.forName("java.lang.Thread[]").equals(Type.forSignature("[Ljava/lang/Thread;")
   UnresolvedType.forName("int").equals(Type.forSignature("I"))
 

Parameters:
name - the java language type name in question.
Returns:
a type object representing that java language type.

forNames

public static UnresolvedType[] forNames(java.lang.String[] names)
Constructs a UnresolvedType for each java language type name in an incoming array.

Parameters:
names - an array of java language type names.
Returns:
an array of UnresolvedType objects.
See Also:
forName(String)

forGenericType

public static UnresolvedType forGenericType(java.lang.String name,
                                            TypeVariable[] tvbs,
                                            java.lang.String genericSig)

forGenericTypeSignature

public static UnresolvedType forGenericTypeSignature(java.lang.String sig,
                                                     java.lang.String declaredGenericSig)

forGenericTypeVariables

public static UnresolvedType forGenericTypeVariables(java.lang.String sig,
                                                     TypeVariable[] tVars)

forRawTypeName

public static UnresolvedType forRawTypeName(java.lang.String name)

forPrimitiveType

public static UnresolvedType forPrimitiveType(java.lang.String signature)

add

public static UnresolvedType[] add(UnresolvedType[] types,
                                   UnresolvedType end)
Creates a new type array with a fresh type appended to the end.

Parameters:
types - the left hand side of the new array
end - the right hand side of the new array

insert

public static UnresolvedType[] insert(UnresolvedType start,
                                      UnresolvedType[] types)
Creates a new type array with a fresh type inserted at the beginning.

Parameters:
start - the left hand side of the new array
types - the right hand side of the new array

forSignature

public static UnresolvedType forSignature(java.lang.String signature)
Constructs a Type for a JVM bytecode signature string. For example:
   UnresolvedType.forSignature("[Ljava/lang/Thread;")
   UnresolvedType.forSignature("I");
 
Types may equivalently be produced by this or by forName(String). This method should not be passed P signatures.
   UnresolvedType.forName("java.lang.Thread[]").equals(Type.forSignature("[Ljava/lang/Thread;")
   UnresolvedType.forName("int").equals(Type.forSignature("I"))
 

Parameters:
signature - the JVM bytecode signature string for the desired type.
Returns:
a type object represnting that JVM bytecode signature.

forSignatures

public static UnresolvedType[] forSignatures(java.lang.String[] sigs)
Constructs a UnresolvedType for each JVM bytecode type signature in an incoming array.

Parameters:
names - an array of JVM bytecode type signatures
Returns:
an array of UnresolvedType objects.
See Also:
forSignature(String)

getName

public java.lang.String getName()
Returns the name of this type in java language form (e.g. java.lang.Thread or boolean[]). This produces a more aesthetically pleasing string than Class.getName().

Returns:
the java language name of this type.

getSimpleName

public java.lang.String getSimpleName()

getRawName

public java.lang.String getRawName()

getBaseName

public java.lang.String getBaseName()

getSimpleBaseName

public java.lang.String getSimpleBaseName()

getNames

public static java.lang.String[] getNames(UnresolvedType[] types)
Returns an array of strings representing the java langauge names of an array of types.

Parameters:
types - an array of UnresolvedType objects
Returns:
an array of Strings fo the java language names of types.
See Also:
getName()

getSignature

public java.lang.String getSignature()
Returns the name of this type in JVM signature form. For all UnresolvedType t:
 UnresolvedType.forSignature(t.getSignature()).equals(t)
 
and for all String s where s is a lexically valid JVM type signature string:
 UnresolvedType.forSignature(s).getSignature().equals(s)
 

Returns:
the java JVM signature string for this type.

getErasureSignature

public java.lang.String getErasureSignature()
For parameterized types, return the signature for the raw type


needsModifiableDelegate

public boolean needsModifiableDelegate()

setNeedsModifiableDelegate

public void setNeedsModifiableDelegate(boolean b)

getRawType

public UnresolvedType getRawType()

getOutermostType

public UnresolvedType getOutermostType()
Returns a UnresolvedType object representing the effective outermost enclosing type for a name type. For all other types, this will return the type itself. The only guarantee is given in JLS 13.1 where code generated according to those rules will have type names that can be split apart in this way.

Returns:
the outermost enclosing UnresolvedType object or this.

getComponentType

public UnresolvedType getComponentType()
Returns a UnresolvedType object representing the component type of this array, or null if this type does not represent an array type.

Returns:
the component UnresolvedType object, or null.

toString

public java.lang.String toString()
Returns a java language string representation of this type.

Overrides:
toString in class java.lang.Object

toDebugString

public java.lang.String toDebugString()

resolve

public ResolvedType resolve(World world)
Returns a resolved version of this type according to a particular world.

Parameters:
world - the World within which to resolve.
Returns:
a resolved type representing this type in the appropriate world.

write

public final void write(CompressingDataOutputStream s)
                 throws java.io.IOException
Write out an UnresolvedType - the signature should be enough.

Throws:
java.io.IOException

read

public static UnresolvedType read(java.io.DataInputStream s)
                           throws java.io.IOException
Read in an UnresolvedType - just read the signature and rebuild the UnresolvedType.

Throws:
java.io.IOException

getNameAsIdentifier

public java.lang.String getNameAsIdentifier()

getPackageNameAsIdentifier

public java.lang.String getPackageNameAsIdentifier()

getTypeParameters

public UnresolvedType[] getTypeParameters()

getTypeVariables

public TypeVariable[] getTypeVariables()

getTypeVariableNamed

public TypeVariable getTypeVariableNamed(java.lang.String name)
Specified by:
getTypeVariableNamed in interface TypeVariableDeclaringElement

toTraceString

public java.lang.String toTraceString()
Specified by:
toTraceString in interface Traceable

parameterize

public UnresolvedType parameterize(java.util.Map<java.lang.String,UnresolvedType> typeBindings)
Return a version of this parameterized type in which any type parameters that are type variable references are replaced by their matching type variable binding.


getClassName

public java.lang.String getClassName()
Returns:
the class name (does not include the package name)

getPackageName

public java.lang.String getPackageName()
Returns:
the package name (no class name included)

writeArray

public static void writeArray(UnresolvedType[] types,
                              CompressingDataOutputStream stream)
                       throws java.io.IOException
Throws:
java.io.IOException

readArray

public static UnresolvedType[] readArray(java.io.DataInputStream s)
                                  throws java.io.IOException
Throws:
java.io.IOException

makeArray

public static UnresolvedType makeArray(UnresolvedType base,
                                       int dims)