< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java

Print this page

        

*** 34,47 **** import javax.lang.model.type.*; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.TypeMetadata.Entry; import com.sun.tools.javac.code.Types.TypeMapping; - import com.sun.tools.javac.code.Types.UniqueType; import com.sun.tools.javac.comp.Infer.IncorporationAction; - import com.sun.tools.javac.jvm.ClassFile; - import com.sun.tools.javac.jvm.PoolConstant; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.DefinedBy.Api; import static com.sun.tools.javac.code.BoundKind.*; import static com.sun.tools.javac.code.Flags.*; --- 34,44 ----
*** 74,84 **** * This code and its internal interfaces are subject to change or * deletion without notice.</b> * * @see TypeTag */ ! public abstract class Type extends AnnoConstruct implements TypeMirror, PoolConstant { /** * Type metadata, Should be {@code null} for the default value. * * Note: it is an invariant that for any {@code TypeMetadata} --- 71,81 ---- * This code and its internal interfaces are subject to change or * deletion without notice.</b> * * @see TypeTag */ ! public abstract class Type extends AnnoConstruct implements TypeMirror { /** * Type metadata, Should be {@code null} for the default value. * * Note: it is an invariant that for any {@code TypeMetadata}
*** 126,145 **** /** The defining class / interface / package / type variable. */ public TypeSymbol tsym; - @Override - public int poolTag() { - throw new AssertionError("Invalid pool entry"); - } - - @Override - public Object poolKey(Types types) { - return new UniqueType(this, types); - } - /** * Checks if the current type tag is equal to the given tag. * @return true if tag is equal to the current type tag. */ public boolean hasTag(TypeTag tag) { --- 123,132 ----
*** 188,209 **** */ public Object constValue() { return null; } - /** Is this a constant type whose value is false? - */ - public boolean isFalse() { - return false; - } - - /** Is this a constant type whose value is true? - */ - public boolean isTrue() { - return false; - } - /** * Get the representation of this type used for modelling purposes. * By default, this is itself. For ErrorType, a different value * may be provided. */ --- 175,184 ----
*** 491,508 **** return buf.toString(); } } /** - * The constant value of this type, converted to String - */ - public String stringValue() { - Object cv = Assert.checkNonNull(constValue()); - return cv.toString(); - } - - /** * Override this method with care. For most Type instances this should behave as ==. */ @Override @DefinedBy(Api.LANGUAGE_MODEL) public boolean equals(Object t) { return this == t; --- 466,475 ----
*** 754,800 **** return tsym.type; } }; } - /** - * The constant value of this type, converted to String - */ - @Override - public String stringValue() { - Object cv = Assert.checkNonNull(constValue()); - if (tag == BOOLEAN) { - return ((Integer) cv).intValue() == 0 ? "false" : "true"; - } - else if (tag == CHAR) { - return String.valueOf((char) ((Integer) cv).intValue()); - } - else { - return cv.toString(); - } - } - - /** Is this a constant type whose value is false? - */ - @Override - public boolean isFalse() { - return - tag == BOOLEAN && - constValue() != null && - ((Integer)constValue()).intValue() == 0; - } - - /** Is this a constant type whose value is true? - */ - @Override - public boolean isTrue() { - return - tag == BOOLEAN && - constValue() != null && - ((Integer)constValue()).intValue() != 0; - } - @Override @DefinedBy(Api.LANGUAGE_MODEL) public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitPrimitive(this, p); } --- 721,730 ----
*** 941,951 **** public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitWildcard(this, p); } } ! public static class ClassType extends Type implements DeclaredType, LoadableConstant, javax.lang.model.type.ErrorType { /** 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 refers to noType. --- 871,881 ---- public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitWildcard(this, p); } } ! public static class ClassType extends Type implements DeclaredType, javax.lang.model.type.ErrorType { /** 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 refers to noType.
*** 986,999 **** this.allparams_field = null; this.supertype_field = null; this.interfaces_field = null; } - public int poolTag() { - return ClassFile.CONSTANT_Class; - } - @Override public ClassType cloneWithMetadata(TypeMetadata md) { return new ClassType(outer_field, typarams_field, tsym, md) { @Override public Type baseType() { return ClassType.this.baseType(); } --- 916,925 ----
*** 1292,1302 **** return v.visitIntersection(this, p); } } public static class ArrayType extends Type ! implements LoadableConstant, javax.lang.model.type.ArrayType { public Type elemtype; public ArrayType(Type elemtype, TypeSymbol arrayClass) { this(elemtype, arrayClass, TypeMetadata.EMPTY); --- 1218,1228 ---- return v.visitIntersection(this, p); } } public static class ArrayType extends Type ! implements javax.lang.model.type.ArrayType { public Type elemtype; public ArrayType(Type elemtype, TypeSymbol arrayClass) { this(elemtype, arrayClass, TypeMetadata.EMPTY);
*** 1312,1325 **** //note: type metadata is deliberately shared here, as we want side-effects from annotation //processing to flow from original array to the cloned array. this(that.elemtype, that.tsym, that.getMetadata()); } - public int poolTag() { - return ClassFile.CONSTANT_Class; - } - @Override public ArrayType cloneWithMetadata(TypeMetadata md) { return new ArrayType(elemtype, tsym, md) { @Override public Type baseType() { return ArrayType.this.baseType(); } --- 1238,1247 ----
*** 1431,1441 **** public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitArray(this, p); } } ! public static class MethodType extends Type implements ExecutableType, LoadableConstant { public List<Type> argtypes; public Type restype; public List<Type> thrown; --- 1353,1363 ---- public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitArray(this, p); } } ! public static class MethodType extends Type implements ExecutableType { public List<Type> argtypes; public Type restype; public List<Type> thrown;
*** 1498,1512 **** return isErroneous(argtypes) || restype != null && restype.isErroneous(); } - @Override - public int poolTag() { - return ClassFile.CONSTANT_MethodType; - } - public boolean contains(Type elem) { return elem.equalsIgnoreMetadata(this) || contains(argtypes, elem) || restype.contains(elem) || contains(thrown, elem); } public MethodType asMethodType() { return this; } --- 1420,1429 ----
*** 2316,2330 **** public Type constType(Object value) { return this; } @Override - public String stringValue() { - return "null"; - } - - @Override public boolean isNullOrReference() { return true; } } --- 2233,2242 ----
< prev index next >