APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.code

public abstract Class Type

extends AnnoConstruct
implements TypeMirror, PoolConstant
Class Inheritance
All Implemented Interfaces
com.sun.tools.javac.jvm.PoolConstant, javax.lang.model.type.TypeMirror, javax.lang.model.AnnotatedConstruct
Known Direct Subclasses
com.sun.tools.javac.code.Type.JCPrimitiveType, com.sun.tools.javac.code.Type.WildcardType, com.sun.tools.javac.code.Type.ClassType, com.sun.tools.javac.code.Type.ArrayType, com.sun.tools.javac.code.Type.MethodType, com.sun.tools.javac.code.Type.PackageType, com.sun.tools.javac.code.Type.ModuleType, com.sun.tools.javac.code.Type.TypeVar, com.sun.tools.javac.code.Type.DelegatedType, com.sun.tools.javac.code.Type.JCNoType, com.sun.tools.javac.code.Type.JCVoidType, com.sun.tools.javac.code.Type.BottomType, com.sun.tools.javac.comp.DeferredAttr.DeferredType, com.sun.tools.javac.jvm.ClassReader.ProxyType
Imports
java.lang.annotation.Annotation, java.util.ArrayDeque, .Collections, .EnumMap, .Map, .Optional, java.util.function.Function, .Predicate, javax.lang.model.type.*, com.sun.tools.javac.code.Symbol.*, .TypeMetadata.Annotations, .TypeMetadata.ConstantValue, .Types.TypeMapping, .Types.UniqueType, com.sun.tools.javac.comp.Infer.IncorporationAction, com.sun.tools.javac.jvm.ClassFile, .PoolConstant, com.sun.tools.javac.util.*, .DefinedBy.Api

This class represents Java types. The class itself defines the behavior of the following types:
base types (tags: BYTE, CHAR, SHORT, INT, LONG, FLOAT, DOUBLE, BOOLEAN),
type `void' (tag: VOID),
the bottom type (tag: BOT),
the missing type (tag: NONE).

The behavior of the following types is defined in subclasses, which are all static inner classes of this class:

class types (tag: CLASS, class: ClassType),
array types (tag: ARRAY, class: ArrayType),
method types (tag: METHOD, class: MethodType),
package types (tag: PACKAGE, class: PackageType),
type variables (tag: TYPEVAR, class: TypeVar),
type arguments (tag: WILDCARD, class: WildcardType),
generic method types (tag: FORALL, class: ForAll),
the error type (tag: ERROR, class: ErrorType).

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

See Also
TypeTag

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
pack-priv static class
public static class
Type.CapturedType

A captured type variable comes from wildcards which can have both upper and lower bound.

public static class
public abstract static class
public static class
public static class
public static class
Type.ForAll

The type of a generic method type.

public static class
public static class
Type.JCNoType

Represents NONE.

public static class
public static class
Type.JCVoidType

Represents VOID.

public static class
public static class
public static class
public abstract static class
Type.StructuralTypeMapping<S>

A subclass of Types.TypeMapping which applies a mapping recursively to the subterms of a given type expression.

public static class
public static class
Type.UndetVar

A class for inference variables, for use during method/diamond type inference.

public static class
public static interface
Type.Visitor<
the return type of the operation implemented by this visitor; use Void if no return type is needed.
R
,
the type of the second argument (the first being the type itself) of the operation implemented by this visitor; use Void if a second argument is not needed.
S
>

A visitor for types.

public static class

Field Summary

Modifier and TypeField and Description
protected final List<TypeMetadata>
metadata

Type metadata, Should be null for the default value.

public static boolean
moreInfo

If this switch is turned on, the names of type variables and anonymous classes are printed with hashcodes appended.

public static final Type.JCNoType
noType

Constant type: no type at all.

public static final Type.JCNoType
recoveryType

Constant type: special type to be used during recovery of deferred expressions.

private static final Types.TypeMapping<Void>
stripMetadata

Note

this visitor only needs to handle cases where 'contained' types can be annotated.

public static final Type.JCNoType
stuckType

Constant type: special type to be used for marking stuck trees.

public Symbol.TypeSymbol
tsym

The defining class / interface / package / type variable.

Constructor Summary

AccessConstructor and Description
public
Type(Symbol.TypeSymbol tsym, List<TypeMetadata> metadata)

Define a type given its tag, type symbol, and type annotations

Method Summary

Modifier and TypeMethod and Description
public <R, S> R
accept(Type.Visitor<R, S> v, S s)

public <R, P> R
accept(TypeVisitor<R, P> v, P p)

Implements javax.lang.model.type.TypeMirror.accept.

Applies a visitor to this type.

public Type
addMetadata(TypeMetadata md)

Create a new copy of this type but with the specified type metadata.

public List<Type>
allparams()

Return all parameters of this type and all its outer types in order outer (first) to inner (last).

public Type
protected void
protected void
public String
argtypes(boolean varargs)

public Symbol.TypeSymbol
public Type.MethodType
asMethodType()

The underlying method type of this type.

public Type
baseType()

If this is a constant type, return its underlying type.

public static List<Type>
baseTypes(List<Type> ts)

Return the base types of a list of types.

protected Type
cloneWithMetadata(List<TypeMetadata> metadata)

Create a new copy of this type but with the specified TypeMetadata.

public void
complete()

Complete loading all classes in this type.

public Type
constType(Object constValue)

Define a constant type, of the same kind as this type and with given constant value

public Object

Returns:

the constant value attribute of this type
constValue
()

The constant value of this type, null if this type does not have a constant value attribute.

public boolean
contains(Type t)

Does this type contain occurrences of type t?

public static boolean
public boolean
containsAny(List<Type> ts)

Does this type contain an occurrence of some type in 'ts'?

public static boolean
public Type
dropMetadata(Class<? extends TypeMetadata> metadataClass)

Create a new copy of this type but without the specified type metadata.

public boolean
equals(Object t)

Overrides java.lang.Object.equals.

Implements javax.lang.model.type.TypeMirror.equals.

Override this method with care.

public boolean
public static List<Type>
public List<Attribute.TypeCompound>
public Type
public TypeKind
getKind()

Implements javax.lang.model.type.TypeMirror.getKind.

Returns the kind of this type.

public Type
public List<TypeMetadata>
getMetadata()

Get all the type metadata associated with this type.

public <M extends TypeMetadata> M
getMetadata(Class<M> metadataClass)

Get the type metadata of the given kind associated with this type (if any).

public <M extends TypeMetadata, Z> Z
getMetadata(Class<M> metadataClass, Function<M, Z> metadataFunc, Z defaultValue)

Get the type metadata of the given kind associated with this type (if any), and apply the provided mapping function.

public Type
getModelType()

Get the representation of this type used for modelling purposes.

public static List<Type>
public Type
getOriginalType()

For ErrorType, returns the original type, otherwise returns the type itself.

public List<Type>
public Type
public Type
public abstract TypeTag

Returns:

the value of the current type tag.
getTag
()

Returns the current type tag.

public List<Type>
public List<Type>
getTypeArguments()

Access methods.

public Type
public int
public boolean

Returns:

true if tag is equal to the current type tag.
hasTag
(TypeTag tag)

Checks if the current type tag is equal to the given tag.

public boolean
public boolean
isCompound()

A compound type is a special class type whose supertypes are used to store a list of component types.

public boolean
isErroneous()

Does this type contain "error" elements?

public static boolean
public boolean
public boolean
isFalse()

Is this a constant type whose value is false?

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
isParameterized()

Is this type parameterized?

public boolean
public boolean
public boolean
public boolean
isRaw()

Is this type a raw type?

public boolean
public boolean
public boolean
isTrue()

Is this a constant type whose value is true?

public boolean
public boolean
public boolean
public <Z> Type
map(Types.TypeMapping<Z> mapping, Z arg)

map a type function over all immediate descendants of this type

public <Z> Type
map(Types.TypeMapping<Z> mapping)

map a type function over all immediate descendants of this type (no arg version)

protected boolean
needsStripping()

Does this type require annotation stripping for API clients?

public Object
poolKey(Types types)

Overrides default com.sun.tools.javac.jvm.PoolConstant.poolKey.

The constant pool entry key.

public int
poolTag()

Implements com.sun.tools.javac.jvm.PoolConstant.poolTag.

The constant pool entry tag.

public Type
public String
stringValue()

The constant value of this type, converted to String

public Type
public Type
stripMetadataIfNeeded()

Strip all metadata associated with this type - this could return a new clone of the type.

public String
toString()

Overrides java.lang.Object.toString.

Implements javax.lang.model.type.TypeMirror.toString.

The Java source which this type represents.

public static String
toString(List<Type> ts)

The Java source which this type list represents.

protected Type
typeNoMetadata()

Returns the original version of this type, before metadata were added.

public Type
Inherited from com.sun.tools.javac.code.AnnoConstruct:
getAnnotationgetAnnotationsByTypegetAttributegetInheritedAnnotations