Java Code Examples for com.sun.tools.javac.code.Symbol#flags()
The following examples show how to use
com.sun.tools.javac.code.Symbol#flags() .
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: LambdaToMethod.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 2
Source File: LambdaToMethod.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 3
Source File: LambdaToMethod.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 4
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** Check that all methods which implement some * method in `ic' conform to the method they implement. */ void checkImplementations(JCTree tree, ClassSymbol origin, ClassSymbol ic) { for (List<Type> l = types.closure(ic.type); l.nonEmpty(); l = l.tail) { ClassSymbol lc = (ClassSymbol)l.head.tsym; if ((lc.flags() & ABSTRACT) != 0) { for (Symbol sym : lc.members().getSymbols(NON_RECURSIVE)) { if (sym.kind == MTH && (sym.flags() & (STATIC|ABSTRACT)) == ABSTRACT) { MethodSymbol absmeth = (MethodSymbol)sym; MethodSymbol implmeth = absmeth.implementation(origin, types, false); if (implmeth != null && implmeth != absmeth && (implmeth.owner.flags() & INTERFACE) == (origin.flags() & INTERFACE)) { // don't check if implmeth is in a class, yet // origin is an interface. This case arises only // if implmeth is declared in Object. The reason is // that interfaces really don't inherit from // Object it's just that the compiler represents // things that way. checkOverride(tree, implmeth, absmeth, origin); } } } } } }
Example 5
Source File: LambdaToMethod.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 6
Source File: LambdaToMethod.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 7
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
public boolean importAccessible(Symbol sym, PackageSymbol packge) { try { int flags = (int)(sym.flags() & AccessFlags); switch (flags) { default: case PUBLIC: return true; case PRIVATE: return false; case 0: case PROTECTED: return sym.packge() == packge; } } catch (ClassFinder.BadClassFile err) { throw err; } catch (CompletionFailure ex) { return false; } }
Example 8
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
private boolean isEffectivelyNonPublic(Symbol sym) { if (sym.packge() == syms.rootPackage) { return false; } while (sym.kind != PCK) { if ((sym.flags() & PUBLIC) == 0) { return true; } sym = sym.owner; } return false; }
Example 9
Source File: JavacElements.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @DefinedBy(Api.LANGUAGE_MODEL) public Origin getOrigin(Element e) { Symbol sym = cast(Symbol.class, e); if ((sym.flags() & Flags.GENERATEDCONSTR) != 0) return Origin.MANDATED; //TypeElement.getEnclosedElements does not return synthetic elements, //and most synthetic elements are not read from the classfile anyway: return Origin.EXPLICIT; }
Example 10
Source File: ResolveHarness.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override void process(Diagnostic<? extends JavaFileObject> diagnostic) { Symbol methodSym = (Symbol)methodSym(diagnostic); if ((methodSym.flags() & Flags.GENERATEDCONSTR) != 0) { //skip resolution of default constructor (put there by javac) return; } Candidate c = getCandidateAtPos(methodSym, asJCDiagnostic(diagnostic).getLineNumber(), asJCDiagnostic(diagnostic).getColumnNumber()); if (c == null) { return; //nothing to check } if (c.applicable().length == 0 && c.mostSpecific()) { error("Inapplicable method cannot be most specific " + methodSym); } if (isApplicable(diagnostic) != Arrays.asList(c.applicable()).contains(phase)) { error("Invalid candidate's applicability " + methodSym); } if (success) { for (Phase p : c.applicable()) { if (phase.ordinal() < p.ordinal()) { error("Invalid phase " + p + " on method " + methodSym); } } } if (Arrays.asList(c.applicable()).contains(phase)) { //applicable if (c.mostSpecific() != mostSpecific) { error("Invalid most specific value for method " + methodSym + " " + new ElementKey(methodSym).key); } MethodType mtype = getSig(diagnostic); if (mtype != null) { checkSig(c, methodSym, mtype); } } }
Example 11
Source File: ResolveHarness.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override void process(Diagnostic<? extends JavaFileObject> diagnostic) { Symbol methodSym = (Symbol)methodSym(diagnostic); if ((methodSym.flags() & Flags.GENERATEDCONSTR) != 0) { //skip resolution of default constructor (put there by javac) return; } Candidate c = getCandidateAtPos(methodSym, asJCDiagnostic(diagnostic).getLineNumber(), asJCDiagnostic(diagnostic).getColumnNumber()); if (c == null) { return; //nothing to check } if (c.applicable().length == 0 && c.mostSpecific()) { error("Inapplicable method cannot be most specific " + methodSym); } if (isApplicable(diagnostic) != Arrays.asList(c.applicable()).contains(phase)) { error("Invalid candidate's applicability " + methodSym); } if (success) { for (Phase p : c.applicable()) { if (phase.ordinal() < p.ordinal()) { error("Invalid phase " + p + " on method " + methodSym); } } } if (Arrays.asList(c.applicable()).contains(phase)) { //applicable if (c.mostSpecific() != mostSpecific) { error("Invalid most specific value for method " + methodSym + " " + new ElementKey(methodSym).key); } MethodType mtype = getSig(diagnostic); if (mtype != null) { checkSig(c, methodSym, mtype); } } }
Example 12
Source File: TypePrinter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Converts a class name into a (possibly localized) string. Anonymous inner * classes get converted into a localized string. * * @param t the type of the class whose name is to be rendered * @param longform if set, the class' fullname is displayed - if unset the * short name is chosen (w/o package) * @param locale the locale in which the string is to be rendered * @return localized string representation */ @Override protected String className(ClassType t, boolean longform, Locale locale) { Symbol sym = t.tsym; if (sym.name.length() == 0 && (sym.flags() & COMPOUND) != 0) { return OBJECT; } else if (sym.name.length() == 0) { // Anonymous String s; ClassType norm = (ClassType) t.tsym.type; if (norm == null) { s = OBJECT; } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) { s = visit(norm.interfaces_field.head, locale); } else { s = visit(norm.supertype_field, locale); } return s; } else if (longform) { String pkg = ""; for (Symbol psym = sym; psym != null; psym = psym.owner) { if (psym.kind == PCK) { pkg = psym.getQualifiedName().toString(); break; } } return fullClassNameAndPackageToClass.apply( sym.getQualifiedName().toString(), pkg ); } else { return sym.name.toString(); } }
Example 13
Source File: ResolveHarness.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override void process(Diagnostic<? extends JavaFileObject> diagnostic) { Symbol methodSym = (Symbol)methodSym(diagnostic); if ((methodSym.flags() & Flags.GENERATEDCONSTR) != 0) { //skip resolution of default constructor (put there by javac) return; } Candidate c = getCandidateAtPos(methodSym, asJCDiagnostic(diagnostic).getLineNumber(), asJCDiagnostic(diagnostic).getColumnNumber()); if (c == null) { return; //nothing to check } if (c.applicable().length == 0 && c.mostSpecific()) { error("Inapplicable method cannot be most specific " + methodSym); } if (isApplicable(diagnostic) != Arrays.asList(c.applicable()).contains(phase)) { error("Invalid candidate's applicability " + methodSym); } if (success) { for (Phase p : c.applicable()) { if (phase.ordinal() < p.ordinal()) { error("Invalid phase " + p + " on method " + methodSym); } } } if (Arrays.asList(c.applicable()).contains(phase)) { //applicable if (c.mostSpecific() != mostSpecific) { error("Invalid most specific value for method " + methodSym + " " + new ElementKey(methodSym).key); } MethodType mtype = getSig(diagnostic); if (mtype != null) { checkSig(c, methodSym, mtype); } } }
Example 14
Source File: Lower.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** The qualifier to be used for accessing a symbol in an outer class. * This is either C.sym or C.this.sym, depending on whether or not * sym is static. * @param sym The accessed symbol. */ JCExpression accessBase(DiagnosticPosition pos, Symbol sym) { return (sym.flags() & STATIC) != 0 ? access(make.at(pos.getStartPosition()).QualIdent(sym.owner)) : makeOwnerThis(pos, sym, true); }
Example 15
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** Is the annotation applicable to the symbol? */ boolean annotationApplicable(JCAnnotation a, Symbol s) { Attribute.Array arr = getAttributeTargetAttribute(a.annotationType.type.tsym); Name[] targets; if (arr == null) { targets = defaultTargetMetaInfo(a, s); } else { // TODO: can we optimize this? targets = new Name[arr.values.length]; for (int i=0; i<arr.values.length; ++i) { Attribute app = arr.values[i]; if (!(app instanceof Attribute.Enum)) { return true; // recovery } Attribute.Enum e = (Attribute.Enum) app; targets[i] = e.value.name; } } for (Name target : targets) { if (target == names.TYPE) { if (s.kind == TYP) return true; } else if (target == names.FIELD) { if (s.kind == VAR && s.owner.kind != MTH) return true; } else if (target == names.METHOD) { if (s.kind == MTH && !s.isConstructor()) return true; } else if (target == names.PARAMETER) { if (s.kind == VAR && s.owner.kind == MTH && (s.flags() & PARAMETER) != 0) { return true; } } else if (target == names.CONSTRUCTOR) { if (s.kind == MTH && s.isConstructor()) return true; } else if (target == names.LOCAL_VARIABLE) { if (s.kind == VAR && s.owner.kind == MTH && (s.flags() & PARAMETER) == 0) { return true; } } else if (target == names.ANNOTATION_TYPE) { if (s.kind == TYP && (s.flags() & ANNOTATION) != 0) { return true; } } else if (target == names.PACKAGE) { if (s.kind == PCK) return true; } else if (target == names.TYPE_USE) { if (s.kind == VAR && s.owner.kind == MTH && s.type.hasTag(NONE)) { //cannot type annotate implictly typed locals return false; } else if (s.kind == TYP || s.kind == VAR || (s.kind == MTH && !s.isConstructor() && !s.type.getReturnType().hasTag(VOID)) || (s.kind == MTH && s.isConstructor())) { return true; } } else if (target == names.TYPE_PARAMETER) { if (s.kind == TYP && s.type.hasTag(TYPEVAR)) return true; } else return true; // Unknown ElementType. This should be an error at declaration site, // assume applicable. } return false; }
Example 16
Source File: JNIWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
static private boolean hasFlag(Symbol m, int flag) { return (m.flags() & flag) != 0; }
Example 17
Source File: FilteredMemberList.java From openjdk-jdk8u with GNU General Public License v2.0 | 2 votes |
/** * Tests whether this is a symbol that should never be seen by * clients, such as a synthetic class. Returns true for null. */ private static boolean unwanted(Symbol s) { return s == null || (s.flags() & SYNTHETIC) != 0; }
Example 18
Source File: FilteredMemberList.java From openjdk-8-source with GNU General Public License v2.0 | 2 votes |
/** * Tests whether this is a symbol that should never be seen by * clients, such as a synthetic class. Returns true for null. */ private static boolean unwanted(Symbol s) { return s == null || (s.flags() & SYNTHETIC) != 0; }
Example 19
Source File: FilteredMemberList.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Tests whether this is a symbol that should never be seen by * clients, such as a synthetic class. Returns true for null. */ private static boolean unwanted(Symbol s) { return s == null || (s.flags() & SYNTHETIC) != 0; }
Example 20
Source File: FilteredMemberList.java From openjdk-8 with GNU General Public License v2.0 | 2 votes |
/** * Tests whether this is a symbol that should never be seen by * clients, such as a synthetic class. Returns true for null. */ private static boolean unwanted(Symbol s) { return s == null || (s.flags() & SYNTHETIC) != 0; }