Java Code Examples for com.sun.tools.javac.code.Symbol.ClassSymbol#isInner()
The following examples show how to use
com.sun.tools.javac.code.Symbol.ClassSymbol#isInner() .
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 | 5 votes |
/** Definition for this$n field. * @param pos The source code position of the definition. * @param owner The method in which the definition goes. */ JCVariableDecl outerThisDef(int pos, MethodSymbol owner) { ClassSymbol c = owner.enclClass(); boolean isMandated = // Anonymous constructors (owner.isConstructor() && owner.isAnonymous()) || // Constructors of non-private inner member classes (owner.isConstructor() && c.isInner() && !c.isPrivate() && !c.isStatic()); long flags = FINAL | (isMandated ? MANDATED : SYNTHETIC) | PARAMETER; VarSymbol outerThis = makeOuterThisVarSymbol(owner, flags); owner.extraParams = owner.extraParams.prepend(outerThis); return makeOuterThisVarDecl(pos, outerThis); }
Example 2
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 3
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); } }