< prev index next >

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

Print this page

  35 import java.util.concurrent.Callable;
  36 import java.util.function.Supplier;
  37 import java.util.function.Predicate;
  38 
  39 import javax.lang.model.element.Element;
  40 import javax.lang.model.element.ElementKind;
  41 import javax.lang.model.element.ElementVisitor;
  42 import javax.lang.model.element.ExecutableElement;
  43 import javax.lang.model.element.Modifier;
  44 import javax.lang.model.element.ModuleElement;
  45 import javax.lang.model.element.NestingKind;
  46 import javax.lang.model.element.PackageElement;
  47 import javax.lang.model.element.RecordComponentElement;
  48 import javax.lang.model.element.TypeElement;
  49 import javax.lang.model.element.TypeParameterElement;
  50 import javax.lang.model.element.VariableElement;
  51 import javax.tools.JavaFileManager;
  52 import javax.tools.JavaFileObject;
  53 
  54 import com.sun.tools.javac.code.Kinds.Kind;

  55 import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
  56 import com.sun.tools.javac.code.Type.*;
  57 import com.sun.tools.javac.comp.Attr;
  58 import com.sun.tools.javac.comp.AttrContext;
  59 import com.sun.tools.javac.comp.Env;
  60 import com.sun.tools.javac.jvm.*;
  61 import com.sun.tools.javac.jvm.PoolConstant;
  62 import com.sun.tools.javac.tree.JCTree;
  63 import com.sun.tools.javac.tree.JCTree.JCAnnotation;
  64 import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
  65 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
  66 import com.sun.tools.javac.tree.JCTree.Tag;
  67 import com.sun.tools.javac.util.*;
  68 import com.sun.tools.javac.util.DefinedBy.Api;
  69 import com.sun.tools.javac.util.List;
  70 import com.sun.tools.javac.util.Name;
  71 
  72 import static com.sun.tools.javac.code.Flags.*;
  73 import static com.sun.tools.javac.code.Kinds.*;
  74 import static com.sun.tools.javac.code.Kinds.Kind.*;

 398 
 399     public boolean isStatic() {
 400         return
 401             (flags() & STATIC) != 0 ||
 402             (owner.flags() & INTERFACE) != 0 && kind != MTH &&
 403              name != name.table.names._this;
 404     }
 405 
 406     public boolean isInterface() {
 407         return (flags() & INTERFACE) != 0;
 408     }
 409 
 410     public boolean isAbstract() {
 411         return (flags_field & ABSTRACT) != 0;
 412     }
 413 
 414     public boolean isPrivate() {
 415         return (flags_field & Flags.AccessFlags) == PRIVATE;
 416     }
 417 




















 418     public boolean isPublic() {
 419         return (flags_field & Flags.AccessFlags) == PUBLIC;
 420     }
 421 
 422     public boolean isEnum() {
 423         return (flags() & ENUM) != 0;
 424     }
 425 
 426     public boolean isSealed() {
 427         return (flags_field & SEALED) != 0;
 428     }
 429 
 430     public boolean isNonSealed() {
 431         return (flags_field & NON_SEALED) != 0;
 432     }
 433 
 434     public boolean isFinal() {
 435         return (flags_field & FINAL) != 0;
 436     }
 437 

 439      *  to a method or variable initializer?
 440      *  Also includes fields of inner classes which are in
 441      *  turn local to a method or variable initializer.
 442      */
 443     public boolean isDirectlyOrIndirectlyLocal() {
 444         return
 445             (owner.kind.matches(KindSelector.VAL_MTH) ||
 446              (owner.kind == TYP && owner.isDirectlyOrIndirectlyLocal()));
 447     }
 448 
 449     /** Has this symbol an empty name? This includes anonymous
 450      *  inner classes.
 451      */
 452     public boolean isAnonymous() {
 453         return name.isEmpty();
 454     }
 455 
 456     /** Is this symbol a constructor?
 457      */
 458     public boolean isConstructor() {
 459         return name == name.table.names.init;






 460     }
 461 
 462     public boolean isDynamic() {
 463         return false;
 464     }
 465 
 466     /** The fully qualified name of this symbol.
 467      *  This is the same as the symbol's name except for class symbols,
 468      *  which are handled separately.
 469      */
 470     public Name getQualifiedName() {
 471         return name;
 472     }
 473 
 474     /** The fully qualified name of this symbol after converting to flat
 475      *  representation. This is the same as the symbol's name except for
 476      *  class symbols, which are handled separately.
 477      */
 478     public Name flatName() {
 479         return getQualifiedName();

1299          */
1300         public List<Symbol> permitted;
1301 
1302         public boolean isPermittedExplicit = false;
1303 
1304         public ClassSymbol(long flags, Name name, Type type, Symbol owner) {
1305             super(TYP, flags, name, type, owner);
1306             this.members_field = null;
1307             this.fullname = formFullName(name, owner);
1308             this.flatname = formFlatName(name, owner);
1309             this.sourcefile = null;
1310             this.classfile = null;
1311             this.annotationTypeMetadata = AnnotationTypeMetadata.notAnAnnotationType();
1312             this.permitted = List.nil();
1313         }
1314 
1315         public ClassSymbol(long flags, Name name, Symbol owner) {
1316             this(
1317                 flags,
1318                 name,
1319                 new ClassType(Type.noType, null, null),
1320                 owner);
1321             this.type.tsym = this;
1322         }
1323 
1324         /** The Java source which this symbol represents.
1325          */
1326         public String toString() {
1327             return className();
1328         }
1329 
1330         public long flags() {
1331             complete();
1332             return flags_field;
1333         }
1334 
1335         public WriteableScope members() {
1336             complete();
1337             return members_field;
1338         }
1339 
1340         @Override
1341         public List<Attribute.Compound> getRawAttributes() {
1342             complete();
1343             return super.getRawAttributes();
1344         }
1345 
1346         @Override
1347         public List<Attribute.TypeCompound> getRawTypeAttributes() {
1348             complete();
1349             return super.getRawTypeAttributes();
1350         }
1351 
1352         public Type erasure(Types types) {
1353             if (erasure_field == null)
1354                 erasure_field = new ClassType(types.erasure(type.getEnclosingType()),
1355                                               List.nil(), this,
1356                                               type.getMetadata());

1357             return erasure_field;
1358         }
1359 
1360         public String className() {
1361             if (name.isEmpty())
1362                 return
1363                     Log.getLocalizedString("anonymous.class", flatname);
1364             else
1365                 return fullname.toString();
1366         }
1367 
1368         @DefinedBy(Api.LANGUAGE_MODEL)
1369         public Name getQualifiedName() {
1370             return fullname;
1371         }
1372 
1373         @Override @DefinedBy(Api.LANGUAGE_MODEL)
1374         public List<Symbol> getEnclosedElements() {
1375             List<Symbol> result = super.getEnclosedElements();
1376             if (!recordComponents.isEmpty()) {
1377                 List<RecordComponent> reversed = recordComponents.reverse();
1378                 for (RecordComponent rc : reversed) {
1379                     result = result.prepend(rc);
1380                 }
1381             }
1382             return result;
1383         }
1384 

1397                         if (is.head.tsym.isSubClass(base, types)) return true;
1398             } else {
1399                 for (Type t = type; t.hasTag(CLASS); t = types.supertype(t))
1400                     if (t.tsym == base) return true;
1401             }
1402             return false;
1403         }
1404 
1405         /** Complete the elaboration of this symbol's definition.
1406          */
1407         public void complete() throws CompletionFailure {
1408             Completer origCompleter = completer;
1409             try {
1410                 super.complete();
1411             } catch (CompletionFailure ex) {
1412                 ex.dcfh.classSymbolCompleteFailed(this, origCompleter);
1413                 // quiet error recovery
1414                 flags_field |= (PUBLIC|STATIC);
1415                 this.type = new ErrorType(this, Type.noType);
1416                 throw ex;








1417             }
1418         }
1419 
1420         @DefinedBy(Api.LANGUAGE_MODEL)
1421         public List<Type> getInterfaces() {
1422             apiComplete();
1423             if (type instanceof ClassType classType) {
1424                 if (classType.interfaces_field == null) // FIXME: shouldn't be null
1425                     classType.interfaces_field = List.nil();
1426                 if (classType.all_interfaces_field != null)
1427                     return Type.getModelTypes(classType.all_interfaces_field);
1428                 return classType.interfaces_field;
1429             } else {
1430                 return List.nil();
1431             }
1432         }
1433 
1434         @DefinedBy(Api.LANGUAGE_MODEL)
1435         public Type getSuperclass() {
1436             apiComplete();

1584                 if (types.firstUnimplementedAbstract(this) != null)
1585                     // add the ABSTRACT flag to an enum
1586                     flags_field |= ABSTRACT;
1587             }
1588         }
1589 
1590         /**Resets the Symbol into the state good for next round of annotation processing.*/
1591         public void reset() {
1592             kind = TYP;
1593             erasure_field = null;
1594             members_field = null;
1595             flags_field = 0;
1596             if (type instanceof ClassType classType) {
1597                 classType.setEnclosingType(Type.noType);
1598                 classType.rank_field = -1;
1599                 classType.typarams_field = null;
1600                 classType.allparams_field = null;
1601                 classType.supertype_field = null;
1602                 classType.interfaces_field = null;
1603                 classType.all_interfaces_field = null;

1604             }
1605             clearAnnotationMetadata();
1606         }
1607 
1608         public void clearAnnotationMetadata() {
1609             metadata = null;
1610             annotationTypeMetadata = AnnotationTypeMetadata.notAnAnnotationType();
1611         }
1612 
1613         @Override
1614         public AnnotationTypeMetadata getAnnotationTypeMetadata() {
1615             return annotationTypeMetadata;
1616         }
1617 
1618         @Override
1619         public boolean isAnnotationType() {
1620             return (flags_field & Flags.ANNOTATION) != 0;
1621         }
1622 
1623         public void setAnnotationTypeMetadata(AnnotationTypeMetadata a) {

2004                     // subst() for a parametric return type.
2005                     types.isSameType(type.getReturnType(),
2006                                      types.memberType(owner.type, sym).getReturnType())) {
2007                     impl = sym;
2008                 }
2009             }
2010             return impl;
2011         }
2012 
2013         /** Will the erasure of this method be considered by the VM to
2014          *  override the erasure of the other when seen from class `origin'?
2015          */
2016         public boolean binaryOverrides(Symbol _other, TypeSymbol origin, Types types) {
2017             if (isConstructor() || _other.kind != MTH) return false;
2018 
2019             if (this == _other) return true;
2020             MethodSymbol other = (MethodSymbol)_other;
2021 
2022             // check for a direct implementation
2023             if (other.isOverridableIn((TypeSymbol)owner) &&
2024                 types.asSuper(owner.type, other.owner) != null &&
2025                 types.isSameType(erasure(types), other.erasure(types)))
2026                 return true;
2027 
2028             // check for an inherited implementation
2029             return
2030                 (flags() & ABSTRACT) == 0 &&
2031                 other.isOverridableIn(origin) &&
2032                 this.isMemberOf(origin, types) &&
2033                 types.isSameType(erasure(types), other.erasure(types));
2034         }
2035 
2036         /** The implementation of this (abstract) symbol in class origin,
2037          *  from the VM's point of view, null if method does not have an
2038          *  implementation in class.
2039          *  @param origin   The class of which the implementation is a member.
2040          */
2041         public MethodSymbol binaryImplementation(ClassSymbol origin, Types types) {
2042             for (TypeSymbol c = origin; c != null; c = types.supertype(c.type).tsym) {
2043                 for (Symbol sym : c.members().getSymbolsByName(name)) {
2044                     if (sym.kind == MTH &&

2073          *  of origin.
2074          *
2075          *  Caveat: If `this' is an abstract inherited member of origin, it is
2076          *  deemed to override `other' only when `requireConcreteIfInherited'
2077          *  is false.
2078          *
2079          *  It is assumed that both symbols have the same name.  The static
2080          *  modifier is ignored for this test.
2081          *
2082          *  See JLS 8.4.8.1 (without transitivity) and 8.4.8.4
2083          */
2084         public boolean overrides(Symbol _other, TypeSymbol origin, Types types, boolean checkResult,
2085                                             boolean requireConcreteIfInherited) {
2086             if (isConstructor() || _other.kind != MTH) return false;
2087 
2088             if (this == _other) return true;
2089             MethodSymbol other = (MethodSymbol)_other;
2090 
2091             // check for a direct implementation
2092             if (other.isOverridableIn((TypeSymbol)owner) &&
2093                 types.asSuper(owner.type, other.owner) != null) {
2094                 Type mt = types.memberType(owner.type, this);
2095                 Type ot = types.memberType(owner.type, other);
2096                 if (types.isSubSignature(mt, ot)) {
2097                     if (!checkResult)
2098                         return true;
2099                     if (types.returnTypeSubstitutable(mt, ot))
2100                         return true;
2101                 }
2102             }
2103 
2104             // check for an inherited implementation
2105             if (((flags() & ABSTRACT) != 0 && requireConcreteIfInherited) ||
2106                     ((other.flags() & ABSTRACT) == 0 && (other.flags() & DEFAULT) == 0) ||
2107                     !other.isOverridableIn(origin) ||
2108                     !this.isMemberOf(origin, types))
2109                 return false;
2110 
2111             // assert types.asSuper(origin.type, other.owner) != null;
2112             Type mt = types.memberType(origin.type, this);
2113             Type ot = types.memberType(origin.type, other);

2122             case Flags.PRIVATE:
2123                 return false;
2124             case Flags.PUBLIC:
2125                 return !this.owner.isInterface() ||
2126                         (flags_field & STATIC) == 0;
2127             case Flags.PROTECTED:
2128                 return (origin.flags() & INTERFACE) == 0;
2129             case 0:
2130                 // for package private: can only override in the same
2131                 // package
2132                 return
2133                     this.packge() == origin.packge() &&
2134                     (origin.flags() & INTERFACE) == 0;
2135             default:
2136                 return false;
2137             }
2138         }
2139 
2140         @Override
2141         public boolean isInheritedIn(Symbol clazz, Types types) {

2142             switch ((int)(flags_field & Flags.AccessFlags)) {
2143                 case PUBLIC:
2144                     return !this.owner.isInterface() ||
2145                             clazz == owner ||
2146                             (flags_field & STATIC) == 0;
2147                 default:
2148                     return super.isInheritedIn(clazz, types);
2149             }
2150         }
2151 
2152         public boolean isLambdaMethod() {
2153             return (flags() & LAMBDA_METHOD) == LAMBDA_METHOD;
2154         }
2155 
2156         /** override this method to point to the original enclosing method if this method symbol represents a synthetic
2157          *  lambda method
2158          */
2159         public MethodSymbol originalEnclosingMethod() {
2160             return this;
2161         }

  35 import java.util.concurrent.Callable;
  36 import java.util.function.Supplier;
  37 import java.util.function.Predicate;
  38 
  39 import javax.lang.model.element.Element;
  40 import javax.lang.model.element.ElementKind;
  41 import javax.lang.model.element.ElementVisitor;
  42 import javax.lang.model.element.ExecutableElement;
  43 import javax.lang.model.element.Modifier;
  44 import javax.lang.model.element.ModuleElement;
  45 import javax.lang.model.element.NestingKind;
  46 import javax.lang.model.element.PackageElement;
  47 import javax.lang.model.element.RecordComponentElement;
  48 import javax.lang.model.element.TypeElement;
  49 import javax.lang.model.element.TypeParameterElement;
  50 import javax.lang.model.element.VariableElement;
  51 import javax.tools.JavaFileManager;
  52 import javax.tools.JavaFileObject;
  53 
  54 import com.sun.tools.javac.code.Kinds.Kind;
  55 import com.sun.tools.javac.code.Type.ClassType.Flavor;
  56 import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
  57 import com.sun.tools.javac.code.Type.*;
  58 import com.sun.tools.javac.comp.Attr;
  59 import com.sun.tools.javac.comp.AttrContext;
  60 import com.sun.tools.javac.comp.Env;
  61 import com.sun.tools.javac.jvm.*;
  62 import com.sun.tools.javac.jvm.PoolConstant;
  63 import com.sun.tools.javac.tree.JCTree;
  64 import com.sun.tools.javac.tree.JCTree.JCAnnotation;
  65 import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
  66 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
  67 import com.sun.tools.javac.tree.JCTree.Tag;
  68 import com.sun.tools.javac.util.*;
  69 import com.sun.tools.javac.util.DefinedBy.Api;
  70 import com.sun.tools.javac.util.List;
  71 import com.sun.tools.javac.util.Name;
  72 
  73 import static com.sun.tools.javac.code.Flags.*;
  74 import static com.sun.tools.javac.code.Kinds.*;
  75 import static com.sun.tools.javac.code.Kinds.Kind.*;

 399 
 400     public boolean isStatic() {
 401         return
 402             (flags() & STATIC) != 0 ||
 403             (owner.flags() & INTERFACE) != 0 && kind != MTH &&
 404              name != name.table.names._this;
 405     }
 406 
 407     public boolean isInterface() {
 408         return (flags() & INTERFACE) != 0;
 409     }
 410 
 411     public boolean isAbstract() {
 412         return (flags_field & ABSTRACT) != 0;
 413     }
 414 
 415     public boolean isPrivate() {
 416         return (flags_field & Flags.AccessFlags) == PRIVATE;
 417     }
 418 
 419     public boolean isPrimitiveClass() {
 420         return (flags() & PRIMITIVE_CLASS) != 0;
 421     }
 422 
 423     public boolean isValueClass() {
 424         return !isInterface() && (flags() & VALUE_CLASS) != 0;
 425     }
 426 
 427     public boolean isIdentityClass() {
 428         return !isInterface() && (flags() & IDENTITY_TYPE) != 0;
 429     }
 430 
 431     public boolean isValueInterface() {
 432         return isInterface() && (flags() & VALUE_CLASS) != 0;
 433     }
 434 
 435     public boolean isIdentityInterface() {
 436         return isInterface() && (flags() & IDENTITY_TYPE) != 0;
 437     }
 438 
 439     public boolean isPublic() {
 440         return (flags_field & Flags.AccessFlags) == PUBLIC;
 441     }
 442 
 443     public boolean isEnum() {
 444         return (flags() & ENUM) != 0;
 445     }
 446 
 447     public boolean isSealed() {
 448         return (flags_field & SEALED) != 0;
 449     }
 450 
 451     public boolean isNonSealed() {
 452         return (flags_field & NON_SEALED) != 0;
 453     }
 454 
 455     public boolean isFinal() {
 456         return (flags_field & FINAL) != 0;
 457     }
 458 

 460      *  to a method or variable initializer?
 461      *  Also includes fields of inner classes which are in
 462      *  turn local to a method or variable initializer.
 463      */
 464     public boolean isDirectlyOrIndirectlyLocal() {
 465         return
 466             (owner.kind.matches(KindSelector.VAL_MTH) ||
 467              (owner.kind == TYP && owner.isDirectlyOrIndirectlyLocal()));
 468     }
 469 
 470     /** Has this symbol an empty name? This includes anonymous
 471      *  inner classes.
 472      */
 473     public boolean isAnonymous() {
 474         return name.isEmpty();
 475     }
 476 
 477     /** Is this symbol a constructor?
 478      */
 479     public boolean isConstructor() {
 480         return name == name.table.names.init && (flags() & STATIC) == 0;
 481     }
 482 
 483     /** Is this symbol a value object factory?
 484      */
 485     public boolean isValueObjectFactory() {
 486         return ((name == name.table.names.init && this.type.getReturnType().tsym == this.owner));
 487     }
 488 
 489     public boolean isDynamic() {
 490         return false;
 491     }
 492 
 493     /** The fully qualified name of this symbol.
 494      *  This is the same as the symbol's name except for class symbols,
 495      *  which are handled separately.
 496      */
 497     public Name getQualifiedName() {
 498         return name;
 499     }
 500 
 501     /** The fully qualified name of this symbol after converting to flat
 502      *  representation. This is the same as the symbol's name except for
 503      *  class symbols, which are handled separately.
 504      */
 505     public Name flatName() {
 506         return getQualifiedName();

1326          */
1327         public List<Symbol> permitted;
1328 
1329         public boolean isPermittedExplicit = false;
1330 
1331         public ClassSymbol(long flags, Name name, Type type, Symbol owner) {
1332             super(TYP, flags, name, type, owner);
1333             this.members_field = null;
1334             this.fullname = formFullName(name, owner);
1335             this.flatname = formFlatName(name, owner);
1336             this.sourcefile = null;
1337             this.classfile = null;
1338             this.annotationTypeMetadata = AnnotationTypeMetadata.notAnAnnotationType();
1339             this.permitted = List.nil();
1340         }
1341 
1342         public ClassSymbol(long flags, Name name, Symbol owner) {
1343             this(
1344                 flags,
1345                 name,
1346                 new ClassType(Type.noType, null, null, TypeMetadata.EMPTY, Flavor.X_Typeof_X),
1347                 owner);
1348             this.type.tsym = this;
1349         }
1350 
1351         /** The Java source which this symbol represents.
1352          */
1353         public String toString() {
1354             return className();
1355         }
1356 
1357         public long flags() {
1358             complete();
1359             return flags_field;
1360         }
1361 
1362         public WriteableScope members() {
1363             complete();
1364             return members_field;
1365         }
1366 
1367         @Override
1368         public List<Attribute.Compound> getRawAttributes() {
1369             complete();
1370             return super.getRawAttributes();
1371         }
1372 
1373         @Override
1374         public List<Attribute.TypeCompound> getRawTypeAttributes() {
1375             complete();
1376             return super.getRawTypeAttributes();
1377         }
1378 
1379         public Type erasure(Types types) {
1380             if (erasure_field == null)
1381                 erasure_field = new ClassType(types.erasure(type.getEnclosingType()),
1382                                               List.nil(), this,
1383                                               type.getMetadata(),
1384                                               type.getFlavor());
1385             return erasure_field;
1386         }
1387 
1388         public String className() {
1389             if (name.isEmpty())
1390                 return
1391                     Log.getLocalizedString("anonymous.class", flatname);
1392 
1393                 return fullname.toString();
1394         }
1395 
1396         @DefinedBy(Api.LANGUAGE_MODEL)
1397         public Name getQualifiedName() {
1398             return fullname;
1399         }
1400 
1401         @Override @DefinedBy(Api.LANGUAGE_MODEL)
1402         public List<Symbol> getEnclosedElements() {
1403             List<Symbol> result = super.getEnclosedElements();
1404             if (!recordComponents.isEmpty()) {
1405                 List<RecordComponent> reversed = recordComponents.reverse();
1406                 for (RecordComponent rc : reversed) {
1407                     result = result.prepend(rc);
1408                 }
1409             }
1410             return result;
1411         }
1412 

1425                         if (is.head.tsym.isSubClass(base, types)) return true;
1426             } else {
1427                 for (Type t = type; t.hasTag(CLASS); t = types.supertype(t))
1428                     if (t.tsym == base) return true;
1429             }
1430             return false;
1431         }
1432 
1433         /** Complete the elaboration of this symbol's definition.
1434          */
1435         public void complete() throws CompletionFailure {
1436             Completer origCompleter = completer;
1437             try {
1438                 super.complete();
1439             } catch (CompletionFailure ex) {
1440                 ex.dcfh.classSymbolCompleteFailed(this, origCompleter);
1441                 // quiet error recovery
1442                 flags_field |= (PUBLIC|STATIC);
1443                 this.type = new ErrorType(this, Type.noType);
1444                 throw ex;
1445             } finally {
1446                 if (this.type != null && this.type.hasTag(CLASS)) {
1447                     ClassType ct = (ClassType) this.type;
1448                     ct.flavor = ct.flavor.metamorphose((this.flags_field & PRIMITIVE_CLASS) != 0);
1449                     if (!this.type.isIntersection() && this.erasure_field != null && this.erasure_field.hasTag(CLASS)) {
1450                         ((ClassType) this.erasure_field).flavor = ct.flavor;
1451                     }
1452                 }
1453             }
1454         }
1455 
1456         @DefinedBy(Api.LANGUAGE_MODEL)
1457         public List<Type> getInterfaces() {
1458             apiComplete();
1459             if (type instanceof ClassType classType) {
1460                 if (classType.interfaces_field == null) // FIXME: shouldn't be null
1461                     classType.interfaces_field = List.nil();
1462                 if (classType.all_interfaces_field != null)
1463                     return Type.getModelTypes(classType.all_interfaces_field);
1464                 return classType.interfaces_field;
1465             } else {
1466                 return List.nil();
1467             }
1468         }
1469 
1470         @DefinedBy(Api.LANGUAGE_MODEL)
1471         public Type getSuperclass() {
1472             apiComplete();

1620                 if (types.firstUnimplementedAbstract(this) != null)
1621                     // add the ABSTRACT flag to an enum
1622                     flags_field |= ABSTRACT;
1623             }
1624         }
1625 
1626         /**Resets the Symbol into the state good for next round of annotation processing.*/
1627         public void reset() {
1628             kind = TYP;
1629             erasure_field = null;
1630             members_field = null;
1631             flags_field = 0;
1632             if (type instanceof ClassType classType) {
1633                 classType.setEnclosingType(Type.noType);
1634                 classType.rank_field = -1;
1635                 classType.typarams_field = null;
1636                 classType.allparams_field = null;
1637                 classType.supertype_field = null;
1638                 classType.interfaces_field = null;
1639                 classType.all_interfaces_field = null;
1640                 classType.flavor = Flavor.X_Typeof_X;
1641             }
1642             clearAnnotationMetadata();
1643         }
1644 
1645         public void clearAnnotationMetadata() {
1646             metadata = null;
1647             annotationTypeMetadata = AnnotationTypeMetadata.notAnAnnotationType();
1648         }
1649 
1650         @Override
1651         public AnnotationTypeMetadata getAnnotationTypeMetadata() {
1652             return annotationTypeMetadata;
1653         }
1654 
1655         @Override
1656         public boolean isAnnotationType() {
1657             return (flags_field & Flags.ANNOTATION) != 0;
1658         }
1659 
1660         public void setAnnotationTypeMetadata(AnnotationTypeMetadata a) {

2041                     // subst() for a parametric return type.
2042                     types.isSameType(type.getReturnType(),
2043                                      types.memberType(owner.type, sym).getReturnType())) {
2044                     impl = sym;
2045                 }
2046             }
2047             return impl;
2048         }
2049 
2050         /** Will the erasure of this method be considered by the VM to
2051          *  override the erasure of the other when seen from class `origin'?
2052          */
2053         public boolean binaryOverrides(Symbol _other, TypeSymbol origin, Types types) {
2054             if (isConstructor() || _other.kind != MTH) return false;
2055 
2056             if (this == _other) return true;
2057             MethodSymbol other = (MethodSymbol)_other;
2058 
2059             // check for a direct implementation
2060             if (other.isOverridableIn((TypeSymbol)owner) &&
2061                 types.asSuper(owner.type.referenceProjectionOrSelf(), other.owner) != null &&
2062                 types.isSameType(erasure(types), other.erasure(types)))
2063                 return true;
2064 
2065             // check for an inherited implementation
2066             return
2067                 (flags() & ABSTRACT) == 0 &&
2068                 other.isOverridableIn(origin) &&
2069                 this.isMemberOf(origin, types) &&
2070                 types.isSameType(erasure(types), other.erasure(types));
2071         }
2072 
2073         /** The implementation of this (abstract) symbol in class origin,
2074          *  from the VM's point of view, null if method does not have an
2075          *  implementation in class.
2076          *  @param origin   The class of which the implementation is a member.
2077          */
2078         public MethodSymbol binaryImplementation(ClassSymbol origin, Types types) {
2079             for (TypeSymbol c = origin; c != null; c = types.supertype(c.type).tsym) {
2080                 for (Symbol sym : c.members().getSymbolsByName(name)) {
2081                     if (sym.kind == MTH &&

2110          *  of origin.
2111          *
2112          *  Caveat: If `this' is an abstract inherited member of origin, it is
2113          *  deemed to override `other' only when `requireConcreteIfInherited'
2114          *  is false.
2115          *
2116          *  It is assumed that both symbols have the same name.  The static
2117          *  modifier is ignored for this test.
2118          *
2119          *  See JLS 8.4.8.1 (without transitivity) and 8.4.8.4
2120          */
2121         public boolean overrides(Symbol _other, TypeSymbol origin, Types types, boolean checkResult,
2122                                             boolean requireConcreteIfInherited) {
2123             if (isConstructor() || _other.kind != MTH) return false;
2124 
2125             if (this == _other) return true;
2126             MethodSymbol other = (MethodSymbol)_other;
2127 
2128             // check for a direct implementation
2129             if (other.isOverridableIn((TypeSymbol)owner) &&
2130                 types.asSuper(owner.type.referenceProjectionOrSelf(), other.owner) != null) {
2131                 Type mt = types.memberType(owner.type, this);
2132                 Type ot = types.memberType(owner.type, other);
2133                 if (types.isSubSignature(mt, ot)) {
2134                     if (!checkResult)
2135                         return true;
2136                     if (types.returnTypeSubstitutable(mt, ot))
2137                         return true;
2138                 }
2139             }
2140 
2141             // check for an inherited implementation
2142             if (((flags() & ABSTRACT) != 0 && requireConcreteIfInherited) ||
2143                     ((other.flags() & ABSTRACT) == 0 && (other.flags() & DEFAULT) == 0) ||
2144                     !other.isOverridableIn(origin) ||
2145                     !this.isMemberOf(origin, types))
2146                 return false;
2147 
2148             // assert types.asSuper(origin.type, other.owner) != null;
2149             Type mt = types.memberType(origin.type, this);
2150             Type ot = types.memberType(origin.type, other);

2159             case Flags.PRIVATE:
2160                 return false;
2161             case Flags.PUBLIC:
2162                 return !this.owner.isInterface() ||
2163                         (flags_field & STATIC) == 0;
2164             case Flags.PROTECTED:
2165                 return (origin.flags() & INTERFACE) == 0;
2166             case 0:
2167                 // for package private: can only override in the same
2168                 // package
2169                 return
2170                     this.packge() == origin.packge() &&
2171                     (origin.flags() & INTERFACE) == 0;
2172             default:
2173                 return false;
2174             }
2175         }
2176 
2177         @Override
2178         public boolean isInheritedIn(Symbol clazz, Types types) {
2179 
2180             switch ((int)(flags_field & Flags.AccessFlags)) {
2181                 case PUBLIC:
2182                     return !this.owner.isInterface() ||
2183                             clazz == owner ||
2184                             (flags_field & STATIC) == 0;
2185                 default:
2186                     return super.isInheritedIn(clazz, types);
2187             }
2188         }
2189 
2190         public boolean isLambdaMethod() {
2191             return (flags() & LAMBDA_METHOD) == LAMBDA_METHOD;
2192         }
2193 
2194         /** override this method to point to the original enclosing method if this method symbol represents a synthetic
2195          *  lambda method
2196          */
2197         public MethodSymbol originalEnclosingMethod() {
2198             return this;
2199         }
< prev index next >