< 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();

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

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

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

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

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

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

  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();

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

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

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

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