JML

org.multijava.mjc
Class CClassType

java.lang.Object
  extended byorg.multijava.util.Utils
      extended byorg.multijava.mjc.CType
          extended byorg.multijava.mjc.CClassType
All Implemented Interfaces:
Cloneable, Comparable, Constants, Constants, CTypeSignatureAppender
Direct Known Subclasses:
CArrayType, CClassNameType, CErasedClassType, CNullType, CTypeVariable, CWildcardType

public abstract class CClassType
extends CType
implements Cloneable

This class represents a class type in the type structure.

See Also:
CType

Nested Class Summary
 
Nested classes inherited from class org.multijava.mjc.CType
CType.MethodSignature, CType.MethodSignatureParser, CType.StringBuffers, CType.TupleCollection
 
Field Summary
protected  CClassType[][] arguments
           
private static CClass BAC_CLASS
           
private  String cachedString
           
private  CClass clazz
           
static CClassType[] EMPTY
           
static CClassType[][] EMPTY_ARG
           
protected  int index
           
protected  CUniverse universe
          Stores the universe modifier that is attached with this class type.
 
Fields inherited from class org.multijava.mjc.CType
instance, isMethodTypeVariable, isTypeVariable, type
 
Fields inherited from class org.multijava.util.Utils
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO
 
Fields inherited from interface org.multijava.mjc.Constants
ACC_MODIFIER_FLAGS_MASK, ACC_NON_NULL, ACC_NON_NULL_BY_DEFAULT, ACC_NULLABLE, ACC_NULLABLE_BY_DEFAULT, ACC_PURE, ACCESS_FLAG_ARRAY, ACCESS_FLAG_NAMES, AMID_JAVA_MATH, AMID_MAX, AMID_SAFE_MATH, CMP_VERSION, IMPLICITLY_NON_NULL, JAV_ASSERTION_ERROR, JAV_CLASS, JAV_CLASSLOADER, JAV_CLASSNOTFOUND_EXCEPTION, JAV_CLONE, JAV_CLONEABLE, JAV_CONSTRUCTOR, JAV_ERROR, JAV_EXCEPTION, JAV_INIT, JAV_LENGTH, JAV_NAME_SEPARATOR, JAV_NOCLASSDEFFOUND_ERROR, JAV_OBJECT, JAV_OUTER_THIS, JAV_RMJ_RUNTIME_EXCEPTION, JAV_RUNTIME, JAV_RUNTIME_EXCEPTION, JAV_SERIALIZABLE, JAV_STATIC_INIT, JAV_STRING, JAV_STRINGBUFFER, JAV_SUPER, JAV_THIS, JAV_THROWABLE, MJ_ANCHOR, NULLITY_MODS, OPE_BAND, OPE_BNOT, OPE_BOR, OPE_BSR, OPE_BXOR, OPE_EQ, OPE_GE, OPE_GT, OPE_LAND, OPE_LE, OPE_LNOT, OPE_LOR, OPE_LT, OPE_MINUS, OPE_NE, OPE_PERCENT, OPE_PLUS, OPE_POSTDEC, OPE_POSTINC, OPE_PREDEC, OPE_PREINC, OPE_SIMPLE, OPE_SL, OPE_SLASH, OPE_SR, OPE_STAR, TID_ARRAY, TID_BOOLEAN, TID_BYTE, TID_CHAR, TID_CLASS, TID_DOUBLE, TID_FLOAT, TID_INT, TID_LONG, TID_MAX, TID_SHORT, TID_VOID, UNIV_ARRAY_TMP, UNIV_TMP
 
Fields inherited from interface org.multijava.util.classfile.Constants
ACC_ABSTRACT, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VOLATILE, ATT_ANCHOR, ATT_BRIDGE, ATT_CODE, ATT_CONSTANTVALUE, ATT_DEPRECATED, ATT_DISPATCHER, ATT_EXCEPTIONS, ATT_GENERIC, ATT_GENERIC_FUNCTIONS, ATT_INNERCLASSES, ATT_LINENUMBERTABLE, ATT_LOCALVARIABLETABLE, ATT_MM_BODY, ATT_REDIRECTOR, ATT_RMJ_GLUE, ATT_RMJ_SIGNATURE, ATT_RUNTIME_VISIBLE_ANNOTATIONS, ATT_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, ATT_SIGNATURE, ATT_SOURCEFILE, ATT_SYNTHETIC, ATT_UNIVERSE_FIELD, ATT_UNIVERSE_METHOD, ATT_UNIVERSE_VERSION, CST_CLASS, CST_DOUBLE, CST_FIELD, CST_FLOAT, CST_INTEGER, CST_INTERFACEMETHOD, CST_LONG, CST_METHOD, CST_NAMEANDTYPE, CST_STRING, CST_UTF8, ENV_DEBUG_MODE, ENV_USE_CACHE, JAVA_MAGIC, JAVA_MAJOR, JAVA_MINOR, MAX_CODE_PER_METHOD, opc_aaload, opc_aastore, opc_aconst_null, opc_aload, opc_aload_0, opc_aload_1, opc_aload_2, opc_aload_3, opc_anewarray, opc_areturn, opc_arraylength, opc_astore, opc_astore_0, opc_astore_1, opc_astore_2, opc_astore_3, opc_athrow, opc_baload, opc_bastore, opc_bipush, opc_caload, opc_castore, opc_checkcast, opc_d2f, opc_d2i, opc_d2l, opc_dadd, opc_daload, opc_dastore, opc_dcmpg, opc_dcmpl, opc_dconst_0, opc_dconst_1, opc_ddiv, opc_dload, opc_dload_0, opc_dload_1, opc_dload_2, opc_dload_3, opc_dmul, opc_dneg, opc_drem, opc_dreturn, opc_dstore, opc_dstore_0, opc_dstore_1, opc_dstore_2, opc_dstore_3, opc_dsub, opc_dup, opc_dup2, opc_dup2_x1, opc_dup2_x2, opc_dup_x1, opc_dup_x2, opc_f2d, opc_f2i, opc_f2l, opc_fadd, opc_faload, opc_fastore, opc_fcmpg, opc_fcmpl, opc_fconst_0, opc_fconst_1, opc_fconst_2, opc_fdiv, opc_fload, opc_fload_0, opc_fload_1, opc_fload_2, opc_fload_3, opc_fmul, opc_fneg, opc_frem, opc_freturn, opc_fstore, opc_fstore_0, opc_fstore_1, opc_fstore_2, opc_fstore_3, opc_fsub, opc_getfield, opc_getstatic, opc_goto, opc_goto_w, opc_i2b, opc_i2c, opc_i2d, opc_i2f, opc_i2l, opc_i2s, opc_iadd, opc_iaload, opc_iand, opc_iastore, opc_iconst_0, opc_iconst_1, opc_iconst_2, opc_iconst_3, opc_iconst_4, opc_iconst_5, opc_iconst_m1, opc_idiv, opc_if_acmpeq, opc_if_acmpne, opc_if_icmpeq, opc_if_icmpge, opc_if_icmpgt, opc_if_icmple, opc_if_icmplt, opc_if_icmpne, opc_ifeq, opc_ifge, opc_ifgt, opc_ifle, opc_iflt, opc_ifne, opc_ifnonnull, opc_ifnull, opc_iinc, opc_iload, opc_iload_0, opc_iload_1, opc_iload_2, opc_iload_3, opc_imul, opc_ineg, opc_instanceof, opc_invokeinterface, opc_invokespecial, opc_invokestatic, opc_invokevirtual, opc_ior, opc_irem, opc_ireturn, opc_ishl, opc_ishr, opc_istore, opc_istore_0, opc_istore_1, opc_istore_2, opc_istore_3, opc_isub, opc_iushr, opc_ixor, opc_jsr, opc_jsr_w, opc_l2d, opc_l2f, opc_l2i, opc_ladd, opc_laload, opc_land, opc_lastore, opc_lcmp, opc_lconst_0, opc_lconst_1, opc_ldc, opc_ldc2_w, opc_ldc_w, opc_ldiv, opc_lload, opc_lload_0, opc_lload_1, opc_lload_2, opc_lload_3, opc_lmul, opc_lneg, opc_lookupswitch, opc_lor, opc_lrem, opc_lreturn, opc_lshl, opc_lshr, opc_lstore, opc_lstore_0, opc_lstore_1, opc_lstore_2, opc_lstore_3, opc_lsub, opc_lushr, opc_lxor, opc_monitorenter, opc_monitorexit, opc_multianewarray, opc_new, opc_newarray, opc_nop, opc_pop, opc_pop2, opc_putfield, opc_putstatic, opc_ret, opc_return, opc_saload, opc_sastore, opc_sipush, opc_swap, opc_tableswitch, opc_wide, opc_xxxunusedxxx, POO_ASCII_CONSTANT, POO_CLASS_CONSTANT, POO_DOUBLE_CONSTANT, POO_FLOAT_CONSTANT, POO_INTEGER_CONSTANT, POO_LONG_CONSTANT, POO_NAT_CONSTANT, POO_REF_CONSTANT, POO_STRING_CONSTANT, TYP_ADDRESS, TYP_DOUBLE, TYP_FLOAT, TYP_INT, TYP_LONG, TYP_REFERENCE, TYP_VOID
 
Constructor Summary
protected CClassType()
          Construct a class type
  CClassType(CClass clazz)
          Construct a class type with the default universe.
  CClassType(CClass clazz, CUniverse univ)
          Construct a class type with a universe.
 
Method Summary
 void appendSignature(FastStringBuffer buff)
          Transforms this type to a string
 CClassType capture()
          Returns the type captured by a type argument.
 CType checkType(CContextType context)
          Checks that this type is valid, throwing an exception if it is not.
 Object clone()
          We need to allow cloning of CClassType and its subtypes, in order to be able to create a new CClassType with the correct universe modifier.
 boolean contains(CClassType type)
          Returns whether this type contains the given type as defined in JLS3 4.5.1.1.
 CClassType createSubstitutedType(CClass local, CClassType prefixType, CClassType[][] substitution)
           
private  boolean descendsFrom(CClassType maybeSuper)
          Returns whether this type descends from the given maybeSuper type.
 Collection directlyVisibleTypes()
          Returns the set of types (excluding non-reference types) that are directly visible from this type.
 boolean equals(Object other)
          Compares two objects for equality.
 boolean equals(Object other, boolean enableUniv)
          Compares two objects for equality.
 boolean equals(CType other, CClassType[] substitution)
           
 boolean equals(CType other, CClassType[] substitution, boolean enableUniv)
           
 CClassType[][] getAllArguments()
          return the arguments of this type
 CClassType[] getArguments()
           
private  CClass getCachedCClass()
          Get source class from cached info of all loaded classes in CTopLevel.
 CClass getCClass()
          Returns the class object associated with this type.
 CUniverse getCUniverse()
          Return the universe of this class type.
 String getCUniverseJMLString()
          Return the universe modifier as string, for output in JML specifications.
 String getCUniverseMJString()
          Returns the universe modifier as String, for output in source code parsed by MultiJava, i.e. the modifiers are written as is.
 String getCUniverseString()
          Return the universe modifier as string.
 CType getErasure()
           
 int getIndex()
           
 int getSize()
          Returns the size used in stack by value of this type
 byte getUniverseByteConstant()
          Return the universe byte constant for this class type.
static Collection getVisibleTypesFrom(Collection dirVisTypes)
          Returns the set of visible types by finding the reflexive, transitive closure of directlyVisibleTypes() on each type in the given collection.
 int hashCode()
          Calculates the hash code for this
 boolean hasUnboundedWildcardTypeArgumentsOnly()
          Returns true if and only if this is a parameterized type and all its type arguments are unbounded wildcards.
 boolean hasWildcardTypeArgument()
          Returns whether any of the type arguments of this type is a wildcard.
 String ident()
           
 boolean implicitlyCastTo(CType dest)
          implicitlyCastTo
 boolean isAlwaysAssignableTo(CType dest)
           
 boolean isAlwaysAssignableTo(CType dest, boolean inst)
          Is this type assignable to the given type by assignment type conversion [JLS2 5.2] [JLS2 5.1.4]
 boolean isAlwaysAssignableTo(CType dest, CClassType[] substitution)
           
 boolean isAlwaysAssignableToNoUniverses(CType dest, CClassType[] substitution)
          A version of the Assignable check without considering the Universe types.
 boolean isAssignableTo(CType dest)
           
 boolean isCastableTo(CType dest)
          Can this type be converted to the specified type by casting conversion (JLS 5.5) ?
protected  boolean isChecked()
          Returns true if this class type has been resolved to a CClass singleton.
 boolean isCheckedException()
          Returns true if this represents the type of a checked exception.
 boolean isClassType()
          Check if a type is a class type
 boolean isConcrete()
          Indicates whether this type is concrete.
 boolean isInterface()
          Check if a type is an interface
 boolean isLocalTo(CContextType context)
          Indicates whether this type is declared local to the given context.
 boolean isNestedType()
          Indicates whether this type is a nested type, i.e., a member type.
 boolean isParameterizedType()
          Returns whether this is a parameterized type (JLS3 4.5).
 boolean isRawTypeInvocationOf(CClass superClazz)
          Returns whether this type is a raw type invocation of the given superClazz.
private  boolean isRawTypeInvocationOfRec(CClass superClazz, CClassType type, boolean isRawType)
          Helper method which goes up the supertype hierarchy in order to find out whether the given type is a raw type invocation of the given superClazz.
private  boolean isRawTypeInvocationOfSuper(CClass superClazz, CClassType superType, boolean isRawType)
          Helper method which takes the step from a type to its supertype in order to find out whether the latter is a raw type invocation of the given superClazz.
 boolean isReference()
          Check if a type is a reference
 boolean isValidTypeArgumentFor(CTypeVariable typeVariable, CClassType[] substitution)
          Returns whether this type is a valid type argument for the given typeVariable.
 boolean needsUncheckedConversion(CType dest)
          Returns whether unchecked conversion (JLS3 5.1.9) is required in order to convert from this type to the given type dest.
 boolean needsUncheckedConversion(CType dest, CClassType[] substitution)
          Returns whether unchecked conversion (JLS3 5.1.9) is required in order to convert from this type to the given type dest, eventually using the given generic substitution.
 String originalQualifiedName()
           
 void plantDispatchTest(CodeSequence code, CodeLabel nextInstruction)
           
 String printArgs()
           
 String qualifiedName()
           
 void resolveValueType(CExpressionContextType context)
          Compute the value of a specializer expression used to dispatch on a compile-time constant.
 void setAllArguments(CClassType[][] arguments)
           
protected  void setClass(CClass clazz)
          Sets the CClass singleton that goes with this class type.
 void setCUniverse(CUniverse univ)
          Set the universe of this class type.
 void setIndex(int i)
          set the type variable to the given index
 String toString()
          Transforms this type to a string also assignable loadedClassInfo, thisClassInfo; ensures \not_modified(loadedClassInfo);
 String toVerboseString()
          Return the universe modifier plus the class type as string.
 
Methods inherited from class org.multijava.mjc.CType
appendGenericSignature, changesByErasure, checked, compareTo, genGenericMethodSignature, genGenericMethodSignature, genGenericMethodSignatureHelper, genMethodSignature, genMultimethodSignature, getCapture, getErasure, getGenericSignature, getIdent, getLoadOpcode, getReturnOpcode, getSignature, getStoreOpcode, getTypeID, getValue, isArrayType, isBoolean, isCapture, isClassTypeVariable, isCodedAsInt, isFloatingPoint, isGenericType, isMethodTypeVariable, isNumeric, isOrdinal, isPrimitive, isRawType, isReifiableType, isTypeVariable, isValueType, isVoid, isWildcard, parseGenericTypeSignature, parseGenericTypeSignature, parseMethodSignature, parseMethodSignature, parseSignature, parseSignature, setMethodTypeVariable, setTypeVariable, specializerSymbol, tupleToString, tupleToString
 
Methods inherited from class org.multijava.util.Utils
assertTrue, assertTrue, combineArrays, escapeString, escapeString, fail, fail, getFilePath, hasFlag, hasOtherFlags, parsePathParts, relativePathTo, splitQualifiedName, splitQualifiedName, stripJavaModifiers, stripNonJavaModifiers, stripPrivateModifier, unescapeString, vectorToArray, vectorToIntArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final CClassType[] EMPTY

EMPTY_ARG

public static final CClassType[][] EMPTY_ARG

BAC_CLASS

private static final CClass BAC_CLASS

clazz

private CClass clazz

index

protected int index

arguments

protected CClassType[][] arguments

universe

protected CUniverse universe
Stores the universe modifier that is attached with this class type. By WMD.


cachedString

private String cachedString
Constructor Detail

CClassType

protected CClassType()
Construct a class type


CClassType

public CClassType(CClass clazz)
Construct a class type with the default universe. By WMD (universe part).


CClassType

public CClassType(CClass clazz,
                  CUniverse univ)
Construct a class type with a universe. By WMD (universe part).

Parameters:
clazz - the class that will represent this type
Method Detail

isChecked

protected boolean isChecked()
Returns true if this class type has been resolved to a CClass singleton.

Returns:
true if this class type has been resolved

getIndex

public int getIndex()

setIndex

public void setIndex(int i)
set the type variable to the given index


setClass

protected void setClass(CClass clazz)
Sets the CClass singleton that goes with this class type.

Parameters:
clazz - the CClass singleton that goes with this class type

setCUniverse

public void setCUniverse(CUniverse univ)
Set the universe of this class type. By WMD.

Parameters:
univ - The new universe modifier. If the parameter is null, then the peer modifier is used.

clone

public Object clone()
             throws CloneNotSupportedException
We need to allow cloning of CClassType and its subtypes, in order to be able to create a new CClassType with the correct universe modifier. By WMD.

Overrides:
clone in class Object
Throws:
CloneNotSupportedException

equals

public boolean equals(Object other)
Compares two objects for equality.

Overrides:
equals in class CType
Parameters:
other - the object to compare with
Returns:
true iff other is a CType object representing the same Java type as this represents WMD: Forward the call to the universe enabled version below.

equals

public boolean equals(Object other,
                      boolean enableUniv)
Compares two objects for equality.

Overrides:
equals in class CType
Parameters:
other - the object to compare with
enableUniv - whether to also check the universe part this is needed sometimes to allow relaxed checks
Returns:
true iff other is a CType object representing the same Java type as this represents

equals

public boolean equals(CType other,
                      CClassType[] substitution)
Overrides:
equals in class CType

equals

public boolean equals(CType other,
                      CClassType[] substitution,
                      boolean enableUniv)
Overrides:
equals in class CType

hashCode

public int hashCode()
Calculates the hash code for this

Overrides:
hashCode in class Object
Returns:
the hash code for this, which is the same as the hash code for the corresponding CClass singleton

 also
 assignable loadedClassInfo, thisClassInfo;
 

toString

public String toString()
Transforms this type to a string

 also
 assignable loadedClassInfo, thisClassInfo;
 ensures \not_modified(loadedClassInfo);
 

Specified by:
toString in class CType

printArgs

public String printArgs()

originalQualifiedName

public String originalQualifiedName()

toVerboseString

public String toVerboseString()
Return the universe modifier plus the class type as string. By WMD.

Overrides:
toVerboseString in class CType

getCUniverseString

public String getCUniverseString()
Return the universe modifier as string. Always returns a Universe string, even if the Universe checks are turned off! By WMD.


getCUniverseJMLString

public String getCUniverseJMLString()
Return the universe modifier as string, for output in JML specifications. The only difference is that implicit annotations are escaped with a backslash. By AHS, WMD.


getCUniverseMJString

public String getCUniverseMJString()
Returns the universe modifier as String, for output in source code parsed by MultiJava, i.e. the modifiers are written as is. By RZU, WMD.


isNestedType

public boolean isNestedType()
Indicates whether this type is a nested type, i.e., a member type.

Overrides:
isNestedType in class CType

appendSignature

public void appendSignature(FastStringBuffer buff)
Transforms this type to a string

Specified by:
appendSignature in interface CTypeSignatureAppender

ident

public String ident()
Returns:
the short name of this class

 assignable loadedClassInfo, thisClassInfo;
 

qualifiedName

public String qualifiedName()
Returns:
the qualified name of this class.

getSize

public int getSize()
Returns the size used in stack by value of this type


isReference

public boolean isReference()
Check if a type is a reference

Overrides:
isReference in class CType
Returns:
is it a type that accept null value

isClassType

public boolean isClassType()
Check if a type is a class type

Overrides:
isClassType in class CType
Returns:
is it a subtype of ClassType ?

isInterface

public boolean isInterface()
Check if a type is an interface

Overrides:
isInterface in class CType
Returns:
is it a class type representing an interface ?

 also
 assignable loadedClassInfo, thisClassInfo;
 

isConcrete

public boolean isConcrete()
Indicates whether this type is concrete. All types are concrete except abstract class types and interface types.

Overrides:
isConcrete in class CType
Returns:
whether this type is concrete

 also
 assignable loadedClassInfo, thisClassInfo;
 

isLocalTo

public boolean isLocalTo(CContextType context)
Indicates whether this type is declared local to the given context. Can only be true of reference types.

Overrides:
isLocalTo in class CType
Parameters:
context - the context in which to check
Returns:
whether this type is declared local to the given context.

 also
 assignable loadedClassInfo, thisClassInfo;
 

getCClass

public CClass getCClass()
Returns the class object associated with this type.

Overrides:
getCClass in class CType
Returns:
the class object associated with this type

getCUniverse

public CUniverse getCUniverse()
Return the universe of this class type. By WMD.


getUniverseByteConstant

public byte getUniverseByteConstant()
Return the universe byte constant for this class type. By AHS.


createSubstitutedType

public CClassType createSubstitutedType(CClass local,
                                        CClassType prefixType,
                                        CClassType[][] substitution)

checkType

public CType checkType(CContextType context)
                throws UnpositionedError
Checks that this type is valid, throwing an exception if it is not. For class types this check resolves type names into their fully qualified versions and sets the class parameter so that getCClass returns the appropriate singleton.

Parameters:
context - the context in which this type was declared, may be null
Throws:
UnpositionedError - this unpositioned error should be positioned by the calling node of the AST, typically by calling the addPosition method of UnpositionedError

 //also
 //assignable loadedClassInfo, thisClassInfo;
 

resolveValueType

public void resolveValueType(CExpressionContextType context)
                      throws PositionedError
Compute the value of a specializer expression used to dispatch on a compile-time constant.

Parameters:
context - the context in which this class declaration appears
Throws:
PositionedError - if the check fails

descendsFrom

private boolean descendsFrom(CClassType maybeSuper)
Returns whether this type descends from the given maybeSuper type.

Parameters:
maybeSuper - The potential supertype of this type.
Returns:
Whether this type is a subtype of the given maybeSuper.

isAlwaysAssignableTo

public boolean isAlwaysAssignableTo(CType dest,
                                    boolean inst)
Is this type assignable to the given type by assignment type conversion [JLS2 5.2] [JLS2 5.1.4]

Overrides:
isAlwaysAssignableTo in class CType
Parameters:
dest - the destination type
Returns:
true iff assignment is valid

 //also
   //assignable_redundantly thisClassInfo;
 
WMD: In addition the universes have to be assignable, too.

isAlwaysAssignableTo

public boolean isAlwaysAssignableTo(CType dest,
                                    CClassType[] substitution)
Overrides:
isAlwaysAssignableTo in class CType

isAlwaysAssignableToNoUniverses

public boolean isAlwaysAssignableToNoUniverses(CType dest,
                                               CClassType[] substitution)
A version of the Assignable check without considering the Universe types. This is needed to determine e.g. the correct method to invoke, where we do not look at the Universe types. There were already many versions of "isAlwaysAssignableTo" and also with boolean flags; therefore I decided to change the name. By WMD.


isAlwaysAssignableTo

public boolean isAlwaysAssignableTo(CType dest)
Description copied from class: CType
Is this type assignable to the given type by assignment type conversion [JLS2 5.2].


isValidTypeArgumentFor

public boolean isValidTypeArgumentFor(CTypeVariable typeVariable,
                                      CClassType[] substitution)
Returns whether this type is a valid type argument for the given typeVariable.

Parameters:
typeVariable - The type variable for which this type is the actual type parameter.
substitution - All the actual type arguments of the parametrized type.
Returns:
Whether this type is a valid type argument for the given typeVariable.

isAssignableTo

public boolean isAssignableTo(CType dest)
Overrides:
isAssignableTo in class CType

needsUncheckedConversion

public boolean needsUncheckedConversion(CType dest)
Description copied from class: CType
Returns whether unchecked conversion (JLS3 5.1.9) is required in order to convert from this type to the given type dest.

Overrides:
needsUncheckedConversion in class CType

needsUncheckedConversion

public boolean needsUncheckedConversion(CType dest,
                                        CClassType[] substitution)
Description copied from class: CType
Returns whether unchecked conversion (JLS3 5.1.9) is required in order to convert from this type to the given type dest, eventually using the given generic substitution.

Overrides:
needsUncheckedConversion in class CType

isRawTypeInvocationOf

public boolean isRawTypeInvocationOf(CClass superClazz)
Returns whether this type is a raw type invocation of the given superClazz.

Parameters:
superClazz - The target super class.
Returns:
Whether this type is a raw type invocation of the given superClazz.

isRawTypeInvocationOfRec

private boolean isRawTypeInvocationOfRec(CClass superClazz,
                                         CClassType type,
                                         boolean isRawType)
Helper method which goes up the supertype hierarchy in order to find out whether the given type is a raw type invocation of the given superClazz.

Parameters:
superClazz - The target super class.
type - The current type in the supertype hierarchy.
isRawType - Whether type is a raw type.
Returns:
Whether type is a raw type invocation of the given superClazz.

isRawTypeInvocationOfSuper

private boolean isRawTypeInvocationOfSuper(CClass superClazz,
                                           CClassType superType,
                                           boolean isRawType)
Helper method which takes the step from a type to its supertype in order to find out whether the latter is a raw type invocation of the given superClazz.

Parameters:
superClazz - The target super class.
superType - The supertype to which to move.
isRawType - Whether the current type is a raw type.
Returns:
Whether the given superType is a raw type invocation of superClazz.

contains

public boolean contains(CClassType type)
Returns whether this type contains the given type as defined in JLS3 4.5.1.1. This test is used when checking for the subtype relationship between two parametrized types. In order for a parametrized type to be a subtype of another, all type arguments of the former must be contained by the corresponding type arguments of the latter.

Parameters:
type - The type possibly contained by this type.
Returns:
Whether this type contains the given type.

getErasure

public CType getErasure()
Overrides:
getErasure in class CType

capture

public CClassType capture()
Returns the type captured by a type argument. Only wildcards have a capture which differs from the type itself as described in JLS3 5.1.10.

Returns:
The capture of this type. Is never null.

isParameterizedType

public boolean isParameterizedType()
Returns whether this is a parameterized type (JLS3 4.5).

Returns:
Whether this is a parameterized type.

hasWildcardTypeArgument

public boolean hasWildcardTypeArgument()
Returns whether any of the type arguments of this type is a wildcard.

Returns:
Whether any of the type arguments of this type is a wildcard.

hasUnboundedWildcardTypeArgumentsOnly

public boolean hasUnboundedWildcardTypeArgumentsOnly()
Returns true if and only if this is a parameterized type and all its type arguments are unbounded wildcards.

Returns:
Whether this is a parameterized type and all its type arguments are unbounded wildcards.

isCastableTo

public boolean isCastableTo(CType dest)
Can this type be converted to the specified type by casting conversion (JLS 5.5) ?

Parameters:
dest - the destination type
Returns:
true iff the casting conversion is valid

 also
 assignable loadedClassInfo, thisClassInfo;
 
WMD: added additional conditions for the universe modifiers

implicitlyCastTo

public boolean implicitlyCastTo(CType dest)
implicitlyCastTo

Overrides:
implicitlyCastTo in class CType
Parameters:
dest - the expression type to cast to
Returns:
cast is valid ?

isCheckedException

public boolean isCheckedException()
Returns true if this represents the type of a checked exception.

Overrides:
isCheckedException in class CType

directlyVisibleTypes

public Collection directlyVisibleTypes()
Returns the set of types (excluding non-reference types) that are directly visible from this type.

 assignable loadedClassInfo, thisClassInfo;
 


getVisibleTypesFrom

public static Collection getVisibleTypesFrom(Collection dirVisTypes)
Returns the set of visible types by finding the reflexive, transitive closure of directlyVisibleTypes() on each type in the given collection. Requires the every member of the given collection is an instance of CType.

Parameters:
dirVisTypes - an initial collection of directly visible types

 requires (\forall Object o; dirVisTypes.contains(o);
				   o instanceof CType);
 

plantDispatchTest

public void plantDispatchTest(CodeSequence code,
                              CodeLabel nextInstruction)
Overrides:
plantDispatchTest in class CType

getCachedCClass

private CClass getCachedCClass()
Get source class from cached info of all loaded classes in CTopLevel.

 assignable loadedClassInfo, thisClassInfo, cachedString, clazz;
 


getArguments

public CClassType[] getArguments()
Overrides:
getArguments in class CType

getAllArguments

public CClassType[][] getAllArguments()
return the arguments of this type

Overrides:
getAllArguments in class CType

setAllArguments

public void setAllArguments(CClassType[][] arguments)

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.