Java Code Examples for com.sun.tools.javac.code.Symbol.ClassSymbol#flags()
The following examples show how to use
com.sun.tools.javac.code.Symbol.ClassSymbol#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: JNIWriter.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 2
Source File: JNIWriter.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 3
Source File: JNIWriter.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 4
Source File: JNIWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 5
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private boolean isDeprecatedOverrideIgnorable(MethodSymbol m, ClassSymbol origin) { // If the method, m, is defined in an interface, then ignore the issue if the method // is only inherited via a supertype and also implemented in the supertype, // because in that case, we will rediscover the issue when examining the method // in the supertype. // If the method, m, is not defined in an interface, then the only time we need to // address the issue is when the method is the supertype implemementation: any other // case, we will have dealt with when examining the supertype classes ClassSymbol mc = m.enclClass(); Type st = types.supertype(origin.type); if (!st.hasTag(CLASS)) return true; MethodSymbol stimpl = m.implementation((ClassSymbol)st.tsym, types, false); if (mc != null && ((mc.flags() & INTERFACE) != 0)) { List<Type> intfs = types.interfaces(origin.type); return (intfs.contains(mc.type) ? false : (stimpl != null)); } else return (stimpl != m); }
Example 6
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void checkClassOverrideEqualsAndHashIfNeeded(DiagnosticPosition pos, ClassSymbol someClass) { /* At present, annotations cannot possibly have a method that is override * equivalent with Object.equals(Object) but in any case the condition is * fine for completeness. */ if (someClass == (ClassSymbol)syms.objectType.tsym || someClass.isInterface() || someClass.isEnum() || (someClass.flags() & ANNOTATION) != 0 || (someClass.flags() & ABSTRACT) != 0) return; //anonymous inner classes implementing interfaces need especial treatment if (someClass.isAnonymous()) { List<Type> interfaces = types.interfaces(someClass.type); if (interfaces != null && !interfaces.isEmpty() && interfaces.head.tsym == syms.comparatorType.tsym) return; } checkClassOverrideEqualsAndHash(pos, someClass); }
Example 7
Source File: JNIWriter.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 8
Source File: JNIWriter.java From hottub with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 9
Source File: JNIWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 10
Source File: JNIWriter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public boolean needsHeader(ClassSymbol c) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; if (checkAll) return needsHeader(c.outermostClass(), true); else return needsHeader(c, false); }
Example 11
Source File: JNIWriter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public boolean needsHeader(ClassSymbol c) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; if (checkAll) return needsHeader(c.outermostClass(), true); else return needsHeader(c, false); }
Example 12
Source File: JNIWriter.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public boolean needsHeader(ClassSymbol c) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; if (checkAll) return needsHeader(c.outermostClass(), true); else return needsHeader(c, false); }
Example 13
Source File: JNIWriter.java From hottub with GNU General Public License v2.0 | 5 votes |
public boolean needsHeader(ClassSymbol c) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; if (checkAll) return needsHeader(c.outermostClass(), true); else return needsHeader(c, false); }
Example 14
Source File: JNIWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public boolean needsHeader(ClassSymbol c) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; if (checkAll) return needsHeader(c.outermostClass(), true); else return needsHeader(c, false); }
Example 15
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Check that an auxiliary class is not accessed from any other file than its own. */ void checkForBadAuxiliaryClassAccess(DiagnosticPosition pos, Env<AttrContext> env, ClassSymbol c) { if (lint.isEnabled(Lint.LintCategory.AUXILIARYCLASS) && (c.flags() & AUXILIARY) != 0 && rs.isAccessible(env, c) && !fileManager.isSameFile(c.sourcefile, env.toplevel.sourcefile)) { log.warning(pos, Warnings.AuxiliaryClassAccessedFromOutsideOfItsSourceFile(c, c.sourcefile)); } }
Example 16
Source File: JNIWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public boolean needsHeader(ClassSymbol c) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; if (checkAll) return needsHeader(c.outermostClass(), true); else return needsHeader(c, false); }
Example 17
Source File: JNIWriter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public boolean needsHeader(ClassSymbol c) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; if (checkAll) return needsHeader(c.outermostClass(), true); else return needsHeader(c, false); }
Example 18
Source File: Modules.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public void visitProvides(JCProvides tree) { Type st = attr.attribType(tree.serviceName, env, syms.objectType); ClassSymbol service = (ClassSymbol) st.tsym; if (allProvides.containsKey(service)) { log.error(tree.serviceName.pos(), Errors.RepeatedProvidesForService(service)); } ListBuffer<ClassSymbol> impls = new ListBuffer<>(); for (JCExpression implName : tree.implNames) { Type it; boolean prevVisitingServiceImplementation = env.info.visitingServiceImplementation; try { env.info.visitingServiceImplementation = true; it = attr.attribType(implName, env, syms.objectType); } finally { env.info.visitingServiceImplementation = prevVisitingServiceImplementation; } ClassSymbol impl = (ClassSymbol) it.tsym; if ((impl.flags_field & PUBLIC) == 0) { log.error(implName.pos(), Errors.NotDefPublic(impl, impl.location())); } //find provider factory: MethodSymbol factory = factoryMethod(impl); if (factory != null) { Type returnType = factory.type.getReturnType(); if (!types.isSubtype(returnType, st)) { log.error(implName.pos(), Errors.ServiceImplementationProviderReturnMustBeSubtypeOfServiceInterface); } } else { if (!types.isSubtype(it, st)) { log.error(implName.pos(), Errors.ServiceImplementationMustBeSubtypeOfServiceInterface); } else if ((impl.flags() & ABSTRACT) != 0) { log.error(implName.pos(), Errors.ServiceImplementationIsAbstract(impl)); } else if (impl.isInner()) { log.error(implName.pos(), Errors.ServiceImplementationIsInner(impl)); } else { MethodSymbol constr = noArgsConstructor(impl); if (constr == null) { log.error(implName.pos(), Errors.ServiceImplementationDoesntHaveANoArgsConstructor(impl)); } else if ((constr.flags() & PUBLIC) == 0) { log.error(implName.pos(), Errors.ServiceImplementationNoArgsConstructorNotPublic(impl)); } } } if (it.hasTag(CLASS)) { if (allProvides.computeIfAbsent(service, s -> new HashSet<>()).add(impl)) { impls.append(impl); } else { log.error(implName.pos(), Errors.DuplicateProvides(service, impl)); } } } if (st.hasTag(CLASS) && !impls.isEmpty()) { Directive.ProvidesDirective d = new Directive.ProvidesDirective(service, impls.toList()); msym.provides = msym.provides.prepend(d); msym.directives = msym.directives.prepend(d); directiveToTreeMap.put(d, tree); } }
Example 19
Source File: Modules.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void visitProvides(JCProvides tree) { Type st = attr.attribType(tree.serviceName, env, syms.objectType); ClassSymbol service = (ClassSymbol) st.tsym; if (allProvides.containsKey(service)) { log.error(tree.serviceName.pos(), Errors.RepeatedProvidesForService(service)); } ListBuffer<ClassSymbol> impls = new ListBuffer<>(); for (JCExpression implName : tree.implNames) { Type it; boolean prevVisitingServiceImplementation = env.info.visitingServiceImplementation; try { env.info.visitingServiceImplementation = true; it = attr.attribType(implName, env, syms.objectType); } finally { env.info.visitingServiceImplementation = prevVisitingServiceImplementation; } ClassSymbol impl = (ClassSymbol) it.tsym; if ((impl.flags_field & PUBLIC) == 0) { log.error(implName.pos(), Errors.NotDefPublic(impl, impl.location())); } //find provider factory: MethodSymbol factory = factoryMethod(impl); if (factory != null) { Type returnType = factory.type.getReturnType(); if (!types.isSubtype(returnType, st)) { log.error(implName.pos(), Errors.ServiceImplementationProviderReturnMustBeSubtypeOfServiceInterface); } } else { if (!types.isSubtype(it, st)) { log.error(implName.pos(), Errors.ServiceImplementationMustBeSubtypeOfServiceInterface); } else if ((impl.flags() & ABSTRACT) != 0) { log.error(implName.pos(), Errors.ServiceImplementationIsAbstract(impl)); } else if (impl.isInner()) { log.error(implName.pos(), Errors.ServiceImplementationIsInner(impl)); } else { MethodSymbol constr = noArgsConstructor(impl); if (constr == null) { log.error(implName.pos(), Errors.ServiceImplementationDoesntHaveANoArgsConstructor(impl)); } else if ((constr.flags() & PUBLIC) == 0) { log.error(implName.pos(), Errors.ServiceImplementationNoArgsConstructorNotPublic(impl)); } } } if (it.hasTag(CLASS)) { if (Maps.computeIfAbsent(allProvides,service, s -> new HashSet<>()).add(impl)) { impls.append(impl); } else { log.error(implName.pos(), Errors.DuplicateProvides(service, impl)); } } } if (st.hasTag(CLASS) && !impls.isEmpty()) { Directive.ProvidesDirective d = new Directive.ProvidesDirective(service, impls.toList()); msym.provides = msym.provides.prepend(d); msym.directives = msym.directives.prepend(d); directiveToTreeMap.put(d, tree); } }
Example 20
Source File: TransTypes.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** Add bridge if given symbol is a non-private, non-static member * of the given class, which is either defined in the class or non-final * inherited, and one of the two following conditions holds: * 1. The method's type changes in the given class, as compared to the * class where the symbol was defined, (in this case * we have extended a parameterized class with non-trivial parameters). * 2. The method has an implementation with a different erased return type. * (in this case we have used co-variant returns). * If a bridge already exists in some other class, no new bridge is added. * Instead, it is checked that the bridge symbol overrides the method symbol. * (Spec ???). * todo: what about bridges for privates??? * * @param pos The source code position to be used for the definition. * @param sym The symbol for which a bridge might have to be added. * @param origin The class in which the bridge would go. * @param bridges The list buffer to which the bridge would be added. */ void addBridgeIfNeeded(DiagnosticPosition pos, Symbol sym, ClassSymbol origin, ListBuffer<JCTree> bridges) { if (sym.kind == MTH && sym.name != names.init && (sym.flags() & (PRIVATE | STATIC)) == 0 && (sym.flags() & SYNTHETIC) != SYNTHETIC && sym.isMemberOf(origin, types)) { MethodSymbol meth = (MethodSymbol)sym; MethodSymbol bridge = meth.binaryImplementation(origin, types); MethodSymbol impl = meth.implementation(origin, types, true); if (bridge == null || bridge == meth || (impl != null && !bridge.owner.isSubClass(impl.owner, types))) { // No bridge was added yet. if (impl != null && isBridgeNeeded(meth, impl, origin.type)) { addBridge(pos, meth, impl, origin, bridge==impl, bridges); } else if (impl == meth && impl.owner != origin && (impl.flags() & FINAL) == 0 && (meth.flags() & (ABSTRACT|PUBLIC)) == PUBLIC && (origin.flags() & PUBLIC) > (impl.owner.flags() & PUBLIC)) { // this is to work around a horrible but permanent // reflection design error. addBridge(pos, meth, impl, origin, false, bridges); } } else if ((bridge.flags() & SYNTHETIC) == SYNTHETIC) { final Pair<MethodSymbol, MethodSymbol> bridgeSpan = bridgeSpans.get(bridge); MethodSymbol other = bridgeSpan == null ? null : bridgeSpan.fst; if (other != null && other != meth) { if (impl == null || !impl.overrides(other, origin, types, true)) { // Is bridge effectively also the bridge for `meth', if so no clash. MethodSymbol target = bridgeSpan == null ? null : bridgeSpan.snd; if (target == null || !target.overrides(meth, origin, types, true, false)) { // Bridge for other symbol pair was added log.error(pos, Errors.NameClashSameErasureNoOverride( other.name, types.memberType(origin.type, other).asMethodType().getParameterTypes(), other.location(origin.type, types), meth.name, types.memberType(origin.type, meth).asMethodType().getParameterTypes(), meth.location(origin.type, types))); } } } } else if (!bridge.overrides(meth, origin, types, true)) { // Accidental binary override without source override. // Don't diagnose the problem if it would already // have been reported in the superclass if (bridge.owner == origin || types.asSuper(bridge.owner.type, meth.owner) == null) { log.error(pos, Errors.NameClashSameErasureNoOverride( bridge.name, types.memberType(origin.type, bridge).asMethodType().getParameterTypes(), bridge.location(origin.type, types), meth.name, types.memberType(origin.type, meth).asMethodType().getParameterTypes(), meth.location(origin.type, types))); } } } }