/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/** This class represents Java types. The class itself defines the behavior of
* the following types:
* <pre>
* 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).
* </pre>
* <p>The behavior of the following types is defined in subclasses, which are
* all static inner classes of this class:
* <pre>
* 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),
* polymorphic types (tag: FORALL, class: ForAll),
* the error type (tag: ERROR, class: ErrorType).
* </pre>
*
* <p><b>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.</b>
*
* @see TypeTags
*/
/** Constant type: no type at all. */
/** If this switch is turned on, the names of type variables
* and anonymous classes are printed with hashcodes appended.
*/
public static boolean moreInfo = false;
/** The tag of this type.
*
* @see TypeTags
*/
public int tag;
/** The defining class / interface / package / type variable
*/
/**
* The constant value of this type, null if this type does not
* have a constant value attribute. Only primitive types and
* strings (ClassType) can have a constant value attribute.
* @return the constant value attribute of this type
*/
return null;
}
/**
* Get the representation of this type used for modelling purposes.
* By default, this is itself. For ErrorType, a different value
* may be provided,
*/
return this;
}
}
/** Define a type given its tag and type symbol
*/
}
/** An abstract class for mappings from types to types
*/
public static abstract class Mapping {
}
return name;
}
}
/** map a type function over all immediate descendants of this type
*/
return this;
}
/** map a type function over a list of types
*/
}
return ts;
}
/** Define a constant type, of the same kind as this type
* and with given constant value
*/
public Object constValue() {
return value;
}
}
};
}
/**
* If this is a constant type, return its underlying type.
* Otherwise, return the type itself.
*/
return this;
}
/** Return the base types of a list of types.
*/
}
return ts;
}
/** The Java source which this type represents.
*/
? "<none>"
return s;
}
/**
* The Java source which this type list represents. A List is
* represented as a comma-spearated listing of the elements in
* that list.
*/
return "";
} else {
}
}
/**
* The constant value of this type, converted to String
*/
else
}
/**
* This method is analogous to isSameType, but weaker, since we
* never complete classes. Where isSameType would complete a
* class, equals assumes that the two types are different.
*/
return super.equals(t);
}
public int hashCode() {
return super.hashCode();
}
/** Is this a constant type whose value is false?
*/
public boolean isFalse() {
return
constValue() != null &&
}
/** Is this a constant type whose value is true?
*/
public boolean isTrue() {
return
constValue() != null &&
}
}
} else {
}
}
/** Access methods.
*/
/** Navigation methods, these will work for classes, type variables,
* foralls, but will return null for arrays and methods.
*/
/** Return all parameters of this type and all its outer types in order
* outer (first) to inner (last).
*/
/** Does this type contain "error" elements?
*/
public boolean isErroneous() {
return false;
}
if (l.head.isErroneous()) return true;
return false;
}
/** Is this type parameterized?
* A class type is parameterized if it has some parameters.
* An array type is parameterized if its element type is parameterized.
* All other types are not parameterized.
*/
public boolean isParameterized() {
return false;
}
/** Is this type a raw type?
* A class type is a raw type if it misses some of its parameters.
* An array type is a raw type if its element type is raw.
* All other types are not raw.
* Type validation will ensure that the only raw types
* in a program are types that miss all their type variables.
*/
public boolean isRaw() {
return false;
}
public boolean isCompound() {
// Compound types can't have a completer. Calling
// flags() will complete the symbol causing the
// compiler to load classes unnecessarily. This led
// to regression 6180021.
}
public boolean isInterface() {
}
public boolean isFinal() {
}
public boolean isPrimitive() {
}
/**
* Does this type contain occurrences of type t?
*/
return t == this;
}
l = l.tail)
return false;
}
/** Does this type contain an occurrence of some type in 'ts'?
*/
if (this.contains(t)) return true;
return false;
}
if (t.containsAny(ts2)) return true;
return false;
}
}
}
}
public boolean isSuperBound() { return false; }
public boolean isExtendsBound() { return false; }
public boolean isUnbound() { return false; }
/** The underlying method type of this type.
*/
/** Complete loading all classes in this type.
*/
public void complete() {}
return tsym;
}
switch (tag) {
}
}
if (isPrimitive())
return v.visitPrimitive(this, p);
else
throw new AssertionError();
}
return v.visitWildcardType(this, s);
}
}
}
}
}
public boolean isSuperBound() {
}
public boolean isExtendsBound() {
}
public boolean isUnbound() {
}
//-System.err.println(this+".withTypeVar("+t+");");//DEBUG
if (bound == t)
return this;
return this;
}
boolean isPrintingBound = false;
StringBuilder s = new StringBuilder();
try {
isPrintingBound = true;
} finally {
isPrintingBound = false;
}
return s.toString();
}
//- System.err.println(" (" + this + ").map(" + f + ")");//DEBUG
if (t != null)
t = f.apply(t);
if (t == type)
return this;
else
}
return type;
else
return null;
}
return type;
else
return null;
}
}
return v.visitWildcard(this, p);
}
}
/** The enclosing type of this type. If this is the type of an inner
* class, outer_field refers to the type of its enclosing
* instance class, in all other cases it referes to noType.
*/
/** The type parameters of this type (to be set once class is loaded).
*/
/** A cache variable for the type parameters of this type,
* appended to all parameters of its enclosing class.
* @see #allparams
*/
/** The supertype of this class (to be set once class is loaded).
*/
/** The interfaces of this class (to be set once class is loaded).
*/
/** All the interfaces of this class, including missing ones.
*/
this.outer_field = outer;
this.typarams_field = typarams;
this.allparams_field = null;
this.supertype_field = null;
this.interfaces_field = null;
/*
// this can happen during error recovery
assert
outer.isParameterized() ?
typarams.length() == tsym.type.typarams().length() :
outer.isRaw() ?
typarams.length() == 0 :
true;
*/
}
return v.visitClassType(this, s);
}
public Object constValue() {
return value;
}
}
};
}
/** The Java source which this type represents.
*/
} else {
}
if (getTypeArguments().nonEmpty()) {
}
}
//where
s.append("&");
}
return s.toString();
String s;
} else {
}
if (moreInfo)
return s;
} else if (longform) {
} else {
}
}
if (typarams_field == null) {
complete();
if (typarams_field == null)
}
return typarams_field;
}
public boolean hasErasedSupertypes() {
return isRaw();
}
return outer_field;
}
outer_field = outer;
}
if (allparams_field == null) {
}
return allparams_field;
}
public boolean isErroneous() {
return
getEnclosingType().isErroneous() ||
isErroneous(getTypeArguments()) ||
}
public boolean isParameterized() {
// optimization, was: allparams().nonEmpty();
}
/** A cache for the rank. */
/** A class type is raw if it misses some
* of its type parameter sections.
* After validation, this is equivalent to:
* allparams.isEmpty() && tsym.type.allparams.nonEmpty();
*/
public boolean isRaw() {
return
}
}
return
elem == this
|| (isParameterized()
|| (isCompound()
}
public void complete() {
}
}
return v.visitDeclared(this, p);
}
}
}
public boolean hasErasedSupertypes() {
return true;
}
}
// a clone of a ClassType that knows about the alternatives of a union type.
}
}
}
}
return v.visitUnion(this, p);
}
}
super(ARRAY, arrayClass);
}
return v.visitArrayType(this, s);
}
return elemtype + "[]";
}
return
this == obj ||
}
public int hashCode() {
}
public boolean isVarargs() {
return false;
}
public boolean isErroneous() {
return elemtype.isErroneous();
}
public boolean isParameterized() {
return elemtype.isParameterized();
}
public boolean isRaw() {
}
public boolean isVarargs() {
return true;
}
};
}
}
}
public void complete() {
}
return elemtype;
}
}
return v.visitArray(this, p);
}
}
super(METHOD, methodClass);
}
return v.visitMethodType(this, s);
}
/** The Java source which this type represents.
*
* XXX 06/09/99 iris This isn't correct Java syntax, but it probably
* should be.
*/
}
if (this == obj)
return true;
if (!(obj instanceof MethodType))
return false;
return false;
}
return false;
}
public int hashCode() {
int h = METHOD;
}
public boolean isErroneous() {
return
isErroneous(argtypes) ||
}
}
}
public void complete() {
}
}
return null;
}
return TypeKind.EXECUTABLE;
}
return v.visitExecutable(this, p);
}
}
}
return v.visitPackageType(this, s);
}
}
}
return v.visitNoType(this, p);
}
}
/** The upper bound of this type variable; set from outside.
* Must be nonempty once it is set.
* For a bound, `bound' is the bound type itself.
* Multiple bounds are expressed as a single class type which has the
* individual bounds as superclass, respectively interfaces.
* The class type then has as `tsym' a compiler generated class `c',
* which has a flag COMPOUND and whose owner is the type variable
* itself. Furthermore, the erasure_field of the class
* points to the first class or interface bound.
*/
/** The lower bound of this type variable.
* TypeVars don't normally have a lower bound, so it is normally set
* to syms.botType.
* Subtypes, such as CapturedType, may provide a different value.
*/
}
}
return v.visitTypeVar(this, s);
}
return lower;
}
}
public boolean isCaptured() {
return false;
}
return v.visitTypeVariable(this, p);
}
}
/** A captured type variable comes from wildcards which can have
* both upper and lower bound. CapturedType extends TypeVar with
* a lower bound.
*/
}
return v.visitCapturedType(this, s);
}
public boolean isCaptured() {
return true;
}
return "capture#"
+ " of "
+ wildcard;
}
}
}
}
}
return v.visitForAll(this, s);
}
}
public boolean isErroneous() {
return qtype.isErroneous();
}
/**
* Replaces this ForAll's typevars with a set of concrete Java types
* and returns the instantiated generic type. Subclasses should override
* in order to check that the list of types is a valid instantiation
* of the ForAll's typevars.
*
* @param actuals list of actual types
* @param types types instance
* @return qtype where all occurrences of tvars are replaced
* by types in actuals
*/
}
/**
* Kind of type-constraint derived during type inference
*/
public enum ConstraintKind {
/**
* upper bound constraint (a type variable must be instantiated
* with a type T, where T is a subtype of all the types specified by
* its EXTENDS constraints).
*/
/**
* lower bound constraint (a type variable must be instantiated
* with a type T, where T is a supertype of all the types specified by
* its SUPER constraints).
*/
/**
* equality constraint (a type variable must be instantiated to the type
* specified by its EQUAL constraint.
*/
}
/**
* Get the type-constraints of a given kind for a given type-variable of
* this ForAll type. Subclasses should override in order to return more
* accurate sets of constraints.
*
* @param tv the type-variable for which the constraint is to be retrieved
* @param ck the constraint kind to be retrieved
* @return the list of types specified by the selected constraint
*/
}
}
}
return qtype.asMethodType();
}
public void complete() {
}
}
}
return TypeKind.EXECUTABLE;
}
return v.visitExecutable(this, p);
}
}
/** A class for instantiatable variables, for use during type
* inference.
*/
return v.visitUndetVar(this, s);
}
}
else return qtype + "?";
}
else return this;
}
}
/** Represents VOID or NONE.
*/
}
switch (tag) {
default:
}
}
return v.visitNoType(this, p);
}
}
public BottomType() {
}
}
return v.visitNull(this, p);
}
return this;
}
return "null";
}
}
}
this(originalType, c);
c.type = this;
}
}
return v.visitErrorType(this, s);
}
public boolean isErroneous() { return true; }
public boolean isCompound() { return false; }
public boolean isInterface() { return false; }
}
return originalType;
}
return v.visitError(this, p);
}
}
/**
* A visitor for types. A visitor is used to implement operations
* (or relations) on types. Most common operations on types are
* binary relations and this interface is designed for binary
* relations, that is, operations on the form
* Type × S → R.
* <!-- In plain text: Type x S -> R -->
*
* @param <R> the return type of the operation implemented by this
* visitor; use Void if no return type is needed.
* @param <S> 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.
*/
public interface Visitor<R,S> {
}
}