MOVE
 to method scanner class
166742
def number_of_arguments(method_sexp)
      arguments = method_sexp[2]
      arguments = arguments[1] if arguments.first == :paren

      arguments[1] == nil ? 0 : arguments[1].size
    end
829311
@VisibleForTesting
    static Method getMethod(Class<?> cls, String name, Class<?>... params) {
        Method m;
        try {
            m = cls.getDeclaredMethod(name, params);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        m.setAccessible(true);
        return m;
    }
1279800
private static String getClassMethod(Class clazz, Method method) {
		StringBuilder builder = new StringBuilder();
		builder.append(clazz.getName()).append(".").append(method.getName());
		builder.append("(");
		if (method.getParameterCount() > 0) {
			for (int i = 0; i < method.getParameterCount(); i++) {
				Parameter param = method.getParameters()[i];
				builder.append(param.getType().getSimpleName()).append(" ").append(param.getName());

				if (i + 1 < method.getParameterCount()) {
					builder.append(", ");
				}
			}
		}
		builder.append(")");
		return builder.toString();
	}
275947
private Method method() throws DynamicGroundingBuildingException {
        Method[] methods = clas.getMethods();
        for (Method method : methods) {
            if (method.getName().equals(methodName)) {
                return method;
            }
        }
        throw new DynamicGroundingBuildingException("clas " + clas.getSimpleName()
                + " has no method with that name (" + methodName + ")");
    }
1044677
private JMethod getMethodsMap(MethodType type, JFieldVar field, ClassOutline co) {
        String getterBody = "return " + field.name() + ";";
        for (JMethod method : co.implClass.methods()) {
            String name = method.name();
            if (method.type().isPrimitive()) {
                if (MethodType.GETTER == type && (name.startsWith("is") || name.startsWith("get"))) {
                    JStatement o = (JStatement) method.body().getContents().get(0);
                    String s = getterBody(o);
                    if (s.trim().equals(getterBody)) {
                        return method;
                    }
                } else if (MethodType.SETTER == type && name.startsWith("set")) {
                    JStatement o = (JStatement) method.body().getContents().get(0);
                    String s = setterBody(o);
                    if (s.startsWith("this." + field.name() + " =")) {
                        return method;
                    }
                }
            }

        }
        throw new RuntimeException("Failed to find " + type + " for " + field.name() + ", disable XReplacePrimitives and report a bug");
    }
1042418
static Method findMethod(Class<?> clazz, String methodName,
            Class<?>[] paramTypes, Object[] paramValues) {

        if (clazz == null || methodName == null) {
            throw new MethodNotFoundException(
                    message(null, "util.method.notfound", clazz, methodName,
                    paramString(paramTypes)));
        }

        if (paramTypes == null) {
            paramTypes = getTypesFromValues(paramValues);
        }

        Method[] methods = clazz.getMethods();

        List<Wrapper> wrappers = Wrapper.wrap(clazz, methods, methodName);

        Wrapper result = findWrapper(
                clazz, wrappers, methodName, paramTypes, paramValues);

        if (result == null) {
            return null;
        }
        return getMethod(clazz, (Method) result.unWrap());
    }
57489
private void scan() {
        if (ivScanned) {
            return;
        }

        ivScanned = true;

        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        for (Class<?> klass = ivClass; klass != null && klass != Object.class; klass = klass.getSuperclass()) {
            if (isTraceOn && (tc.isDebugEnabled() || tcMetaData.isDebugEnabled()))
                Tr.debug(tc.isDebugEnabled() ? tc : tcMetaData,
                         "scanning " + klass.getName());

            ivCurrentClassName = klass.getName();
            ivCurrentPrivateMethodMetaData = null;

            ClassLoader classLoader = klass.getClassLoader();
            if (classLoader == null) {
                classLoader = getBootClassLoader(); // d742751
            }

            String resourceName = klass.getName().replace('.', '/') + ".class";
            InputStream input = classLoader.getResourceAsStream(resourceName);

            if (input == null) // d728537
            {
                if (isTraceOn && (tc.isDebugEnabled() || tcMetaData.isDebugEnabled()))
                    Tr.debug(tc.isDebugEnabled() ? tc : tcMetaData,
                             "failed to find " + resourceName + " from " + classLoader);

                ivScanException = new FileNotFoundException(resourceName);
                return;
            }

            try {
                ClassReader classReader = new ClassReader(input);
                classReader.accept(this, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
            }
            // If the class is malformed, ASM might throw any exception.    d728537
            catch (Throwable t) {
                FFDCFilter.processException(t, CLASS_NAME + ".scan", "168", this,
                                            new Object[] { resourceName, klass, classLoader });

                if (isTraceOn && (tc.isDebugEnabled() || tcMetaData.isDebugEnabled()))
                    Tr.debug(tc.isDebugEnabled() ? tc : tcMetaData,
                             "scan exception", t);

                ivScanException = t;
                return;
            } finally {
                try {
                    input.close();
                } catch (IOException ex) {
                    if (isTraceOn && tc.isDebugEnabled())
                        Tr.debug(tc, "error closing input stream", ex);
                }
            }
        }
    }
1307691
private Map<StandardMethod, UnderrideLevel> findUnderriddenMethods(
      Iterable<ExecutableElement> methods) {
    Map<StandardMethod, ExecutableElement> standardMethods = new LinkedHashMap<>();
    for (ExecutableElement method : methods) {
      Optional<StandardMethod> standardMethod = maybeStandardMethod(method);
      if (standardMethod.isPresent() && isUnderride(method)) {
        standardMethods.put(standardMethod.get(), method);
      }
    }
    if (standardMethods.containsKey(StandardMethod.EQUALS)
        != standardMethods.containsKey(StandardMethod.HASH_CODE)) {
      ExecutableElement underriddenMethod = standardMethods.containsKey(StandardMethod.EQUALS)
          ? standardMethods.get(StandardMethod.EQUALS)
          : standardMethods.get(StandardMethod.HASH_CODE);
      messager.printMessage(ERROR,
          "hashCode and equals must be implemented together on FreeBuilder types",
          underriddenMethod);
    }
    ImmutableMap.Builder<StandardMethod, UnderrideLevel> result = ImmutableMap.builder();
    for (StandardMethod standardMethod : standardMethods.keySet()) {
      if (standardMethods.get(standardMethod).getModifiers().contains(Modifier.FINAL)) {
        result.put(standardMethod, UnderrideLevel.FINAL);
      } else {
        result.put(standardMethod, UnderrideLevel.OVERRIDEABLE);
      }
    }
    return result.build();
  }
1336766
public void scan(String classNamePattern, final Map<String, Class<?>> scannedClasses) throws IOException {
        scan(classNamePattern, scannedClasses::put);
    }
4420
private static Object _runMethod(Object obj, String methodName)
    {
        try
        {
            Method sessionIdMethod = obj.getClass().getMethod(methodName);
            return sessionIdMethod.invoke(obj);
        }
        catch (Exception e)
        {
            return null;
        }

    }
692114
def method(method_class):
    

    def callback(scanner, name, method_class):
        if method_class.actions is not None:
            actions = method_class.actions
        else:
            actions = [name]

        if method_class.versions is not None:
            versions = method_class.versions
        else:
            versions = [None]

        for action in actions:
            for version in versions:
                scanner.registry.add(method_class,
                                     action=action,
                                     version=version)

    from venusian import attach
    attach(method_class, callback, category="method")
    return method_class
814307
@Nullable
    private static Method findMethod(JavaClass cls, String methodName, String methodSig) {
        Method[] methods = cls.getMethods();
        for (Method method : methods) {
            if (method.getName().equals(methodName) && method.getSignature().equals(methodSig)) {
                return method;
            }
        }
        return null;
    }
462453
public static Method copyMethod(Method method) {
		try {
			if (jlrMethodRootField != null) {
				jlrMethodRootField.set(method, null);
			}
			return (Method) jlrMethodCopy.invoke(method);
		}
		catch (Exception e) {
			log.log(Level.SEVERE, "Problems copying method. Incompatible JVM?", e);
			return method; // return original as the best we can do
		}
	}
22477
private String convertMethod(List<String> methodList, boolean negative) {
        boolean first = true;
        StringBuffer methodSB = new StringBuffer();
        for (String method : methodList) {
            if (first) {
                first = false;
                if (negative) {
                    methodSB.append("!");
                }
            } else {
                methodSB.append(",");
            }
            methodSB.append(method);
        }
        if (tc.isDebugEnabled())
            Tr.debug(tc, "convertMethod : " + methodSB.toString());
        return methodSB.toString();
    }
225521
def _update_classmethod(self, oldcm, newcm):
        """"""
        # While we can't modify the classmethod object itself (it has no
        # mutable attributes), we *can* extract the underlying function
        # (by calling __get__(), which returns a method object) and update
        # it in-place.  We don't have the class available to pass to
        # __get__() but any object except None will do.
        self._update(None, None, oldcm.__get__(0), newcm.__get__(0))
666117
def walk_method(name)
      method_choice  = /#{Regexp.escape name}/
      invalid_choice = false

      # Continue walking up and down the stack until the users selects "exit"
      while method_choice != :exit
        print_method method_choice unless invalid_choice
        STDOUT.puts "\n\n"

        # Determine callers and callees for the current frame
        new_frames  = frames.select  {|_, info| info[:name] =~ method_choice }
        new_choices = new_frames.map {|frame, info| [
          callers_for(frame).sort_by(&:last).reverse.map(&:first),
          (info[:edges] || []).map{ |k, w| [data[:frames][k][:name], w] }.sort_by{ |k,v| -v }.map(&:first)
        ]}.flatten + [:exit]

        # Print callers and callees for selection
        STDOUT.puts "Select next method:"
        new_choices.each_with_index do |method, index|
          STDOUT.printf "%2d)  %s\n", index + 1, method.to_s
        end

        # Pick selection
        STDOUT.printf "> "
        selection = STDIN.gets.chomp.to_i - 1
        STDOUT.puts "\n\n\n"

        # Determine if it was a valid choice
        # (if not, don't re-run .print_method)
        if new_choice = new_choices[selection]
          invalid_choice = false
          method_choice = new_choice == :exit ? :exit : %r/^#{Regexp.escape new_choice}$/
        else
          invalid_choice = true
          STDOUT.puts "Invalid choice.  Please select again..."
        end
      end
    end
1028077
public void walk(Object root, Class[] skip, Visitor visitor)
    {
        Deque stack = new LinkedList();
        stack.add(root);

        while (!stack.isEmpty())
        {
            Object current = stack.removeFirst();

            if (current == null || _objVisited.containsKey(current))
            {
                continue;
            }

            final Class clazz = current.getClass();
            ClassInfo classInfo = getClassInfo(clazz, skip);
            if (classInfo._skip)
            {  // Do not process any classes that are assignableFrom the skip classes list.
                continue;
            }

            _objVisited.put(current, null);
            visitor.process(current);

            if (clazz.isArray())
            {
                int len = Array.getLength(current);
                Class compType = clazz.getComponentType();

                if (!compType.isPrimitive())
                {   // Speed up: do not walk primitives
                    ClassInfo info = getClassInfo(compType, skip);
                    if (!info._skip)
                    {   // Do not walk array elements of a class type that is to be skipped.
                        for (int i=0; i < len; i++)
                        {
                            Object element = Array.get(current, i);
                            if (element != null)
                            {   // Skip processing null array elements
                                stack.add(Array.get(current, i));
                            }
                        }
                    }
                }
            }
            else
            {   // Process fields of an object instance
                if (current instanceof Collection)
                {
                    walkCollection(stack, (Collection) current);
                }
                else if (current instanceof Map)
                {
                    walkMap(stack, (Map) current);
                }
                else
                {
                    walkFields(stack, current, skip);
                }
            }
        }
    }