< prev index next >

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

Print this page

        

@@ -34,14 +34,11 @@
 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.*;

@@ -74,11 +71,11 @@
  *  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 {
+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,20 +123,10 @@
 
     /** 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) {

@@ -188,22 +175,10 @@
      */
     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.
      */

@@ -491,18 +466,10 @@
             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;

@@ -754,47 +721,10 @@
                         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);
         }
 

@@ -941,11 +871,11 @@
         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,
+    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,14 +916,10 @@
             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(); }

@@ -1292,11 +1218,11 @@
             return v.visitIntersection(this, p);
         }
     }
 
     public static class ArrayType extends Type
-            implements LoadableConstant, javax.lang.model.type.ArrayType {
+            implements javax.lang.model.type.ArrayType {
 
         public Type elemtype;
 
         public ArrayType(Type elemtype, TypeSymbol arrayClass) {
             this(elemtype, arrayClass, TypeMetadata.EMPTY);

@@ -1312,14 +1238,10 @@
             //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(); }

@@ -1431,11 +1353,11 @@
         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 static class MethodType extends Type implements ExecutableType {
 
         public List<Type> argtypes;
         public Type restype;
         public List<Type> thrown;
 

@@ -1498,15 +1420,10 @@
             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; }

@@ -2316,15 +2233,10 @@
         public Type constType(Object value) {
             return this;
         }
 
         @Override
-        public String stringValue() {
-            return "null";
-        }
-
-        @Override
         public boolean isNullOrReference() {
             return true;
         }
 
     }
< prev index next >