private MethodSymbol searchMethod(ClassSymbol tsym, Name methodName,
                                       List<Type> paramTypes, Set<ClassSymbol> searched) {
        //### Note that this search is not necessarily what the compiler would do!

        // do not match constructors
        if (methodName == names.init)
            return null;

        if (searched.contains(tsym))
            return null;
        searched.add(tsym);

        // search current class

        //### Using modifier filter here isn't really correct,
        //### but emulates the old behavior.  Instead, we should
        //### apply the normal rules of visibility and inheritance.

        if (paramTypes == null) {
            // If no parameters specified, we are allowed to return
            // any method with a matching name.  In practice, the old
            // code returned the first method, which is now the last!
            // In order to provide textually identical results, we
            // attempt to emulate the old behavior.
            MethodSymbol lastFound = null;
            for (Symbol sym : tsym.members().getSymbolsByName(methodName)) {
                if (sym.kind == MTH) {
                    if (sym.name == methodName) {
                        lastFound = (MethodSymbol)sym;
                    }
                }
            }
            if (lastFound != null) {
                return lastFound;
            }
        } else {
            for (Symbol sym : tsym.members().getSymbolsByName(methodName)) {
                if (sym != null &&
                    sym.kind == MTH) {
                    if (hasParameterTypes((MethodSymbol) sym, paramTypes)) {
                        return (MethodSymbol) sym;
                    }
                }
            }
        }

        //### If we found a MethodSymbol above, but which did not pass
        //### the modifier filter, we should return failure here!

        // search superclass
        Type superclass = tsym.getSuperclass();
        if (superclass.tsym != null) {
            MethodSymbol msym = searchMethod((ClassSymbol) superclass.tsym, methodName, paramTypes, searched);
            if (msym != null) {
                return msym;
            }
        }

        // search interfaces
        List<Type> intfs = tsym.getInterfaces();
        for (List<Type> l = intfs; l.nonEmpty(); l = l.tail) {
            Type intf = l.head;
            if (intf.isErroneous()) continue;
            MethodSymbol msym = searchMethod((ClassSymbol) intf.tsym, methodName, paramTypes, searched);
            if (msym != null) {
                return msym;
            }
        }

        // search enclosing class
        ClassSymbol encl = tsym.owner.enclClass();
        if (encl != null) {
            MethodSymbol msym = searchMethod(encl, methodName, paramTypes, searched);
            if (msym != null) {
                return msym;
            }
        }

        return null;
    }
private MethodSymbol searchMethod ( ClassSymbol tsym , Name methodName , List < Type > paramTypes , Set < ClassSymbol > searched ) { if ( methodName == names . init ) return null ; if ( searched . contains ( tsym ) ) return null ; searched . add ( tsym ) ; if ( paramTypes == null ) { MethodSymbol lastFound = null ; for ( Symbol sym : tsym . members ( ) . getSymbolsByName ( methodName ) ) { if ( sym . kind == MTH ) { if ( sym . name == methodName ) { lastFound = ( MethodSymbol ) sym ; } } } if ( lastFound != null ) { return lastFound ; } } else { for ( Symbol sym : tsym . members ( ) . getSymbolsByName ( methodName ) ) { if ( sym != null && sym . kind == MTH ) { if ( hasParameterTypes ( ( MethodSymbol ) sym , paramTypes ) ) { return ( MethodSymbol ) sym ; } } } } Type superclass = tsym . getSuperclass ( ) ; if ( superclass . tsym != null ) { MethodSymbol msym = searchMethod ( ( ClassSymbol ) superclass . tsym , methodName , paramTypes , searched ) ; if ( msym != null ) { return msym ; } } List < Type > intfs = tsym . getInterfaces ( ) ; for ( List < Type > l = intfs ; l . nonEmpty ( ) ; l = l . tail ) { Type intf = l . head ; if ( intf . isErroneous ( ) ) continue ; MethodSymbol msym = searchMethod ( ( ClassSymbol ) intf . tsym , methodName , paramTypes , searched ) ; if ( msym != null ) { return msym ; } } ClassSymbol encl = tsym . owner . enclClass ( ) ; if ( encl != null ) { MethodSymbol msym = searchMethod ( encl , methodName , paramTypes , searched ) ; if ( msym != null ) { return msym ; } } return null ; }
@see com.sun.tools.javadoc.ClassDocImpl#searchMethod