Java Code Examples for com.sun.tools.javac.code.Symbol.ClassSymbol#isSubClass()
The following examples show how to use
com.sun.tools.javac.code.Symbol.ClassSymbol#isSubClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Lower.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** The class in which an access method for given symbol goes. * @param sym The access symbol * @param protAccess Is access to a protected symbol in another * package? */ ClassSymbol accessClass(Symbol sym, boolean protAccess, JCTree tree) { if (protAccess) { Symbol qualifier = null; ClassSymbol c = currentClass; if (tree.hasTag(SELECT) && (sym.flags() & STATIC) == 0) { qualifier = ((JCFieldAccess) tree).selected.type.tsym; while (!qualifier.isSubClass(c, types)) { c = c.owner.enclClass(); } return c; } else { while (!c.isSubClass(sym.owner, types)) { c = c.owner.enclClass(); } } return c; } else { // the symbol is private return sym.owner.enclClass(); } }
Example 2
Source File: JavacElements.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@DefinedBy(Api.LANGUAGE_MODEL) public boolean hides(Element hiderEl, Element hideeEl) { Symbol hider = cast(Symbol.class, hiderEl); Symbol hidee = cast(Symbol.class, hideeEl); // Fields only hide fields; methods only methods; types only types. // Names must match. Nothing hides itself (just try it). if (hider == hidee || hider.kind != hidee.kind || hider.name != hidee.name) { return false; } // Only static methods can hide other methods. // Methods only hide methods with matching signatures. if (hider.kind == MTH) { if (!hider.isStatic() || !types.isSubSignature(hider.type, hidee.type)) { return false; } } // Hider must be in a subclass of hidee's class. // Note that if M1 hides M2, and M2 hides M3, and M3 is accessible // in M1's class, then M1 and M2 both hide M3. ClassSymbol hiderClass = hider.owner.enclClass(); ClassSymbol hideeClass = hidee.owner.enclClass(); if (hiderClass == null || hideeClass == null || !hiderClass.isSubClass(hideeClass, types)) { return false; } // Hidee must be accessible in hider's class. // The method isInheritedIn is poorly named: it checks only access. return hidee.isInheritedIn(hiderClass, types); }
Example 3
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Is exc an exception symbol that need not be declared? */ boolean isUnchecked(ClassSymbol exc) { return exc.kind == ERR || exc.isSubClass(syms.errorType.tsym, types) || exc.isSubClass(syms.runtimeExceptionType.tsym, types); }
Example 4
Source File: Lower.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
ClassSymbol ownerToCopyFreeVarsFrom(ClassSymbol c) { if (!c.isLocal()) { return null; } Symbol currentOwner = c.owner; while (currentOwner.owner.kind.matches(KindSelector.TYP) && currentOwner.isLocal()) { currentOwner = currentOwner.owner; } if (currentOwner.owner.kind.matches(KindSelector.VAL_MTH) && c.isSubClass(currentOwner, types)) { return (ClassSymbol)currentOwner; } return null; }
Example 5
Source File: LambdaToMethod.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Return the declaration corresponding to a symbol in the enclosing * scope; the depth parameter is used to filter out symbols defined * in nested scopes (which do not need to undergo capture). */ private JCTree capturedDecl(int depth, Symbol sym) { int currentDepth = frameStack.size() - 1; for (Frame block : frameStack) { switch (block.tree.getTag()) { case CLASSDEF: ClassSymbol clazz = ((JCClassDecl)block.tree).sym; if (clazz.isSubClass(sym, types) || sym.isMemberOf(clazz, types)) { return currentDepth > depth ? null : block.tree; } break; case VARDEF: if (((JCVariableDecl)block.tree).sym == sym && sym.owner.kind == MTH) { //only locals are captured return currentDepth > depth ? null : block.tree; } break; case BLOCK: case METHODDEF: case LAMBDA: if (block.locals != null && block.locals.contains(sym)) { return currentDepth > depth ? null : block.tree; } break; default: Assert.error("bad decl kind " + block.tree.getTag()); } currentDepth--; } return null; }
Example 6
Source File: LambdaToMethod.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Return the declaration corresponding to a symbol in the enclosing * scope; the depth parameter is used to filter out symbols defined * in nested scopes (which do not need to undergo capture). */ private JCTree capturedDecl(int depth, Symbol sym) { int currentDepth = frameStack.size() - 1; for (Frame block : frameStack) { switch (block.tree.getTag()) { case CLASSDEF: ClassSymbol clazz = ((JCClassDecl)block.tree).sym; if (clazz.isSubClass(sym, types) || sym.isMemberOf(clazz, types)) { return currentDepth > depth ? null : block.tree; } break; case VARDEF: if (((JCVariableDecl)block.tree).sym == sym && sym.owner.kind == MTH) { //only locals are captured return currentDepth > depth ? null : block.tree; } break; case BLOCK: case METHODDEF: case LAMBDA: if (block.locals != null && block.locals.contains(sym)) { return currentDepth > depth ? null : block.tree; } break; default: Assert.error("bad decl kind " + block.tree.getTag()); } currentDepth--; } return null; }