< prev index next >

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

Print this page




 551                     (sym.flags() & STATIC) != 0 &&
 552                     types.isSubSignature(sym.type, type))) {
 553                 return sym;
 554             }
 555         }
 556         Symbol hiddenSym = null;
 557         for (Type st : types.interfaces(currentClass.type)
 558                 .prepend(types.supertype(currentClass.type))) {
 559             if (st != null && (st.hasTag(CLASS))) {
 560                 Symbol sym = hiddenInInternal((ClassSymbol)st.tsym, types);
 561                 if (sym == this) {
 562                     return this;
 563                 } else if (sym != null) {
 564                     hiddenSym = sym;
 565                 }
 566             }
 567         }
 568         return hiddenSym;
 569     }
 570 
 571     /** Is this symbol inherited into a given class?
 572      *  PRE: If symbol's owner is a interface,
 573      *       it is already assumed that the interface is a superinterface
 574      *       of given class.
 575      *  @param clazz  The class for which we want to establish membership.
 576      *                This must be a subclass of the member's owner.
 577      */
 578     public boolean isInheritedIn(Symbol clazz, Types types) {
 579         switch ((int)(flags_field & Flags.AccessFlags)) {
 580         default: // error recovery
 581         case PUBLIC:
 582             return true;
 583         case PRIVATE:
 584             return this.owner == clazz;
 585         case PROTECTED:
 586             // we model interfaces as extending Object
 587             return (clazz.flags() & INTERFACE) == 0;
 588         case 0:
 589             PackageSymbol thisPackage = this.packge();
 590             for (Symbol sup = clazz;
 591                  sup != null && sup != this.owner;
 592                  sup = types.supertype(sup.type).tsym) {
 593                 while (sup.type.hasTag(TYPEVAR))
 594                     sup = sup.type.getUpperBound().tsym;
 595                 if (sup.type.isErroneous())
 596                     return true; // error recovery
 597                 if ((sup.flags() & COMPOUND) != 0)
 598                     continue;
 599                 if (sup.packge() != thisPackage)
 600                     return false;
 601             }
 602             return (clazz.flags() & INTERFACE) == 0;
 603         }











 604     }
 605 
 606     /** The (variable or method) symbol seen as a member of given
 607      *  class type`site' (this might change the symbol's type).
 608      *  This is used exclusively for producing diagnostics.
 609      */
 610     public Symbol asMemberOf(Type site, Types types) {
 611         throw new AssertionError();
 612     }
 613 
 614     /** Does this method symbol override `other' symbol, when both are seen as
 615      *  members of class `origin'?  It is assumed that _other is a member
 616      *  of origin.
 617      *
 618      *  It is assumed that both symbols have the same name.  The static
 619      *  modifier is ignored for this test.
 620      *
 621      *  See JLS 8.4.6.1 (without transitivity) and 8.4.6.4
 622      */
 623     public boolean overrides(Symbol _other, TypeSymbol origin, Types types, boolean checkResult) {




 551                     (sym.flags() & STATIC) != 0 &&
 552                     types.isSubSignature(sym.type, type))) {
 553                 return sym;
 554             }
 555         }
 556         Symbol hiddenSym = null;
 557         for (Type st : types.interfaces(currentClass.type)
 558                 .prepend(types.supertype(currentClass.type))) {
 559             if (st != null && (st.hasTag(CLASS))) {
 560                 Symbol sym = hiddenInInternal((ClassSymbol)st.tsym, types);
 561                 if (sym == this) {
 562                     return this;
 563                 } else if (sym != null) {
 564                     hiddenSym = sym;
 565                 }
 566             }
 567         }
 568         return hiddenSym;
 569     }
 570 
 571     /** Is this symbol accessible in a given class?
 572      *  PRE: If symbol's owner is a interface,
 573      *       it is already assumed that the interface is a superinterface
 574      *       the given class.
 575      *  @param clazz  The class for which we want to establish membership.
 576      *                This must be a subclass of the member's owner.
 577      */
 578     public boolean isAccessibleIn(Symbol clazz, Types types) {
 579         switch ((int)(flags_field & Flags.AccessFlags)) {
 580         default: // error recovery
 581         case PUBLIC:
 582             return true;
 583         case PRIVATE:
 584             return this.owner == clazz;
 585         case PROTECTED:
 586             // we model interfaces as extending Object
 587             return (clazz.flags() & INTERFACE) == 0;
 588         case 0:
 589             PackageSymbol thisPackage = this.packge();
 590             for (Symbol sup = clazz;
 591                  sup != null && sup != this.owner;
 592                  sup = types.supertype(sup.type).tsym) {
 593                 while (sup.type.hasTag(TYPEVAR))
 594                     sup = sup.type.getUpperBound().tsym;
 595                 if (sup.type.isErroneous())
 596                     return true; // error recovery
 597                 if ((sup.flags() & COMPOUND) != 0)
 598                     continue;
 599                 if (sup.packge() != thisPackage)
 600                     return false;
 601             }
 602             return (clazz.flags() & INTERFACE) == 0;
 603         }
 604     }
 605 
 606     /** Is this symbol inherited into a given class?
 607      *  PRE: If symbol's owner is a interface,
 608      *       it is already assumed that the interface is a superinterface
 609      *       of given class.
 610      *  @param clazz  The class for which we want to establish membership.
 611      *                This must be a subclass of the member's owner.
 612      */
 613     public boolean isInheritedIn(Symbol clazz, Types types) {
 614         return isAccessibleIn(clazz, types);
 615     }
 616 
 617     /** The (variable or method) symbol seen as a member of given
 618      *  class type`site' (this might change the symbol's type).
 619      *  This is used exclusively for producing diagnostics.
 620      */
 621     public Symbol asMemberOf(Type site, Types types) {
 622         throw new AssertionError();
 623     }
 624 
 625     /** Does this method symbol override `other' symbol, when both are seen as
 626      *  members of class `origin'?  It is assumed that _other is a member
 627      *  of origin.
 628      *
 629      *  It is assumed that both symbols have the same name.  The static
 630      *  modifier is ignored for this test.
 631      *
 632      *  See JLS 8.4.6.1 (without transitivity) and 8.4.6.4
 633      */
 634     public boolean overrides(Symbol _other, TypeSymbol origin, Types types, boolean checkResult) {


< prev index next >