Java Code Examples for com.sun.tools.javac.code.Symbol.MethodSymbol#flags()

The following examples show how to use com.sun.tools.javac.code.Symbol.MethodSymbol#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: SerializedForm.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Names names = def.name.table.names;

    for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol md = (MethodSymbol)e.sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
Example 2
Source File: SerializedForm.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Names names = def.name.table.names;

    for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol md = (MethodSymbol)e.sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
Example 3
Source File: SerializedForm.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Names names = def.name.table.names;

    for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol md = (MethodSymbol)e.sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
Example 4
Source File: SerializedForm.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Names names = def.name.table.names;

    for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol md = (MethodSymbol)e.sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
Example 5
Source File: SerializedForm.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Names names = def.name.table.names;

    for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol md = (MethodSymbol)e.sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
Example 6
Source File: SerializedForm.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Names names = def.name.table.names;

    for (Symbol sym : def.members().getSymbolsByName(names.fromString(methodName))) {
        if (sym.kind == MTH) {
            MethodSymbol md = (MethodSymbol)sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
Example 7
Source File: SerializedForm.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Names names = def.name.table.names;

    for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol md = (MethodSymbol)e.sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
Example 8
Source File: ElementsService.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
    * Returns true if this element represents a method which overrides a
    * method in one of its superclasses.
    */
   public boolean overridesMethod(ExecutableElement element) {
       MethodSymbol m = (MethodSymbol)element;
       if ((m.flags() & Flags.STATIC) == 0) {
           ClassSymbol owner = (ClassSymbol) m.owner;
           for (Type sup = jctypes.supertype(m.owner.type);
                   sup.hasTag(TypeTag.CLASS);
                   sup = jctypes.supertype(sup)) {
               for (Symbol sym : sup.tsym.members().getSymbolsByName(m.name)) {
                   if (m.overrides(sym, owner, jctypes, true)) 
                       return true;
               }
           }
       }
return false;
   }
 
Example 9
Source File: DocEnv.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** Check whether this member should be documented. */
public boolean shouldDocument(MethodSymbol sym) {
    long mod = sym.flags();

    if ((mod & Flags.SYNTHETIC) != 0) {
        return false;
    }

    return showAccess.checkModifier(translateModifiers(mod));
}
 
Example 10
Source File: HandleExtensionMethod.java    From EasyMPermission with MIT License 5 votes vote down vote up
public Extension getExtension(final JavacNode typeNode, final ClassType extensionMethodProviderType) {
	List<MethodSymbol> extensionMethods = new ArrayList<MethodSymbol>();
	TypeSymbol tsym = extensionMethodProviderType.asElement();
	if (tsym != null) for (Symbol member : tsym.getEnclosedElements()) {
		if (member.getKind() != ElementKind.METHOD) continue;
		MethodSymbol method = (MethodSymbol) member;
		if ((method.flags() & (STATIC | PUBLIC)) == 0) continue;
		if (method.params().isEmpty()) continue;
		extensionMethods.add(method);
	}
	return new Extension(extensionMethods, tsym);
}
 
Example 11
Source File: Modules.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
MethodSymbol factoryMethod(ClassSymbol tsym) {
    for (Symbol sym : tsym.members().getSymbolsByName(names.provider, sym -> sym.kind == MTH)) {
        MethodSymbol mSym = (MethodSymbol)sym;
        if (mSym.isStatic() && (mSym.flags() & Flags.PUBLIC) != 0 && mSym.params().isEmpty()) {
            return mSym;
        }
    }
    return null;
}
 
Example 12
Source File: ElementsService.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Element getImplementationOf(ExecutableElement method, TypeElement origin) {
    MethodSymbol msym = (MethodSymbol)method;
    MethodSymbol implmethod = (msym).implementation((TypeSymbol)origin, jctypes, true);
    if ((msym.flags() & Flags.STATIC) != 0) {
        // return null if outside of hierarchy, or the method itself if origin extends method's class
        if (jctypes.isSubtype(((TypeSymbol)origin).type,  ((TypeSymbol)((MethodSymbol)method).owner).type)) {
            return method;
        } else {
            return null;
        }
    }
    if (implmethod == null || implmethod == method) {
        //look for default implementations
        if (allowDefaultMethods) {
            com.sun.tools.javac.util.List<MethodSymbol> candidates = jctypes.interfaceCandidates(((TypeSymbol) origin).type, (MethodSymbol) method);
            X: for (com.sun.tools.javac.util.List<MethodSymbol> ptr = candidates; ptr.head != null; ptr = ptr.tail) {
                MethodSymbol prov = ptr.head;
                if (prov != null && prov.overrides((MethodSymbol) method, (TypeSymbol) origin, jctypes, true) &&
                    hasImplementation(prov)) {
                    // PENDING: even if `prov' overrides the method, there may be a different method, in different interface, that overrides `method'
                    // 'prov' must override all such compatible methods in order to present a valid implementation of `method'.
                    for (com.sun.tools.javac.util.List<MethodSymbol> sibling = candidates; sibling.head != null; sibling = sibling.tail) {
                        MethodSymbol redeclare = sibling.head;

                        // if the default method does not override the alternative candidate from an interface, then the default will be rejected
                        // as specified in JLS #8, par. 8.4.8
                        if (!prov.overrides(redeclare, (TypeSymbol)origin, jctypes, allowDefaultMethods)) {
                            break X;
                        }
                    }
                    implmethod = prov;
                    break;
                }
            }
        }
    }
    return implmethod;
}
 
Example 13
Source File: Modules.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
MethodSymbol factoryMethod(ClassSymbol tsym) {
    for (Symbol sym : tsym.members().getSymbolsByName(names.provider, sym -> sym.kind == MTH)) {
        MethodSymbol mSym = (MethodSymbol)sym;
        if (mSym.isStatic() && (mSym.flags() & Flags.PUBLIC) != 0 && mSym.params().isEmpty()) {
            return mSym;
        }
    }
    return null;
}
 
Example 14
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void checkDefaultMethodClashes(DiagnosticPosition pos, Type site) {
    DefaultMethodClashFilter dcf = new DefaultMethodClashFilter(site);
    for (Symbol m : types.membersClosure(site, false).getSymbols(dcf)) {
        Assert.check(m.kind == MTH);
        List<MethodSymbol> prov = types.interfaceCandidates(site, (MethodSymbol)m);
        if (prov.size() > 1) {
            ListBuffer<Symbol> abstracts = new ListBuffer<>();
            ListBuffer<Symbol> defaults = new ListBuffer<>();
            for (MethodSymbol provSym : prov) {
                if ((provSym.flags() & DEFAULT) != 0) {
                    defaults = defaults.append(provSym);
                } else if ((provSym.flags() & ABSTRACT) != 0) {
                    abstracts = abstracts.append(provSym);
                }
                if (defaults.nonEmpty() && defaults.size() + abstracts.size() >= 2) {
                    //strong semantics - issue an error if two sibling interfaces
                    //have two override-equivalent defaults - or if one is abstract
                    //and the other is default
                    String errKey;
                    Symbol s1 = defaults.first();
                    Symbol s2;
                    if (defaults.size() > 1) {
                        errKey = "types.incompatible.unrelated.defaults";
                        s2 = defaults.toList().tail.head;
                    } else {
                        errKey = "types.incompatible.abstract.default";
                        s2 = abstracts.first();
                    }
                    log.error(pos, errKey,
                            Kinds.kindName(site.tsym), site,
                            m.name, types.memberType(site, m).getParameterTypes(),
                            s1.location(), s2.location());
                    break;
                }
            }
        }
    }
}
 
Example 15
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Check that all abstract members of given class have definitions.
 *  @param pos          Position to be used for error reporting.
 *  @param c            The class.
 */
void checkAllDefined(DiagnosticPosition pos, ClassSymbol c) {
    MethodSymbol undef = types.firstUnimplementedAbstract(c);
    if (undef != null) {
        MethodSymbol undef1 =
            new MethodSymbol(undef.flags(), undef.name,
                             types.memberType(c.type, undef), undef.owner);
        log.error(pos,
                  Errors.DoesNotOverrideAbstract(c, undef1, undef1.location()));
    }
}
 
Example 16
Source File: ElementsService.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static boolean hasImplementation(MethodSymbol msym) {
    long f = msym.flags();
    return ((f & Flags.DEFAULT) != 0) || ((f & Flags.ABSTRACT) == 0);
}
 
Example 17
Source File: Modules.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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 18
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
  * Report warnings for potentially ambiguous method declarations. Two declarations
  * are potentially ambiguous if they feature two unrelated functional interface
  * in same argument position (in which case, a call site passing an implicit
  * lambda would be ambiguous).
  */
void checkPotentiallyAmbiguousOverloads(DiagnosticPosition pos, Type site,
        MethodSymbol msym1, MethodSymbol msym2) {
    if (msym1 != msym2 &&
            allowDefaultMethods &&
            lint.isEnabled(LintCategory.OVERLOADS) &&
            (msym1.flags() & POTENTIALLY_AMBIGUOUS) == 0 &&
            (msym2.flags() & POTENTIALLY_AMBIGUOUS) == 0) {
        Type mt1 = types.memberType(site, msym1);
        Type mt2 = types.memberType(site, msym2);
        //if both generic methods, adjust type variables
        if (mt1.hasTag(FORALL) && mt2.hasTag(FORALL) &&
                types.hasSameBounds((ForAll)mt1, (ForAll)mt2)) {
            mt2 = types.subst(mt2, ((ForAll)mt2).tvars, ((ForAll)mt1).tvars);
        }
        //expand varargs methods if needed
        int maxLength = Math.max(mt1.getParameterTypes().length(), mt2.getParameterTypes().length());
        List<Type> args1 = rs.adjustArgs(mt1.getParameterTypes(), msym1, maxLength, true);
        List<Type> args2 = rs.adjustArgs(mt2.getParameterTypes(), msym2, maxLength, true);
        //if arities don't match, exit
        if (args1.length() != args2.length()) return;
        boolean potentiallyAmbiguous = false;
        while (args1.nonEmpty() && args2.nonEmpty()) {
            Type s = args1.head;
            Type t = args2.head;
            if (!types.isSubtype(t, s) && !types.isSubtype(s, t)) {
                if (types.isFunctionalInterface(s) && types.isFunctionalInterface(t) &&
                        types.findDescriptorType(s).getParameterTypes().length() > 0 &&
                        types.findDescriptorType(s).getParameterTypes().length() ==
                        types.findDescriptorType(t).getParameterTypes().length()) {
                    potentiallyAmbiguous = true;
                } else {
                    break;
                }
            }
            args1 = args1.tail;
            args2 = args2.tail;
        }
        if (potentiallyAmbiguous) {
            //we found two incompatible functional interfaces with same arity
            //this means a call site passing an implicit lambda would be ambigiuous
            msym1.flags_field |= POTENTIALLY_AMBIGUOUS;
            msym2.flags_field |= POTENTIALLY_AMBIGUOUS;
            log.warning(LintCategory.OVERLOADS, pos,
                        Warnings.PotentiallyAmbiguousOverload(msym1, msym1.location(),
                                                              msym2, msym2.location()));
            return;
        }
    }
}
 
Example 19
Source File: Modules.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@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 20
Source File: TransTypes.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/** 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)));
            }
        }
    }
}