Class UnresolvedType

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

public class UnresolvedType extends 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.

  • Field Details

    • 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
    • AJC_PRIVILEGED

      public static final UnresolvedType AJC_PRIVILEGED
    • PROCEEDING_JOINPOINT

      public static final UnresolvedType PROCEEDING_JOINPOINT
    • 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 String MISSING_NAME
      See Also:
      Constant Field Values
    • typeKind

      protected UnresolvedType.TypeKind typeKind
    • signature

      protected String signature
    • signatureErasure

      protected 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 Details

    • UnresolvedType

      protected UnresolvedType(String signature)
    • UnresolvedType

      protected UnresolvedType(String signature, String signatureErasure)
    • UnresolvedType

      public UnresolvedType(String signature, String signatureErasure, UnresolvedType[] typeParams)
  • Method Details

    • 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(Object other)
      Equality is checked based on the underlying signature.
      Overrides:
      equals in class 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 Object
    • getSize

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

      public static UnresolvedType forName(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(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(String name, TypeVariable[] tvbs, String genericSig)
    • forGenericTypeSignature

      public static UnresolvedType forGenericTypeSignature(String sig, String declaredGenericSig)
    • forGenericTypeVariables

      public static UnresolvedType forGenericTypeVariables(String sig, TypeVariable[] tVars)
    • forRawTypeName

      public static UnresolvedType forRawTypeName(String name)
    • forPrimitiveType

      public static UnresolvedType forPrimitiveType(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(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(String[] sigs)
      Constructs a UnresolvedType for each JVM bytecode type signature in an incoming array.
      Parameters:
      sigs - an array of JVM bytecode type signatures
      Returns:
      an array of UnresolvedType objects.
      See Also:
      forSignature(String)
    • getName

      public 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 String getSimpleName()
    • getRawName

      public String getRawName()
    • getBaseName

      public String getBaseName()
    • getSimpleBaseName

      public String getSimpleBaseName()
    • getNames

      public static 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 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 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 String toString()
      Returns a java language string representation of this type.
      Overrides:
      toString in class Object
    • toDebugString

      public 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 IOException
      Write out an UnresolvedType - the signature should be enough.
      Throws:
      IOException
    • read

      public static UnresolvedType read(DataInputStream s) throws IOException
      Read in an UnresolvedType - just read the signature and rebuild the UnresolvedType.
      Throws:
      IOException
    • getNameAsIdentifier

      public String getNameAsIdentifier()
    • getPackageNameAsIdentifier

      public String getPackageNameAsIdentifier()
    • getTypeParameters

      public UnresolvedType[] getTypeParameters()
    • getTypeVariables

      public TypeVariable[] getTypeVariables()
    • getTypeVariableNamed

      public TypeVariable getTypeVariableNamed(String name)
      Specified by:
      getTypeVariableNamed in interface TypeVariableDeclaringElement
    • toTraceString

      public String toTraceString()
      Specified by:
      toTraceString in interface Traceable
    • parameterize

      public UnresolvedType parameterize(Map<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 String getClassName()
      Returns:
      the class name (does not include the package name)
    • getPackageName

      public String getPackageName()
      Returns:
      the package name (no class name included)
    • writeArray

      public static void writeArray(UnresolvedType[] types, CompressingDataOutputStream stream) throws IOException
      Throws:
      IOException
    • readArray

      public static UnresolvedType[] readArray(DataInputStream s) throws IOException
      Throws:
      IOException
    • makeArray

      public static UnresolvedType makeArray(UnresolvedType base, int dims)