< prev index next >

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

Print this page




 926 
 927         @DefinedBy(Api.LANGUAGE_MODEL)
 928         public Type getSuperBound() {
 929             if (kind == SUPER)
 930                 return type;
 931             else
 932                 return null;
 933         }
 934 
 935         @DefinedBy(Api.LANGUAGE_MODEL)
 936         public TypeKind getKind() {
 937             return TypeKind.WILDCARD;
 938         }
 939 
 940         @DefinedBy(Api.LANGUAGE_MODEL)
 941         public <R, P> R accept(TypeVisitor<R, P> v, P p) {
 942             return v.visitWildcard(this, p);
 943         }
 944     }
 945 


































 946     public static class ClassType extends Type implements DeclaredType, LoadableConstant,
 947                                                           javax.lang.model.type.ErrorType {
 948 
 949         /** The enclosing type of this type. If this is the type of an inner
 950          *  class, outer_field refers to the type of its enclosing
 951          *  instance class, in all other cases it refers to noType.
 952          */
 953         private Type outer_field;
 954 
 955         /** The type parameters of this type (to be set once class is loaded).
 956          */
 957         public List<Type> typarams_field;
 958 
 959         /** A cache variable for the type parameters of this type,
 960          *  appended to all parameters of its enclosing class.
 961          *  @see #allparams
 962          */
 963         public List<Type> allparams_field;
 964 
 965         /** The supertype of this class (to be set once class is loaded).


1053                     for (List<Type> is=interfaces_field; is.nonEmpty(); is = is.tail) {
1054                         s.append("&");
1055                         s.append(is.head.toString());
1056                     }
1057                     return s.toString();
1058                 } else if (sym.name.isEmpty()) {
1059                     String s;
1060                     ClassType norm = (ClassType) tsym.type;
1061                     if (norm == null) {
1062                         s = Log.getLocalizedString("anonymous.class", (Object)null);
1063                     } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) {
1064                         s = Log.getLocalizedString("anonymous.class",
1065                                                    norm.interfaces_field.head);
1066                     } else {
1067                         s = Log.getLocalizedString("anonymous.class",
1068                                                    norm.supertype_field);
1069                     }
1070                     if (moreInfo)
1071                         s += String.valueOf(sym.hashCode());
1072                     return s;
1073                 } else if (longform) {
1074                     return sym.getQualifiedName().toString();


1075                 } else {
1076                     return sym.name.toString();
1077                 }

1078             }
1079 
1080         @DefinedBy(Api.LANGUAGE_MODEL)
1081         public List<Type> getTypeArguments() {
1082             if (typarams_field == null) {
1083                 complete();
1084                 if (typarams_field == null)
1085                     typarams_field = List.nil();
1086             }
1087             return typarams_field;
1088         }
1089 
1090         public boolean hasErasedSupertypes() {
1091             return isRaw();
1092         }
1093 
1094         @DefinedBy(Api.LANGUAGE_MODEL)
1095         public Type getEnclosingType() {
1096             return outer_field;
1097         }




 926 
 927         @DefinedBy(Api.LANGUAGE_MODEL)
 928         public Type getSuperBound() {
 929             if (kind == SUPER)
 930                 return type;
 931             else
 932                 return null;
 933         }
 934 
 935         @DefinedBy(Api.LANGUAGE_MODEL)
 936         public TypeKind getKind() {
 937             return TypeKind.WILDCARD;
 938         }
 939 
 940         @DefinedBy(Api.LANGUAGE_MODEL)
 941         public <R, P> R accept(TypeVisitor<R, P> v, P p) {
 942             return v.visitWildcard(this, p);
 943         }
 944     }
 945 
 946     public static class ConstantPoolQType implements PoolConstant {
 947 
 948         public final Type type;
 949         final Types types;
 950 
 951         public ConstantPoolQType(Type type, Types types) {
 952             this.type = type;
 953             this.types = types;
 954         }
 955 
 956         @Override
 957         public Object poolKey(Types types) {
 958             return this;
 959         }
 960 
 961         @Override
 962         public int poolTag() {
 963             return ClassFile.CONSTANT_Class;
 964         }
 965 
 966         public int hashCode() {
 967             return types.hashCode(type);
 968         }
 969 
 970         public boolean equals(Object obj) {
 971             return (obj instanceof ConstantPoolQType) &&
 972                     types.isSameType(type, ((ConstantPoolQType)obj).type);
 973         }
 974 
 975         public String toString() {
 976             return type.toString();
 977         }
 978     }
 979 
 980     public static class ClassType extends Type implements DeclaredType, LoadableConstant,
 981                                                           javax.lang.model.type.ErrorType {
 982 
 983         /** The enclosing type of this type. If this is the type of an inner
 984          *  class, outer_field refers to the type of its enclosing
 985          *  instance class, in all other cases it refers to noType.
 986          */
 987         private Type outer_field;
 988 
 989         /** The type parameters of this type (to be set once class is loaded).
 990          */
 991         public List<Type> typarams_field;
 992 
 993         /** A cache variable for the type parameters of this type,
 994          *  appended to all parameters of its enclosing class.
 995          *  @see #allparams
 996          */
 997         public List<Type> allparams_field;
 998 
 999         /** The supertype of this class (to be set once class is loaded).


1087                     for (List<Type> is=interfaces_field; is.nonEmpty(); is = is.tail) {
1088                         s.append("&");
1089                         s.append(is.head.toString());
1090                     }
1091                     return s.toString();
1092                 } else if (sym.name.isEmpty()) {
1093                     String s;
1094                     ClassType norm = (ClassType) tsym.type;
1095                     if (norm == null) {
1096                         s = Log.getLocalizedString("anonymous.class", (Object)null);
1097                     } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) {
1098                         s = Log.getLocalizedString("anonymous.class",
1099                                                    norm.interfaces_field.head);
1100                     } else {
1101                         s = Log.getLocalizedString("anonymous.class",
1102                                                    norm.supertype_field);
1103                     }
1104                     if (moreInfo)
1105                         s += String.valueOf(sym.hashCode());
1106                     return s;
1107                 }
1108                 String s;
1109                 if (longform) {
1110                     s =  sym.getQualifiedName().toString();
1111                 } else {
1112                     s = sym.name.toString();
1113                 }
1114                 return sym.isProjectedNullable() ? s + '?' : s;
1115             }
1116 
1117         @DefinedBy(Api.LANGUAGE_MODEL)
1118         public List<Type> getTypeArguments() {
1119             if (typarams_field == null) {
1120                 complete();
1121                 if (typarams_field == null)
1122                     typarams_field = List.nil();
1123             }
1124             return typarams_field;
1125         }
1126 
1127         public boolean hasErasedSupertypes() {
1128             return isRaw();
1129         }
1130 
1131         @DefinedBy(Api.LANGUAGE_MODEL)
1132         public Type getEnclosingType() {
1133             return outer_field;
1134         }


< prev index next >