Load the class this method is associated with, and get the {@link Method} reference for this method.

@return The {@link Method} reference for this field.
@throws IllegalArgumentException
if the method does not exist.
770675
public Method loadClassAndGetMethod() throws IllegalArgumentException {
        final MethodParameterInfo[] allParameterInfo = getParameterInfo();
        final List<Class<?>> parameterClasses = new ArrayList<>(allParameterInfo.length);
        for (final MethodParameterInfo mpi : allParameterInfo) {
            final TypeSignature parameterType = mpi.getTypeSignatureOrTypeDescriptor();
            parameterClasses.add(parameterType.loadClass());
        }
        final Class<?>[] parameterClassesArr = parameterClasses.toArray(new Class<?>[0]);
        try {
            return loadClass().getMethod(getName(), parameterClassesArr);
        } catch (final NoSuchMethodException e1) {
            try {
                return loadClass().getDeclaredMethod(getName(), parameterClassesArr);
            } catch (final NoSuchMethodException es2) {
                throw new IllegalArgumentException("No such method: " + getClassName() + "." + getName());
            }
        }
    }
76861
@Nonnull
  public Class <?> loadClass (final String sClassName) throws ClassNotFoundException
  {
    if (m_aBestCandidate != null)
    {
      try
      {
        return m_aBestCandidate.loadClass (sClassName);
      }
      catch (final Throwable t)
      {
        m_aBestCandidate = null;
      }
    }

    Throwable aThrowable = null;
    Class <?> ret = null;
    IClassLoadHelper aLoadHelper = null;

    final Iterator <IClassLoadHelper> iter = m_aLoadHelpers.iterator ();
    while (iter.hasNext ())
    {
      aLoadHelper = iter.next ();
      try
      {
        ret = aLoadHelper.loadClass (sClassName);
        break;
      }
      catch (final Throwable t)
      {
        aThrowable = t;
      }
    }

    if (ret == null)
    {
      if (aThrowable instanceof ClassNotFoundException)
        throw (ClassNotFoundException) aThrowable;
      throw new ClassNotFoundException ("Unable to load class " + sClassName + " by any known loaders.", aThrowable);
    }

    // Remember
    m_aBestCandidate = aLoadHelper;
    return ret;
  }
709734
public static Field findField(Class<?> type, String name) {
        if (type == null) {
            throw new IllegalArgumentException("Method argument type must not be null");
        }
        if (name == null) {
            throw new IllegalArgumentException("Method argument name must not be null");
        }

        Class<?> c = type;

        do {
            for (Field f : c.getDeclaredFields()) {
                if (name.equals(f.getName())) {
                    return f;
                }
            }
            c = c.getSuperclass();
        } while (c != null);

        return null;
    }
1361484
private Class getTargetClass(Method setMethod) {
        Class[] params = setMethod.getParameterTypes();
        if (params == null || params.length != 1) {
            throw new BeanMappingException("illegal set method[" + setMethod.getName() + "] for ParameterType");
        }
        return params[0];
    }
1297515
public com.groupon.odo.proxylib.models.Method getMethod(String className, String methodName) throws Exception {
        // TODO: fix this so it returns the right override ID
        com.groupon.odo.proxylib.models.Method m = null;

        // calls getClass first in case the loaded class needs to be invalidated
        Class<?> gottenClass = getClass(className);
        ClassInformation classInfo = classInformation.get(className);

        String fullName = className + "." + methodName;
        if (methodInformation.containsKey(fullName)) {
            m = methodInformation.get(fullName);
        } else {
            logger.info("Getting method info: {}", fullName);

            // Make a new classpool with the system classpath URLS
            // We create a new classpool each time since we want to reload plugin information in case it has changed.
            // Once a method is loaded this should not get called so the extra expense is not always taken as a hit
            ClassPool classPool = new ClassPool();
            ClassLoader sysClassLoader = Thread.currentThread().getContextClassLoader();

            //Get the URLs
            URL[] urls = ((URLClassLoader) sysClassLoader).getURLs();
            for (int i = 0; i < urls.length; i++) {
                try {
                    // insert all classpaths into the javassist classpool
                    File f1 = new File(urls[i].getFile());

                    if (f1.exists()) {
                        // only add if file exists to avoid an uncatchable exception in Java 8
                        classPool.insertClassPath(urls[i].getFile());
                    }
                } catch (NotFoundException e) {
                    e.printStackTrace();
                }
            }
            classPool.insertClassPath(classInfo.pluginPath);

            // load method information
            Method[] methods = gottenClass.getDeclaredMethods();
            for (Method method : methods) {
                if (method.getName().compareTo(methodName) != 0) {
                    continue;
                }

                try {
                    // get annotation information
                    Annotation[] annotations = method.getAnnotations();
                    for (Annotation annotation : annotations) {
                        com.groupon.odo.proxylib.models.Method newMethod = new com.groupon.odo.proxylib.models.Method();
                        newMethod.setClassName(className);
                        newMethod.setMethodName(methodName);
                        newMethod.setMethod(method);
                        newMethod.setMethodType(annotation.annotationType().toString());

                        String[] argNames = null;
                        String[] defaultArgs = null;
                        String description = null;

                        // Convert to the right type and get annotation information
                        if (annotation.annotationType().toString().endsWith(Constants.PLUGIN_RESPONSE_OVERRIDE_CLASS)) {
                            ResponseOverride roAnnotation = (ResponseOverride) annotation;
                            newMethod.setHttpCode(roAnnotation.httpCode());
                            description = roAnnotation.description();
                            argNames = roAnnotation.parameters();
                            defaultArgs = new String[0];
                            newMethod.setOverrideVersion(1);
                        } else if (annotation.annotationType().toString().endsWith(Constants.PLUGIN_RESPONSE_OVERRIDE_V2_CLASS)) {
                            com.groupon.odo.plugin.v2.ResponseOverride roAnnotation = (com.groupon.odo.plugin.v2.ResponseOverride) annotation;
                            description = roAnnotation.description();
                            argNames = roAnnotation.parameters();
                            defaultArgs = roAnnotation.argDefaults();
                            newMethod.setBlockRequest(roAnnotation.blockRequest());
                            newMethod.setOverrideVersion(2);
                        } else {
                            continue;
                        }

                        // identify arguments
                        // first arg is always a reserved that we skip
                        ArrayList<String> params = new ArrayList<String>();
                        if (method.getParameterTypes().length > 1) {
                            for (int x = 1; x < method.getParameterTypes().length; x++) {
                                params.add(method.getParameterTypes()[x].getName());
                            }
                        }
                        newMethod.setMethodArguments(params.toArray(new Object[0]));
                        newMethod.setMethodArgumentNames(argNames);
                        newMethod.setMethodDefaultArguments(defaultArgs);
                        newMethod.setDescription(description);
                        newMethod.setIdString(className + "." + methodName);

                        methodInformation.put(fullName, newMethod);
                        m = newMethod;
                    }

                    break;
                } catch (Exception e) {
                    // in this case we just return null since the method would be unuseable
                    return null;
                }
            }
        }

        return m;
    }
524500
@Nonnull
  public ClassLoader getClassLoader ()
  {
    return m_aBestCandidate == null ? Thread.currentThread ().getContextClassLoader ()
                                    : m_aBestCandidate.getClassLoader ();
  }
1255961
@Override
    protected Class<?> loadClass(String name, boolean resolve)
            throws ClassNotFoundException {
        synchronized (LaunchedURLClassLoader.LOCK_PROVIDER.getLock(this, name)) {
            Class<?> loadedClass = findLoadedClass(name);
            if (loadedClass == null) {
                Handler.setUseFastConnectionExceptions(true);
                try {
                    loadedClass = doLoadClass(name);
                } finally {
                    Handler.setUseFastConnectionExceptions(false);
                }
            }
            if (resolve) {
                resolveClass(loadedClass);
            }
            return loadedClass;
        }
    }
275916
protected boolean _load ()
    {
        java.util.Iterator it =
            this.getOjbMetaTreeModel ().getRepository().iterator();
        java.util.ArrayList newChildren = new java.util.ArrayList();

        /* @todo make this work */

//        newChildren.add(new OjbMetaJdbcConnectionDescriptorNode(
//            this.getOjbMetaTreeModel ().getRepository(),
//            this.getOjbMetaTreeModel (),
//            this,
//            this.getOjbMetaTreeModel ().getRepository().getDefaultJdbcConnection()));

        while (it.hasNext())
        {
            org.apache.ojb.broker.metadata.ClassDescriptor cld = (org.apache.ojb.broker.metadata.ClassDescriptor)it.next();
            OjbMetaClassDescriptorNode cldNode =
            	new OjbMetaClassDescriptorNode(this.getOjbMetaTreeModel ().getRepository(),
					                           this.getOjbMetaTreeModel (),
     						                   this, cld);
            cldToNodes.put(cld, cldNode);
            newChildren.add(cldNode);
        }
        java.util.Collections.sort(newChildren);
        this.alChildren = newChildren;
        this.getOjbMetaTreeModel ().nodeStructureChanged(this);
        return true;
    }
942744
public static Field getGetterField(Method method) {
        if (method == null) {
            throw new IllegalArgumentException("method cannot be null.");
        }
        Class<?> clazz = method.getDeclaringClass();
        String fName = stripGetterPrefix(method.getName());
        Field field = null;
        try {
            field = findField(clazz, fName);
        } catch (Exception ignore) {
        }
        return field;

    }
744875
@Override
    public JavaClass loadClass(String className) throws ClassNotFoundException {
        if (className.length() == 0) {
            throw new IllegalArgumentException("Request to load empty class");
        }
        className = ClassName.toSlashedClassName(className);
        ClassDescriptor classDescriptor = DescriptorFactory.instance().getClassDescriptor(className);
        try {
            return Global.getAnalysisCache().getClassAnalysis(JavaClass.class, classDescriptor);
        } catch (CheckedAnalysisException e) {
            throw new ClassNotFoundException("Exception while looking for class " + className, e);
        }
    }
410008
public static <T> Class<T> loadClass(String className, ClassLoader classloader) {
        if(className == null) {
            throw new IllegalArgumentException("className cannot be null");
        }

        if(classloader == null) {
            throw new IllegalArgumentException("classloader cannot be null");
        }

        try {
            return (Class<T>) Class.forName(className, false, classloader);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
485877
public static <T extends Annotation> T getAnnotation(Method method, Class<T> annotationClass) {
        T annotation = method.getAnnotation(annotationClass);
        if (annotation == null) {
            annotation = getAnnotation(method.getDeclaringClass(), annotationClass);
        }

        return annotation;
    }
294089
public Class<?> loadClassFrom(String name, AbstractClassLoader first) throws ClassNotFoundException {
		// try on the system one
		try { return AppClassLoader.class.getClassLoader().loadClass(name); }
		catch (ClassNotFoundException e) { /* not found. */ }
		Class<?> c = null;
		// check it is not loaded on one of the library
		for (int i = 0; i < libs.size(); i++) {
    		AbstractClassLoader cl = libs.get(i);
    		c = cl.isLoaded(name);
    		if (c != null) return c;
    	}
    	// try with the first one
    	if (first != null) {
    		try {
    			c = first.loadClassInLibrary(name);
    			if (c != null) return c;
    		} catch (FileNotFoundException e) {
    			// not found
    		} catch (IOException e) {
    			throw new ClassNotFoundException(e.getMessage());
    		}
    	}
    	// then, try on other libraries
    	for (int i = 0; i < libs.size(); i++) {
    		AbstractClassLoader cl = libs.get(i);
    		if (cl == first) continue;
    		try {
    			c = cl.loadClassInLibrary(name);
    			if (c != null) return c;
    		} catch (FileNotFoundException e) {
    			// not found
    		} catch (IOException e) {
    			throw new ClassNotFoundException(e.getMessage());
    		}
    	}
		StringBuilder msg = new StringBuilder(512);
		msg.append("Class not found: ").append(name);
		msg.append("\r\nFrom class loader: ").append(first);
		msg.append("\r\nlibraries currently registered:");
		for (int i = 0; i < libs.size(); i++)
			msg.append("\r\n - ").append(libs.get(i).toString());
		throw new ClassNotFoundException(msg.toString());
	}

	/** Load a resource. */
	@SuppressWarnings("resource")
	public IO.Readable getResourceIO(String name, byte priority) {
		if (name.length() == 0) return null;
		if (name.charAt(0) == '/') name = name.substring(1);
		IO.Readable io = null;
    	for (int i = 0; i < libs.size(); i++) {
    		AbstractClassLoader cl = libs.get(i);
   			try { io = cl.open(name, priority); }
   			catch (IOException e) { /* ignore */ }
    		if (io != null) return io;
    	}
       	// then try on the core one
        InputStream in = AppClassLoader.class.getClassLoader().getResourceAsStream(name);
        if (in == null) return null;
        return new IOFromInputStream(in, name, Threading.getUnmanagedTaskManager(), priority);
	}
313034
public static Method getSAMMethod(Class<?> c) {
        // SAM = single public abstract method
        // if the class is not abstract there is no abstract method
        if (!Modifier.isAbstract(c.getModifiers())) return null;
        if (c.isInterface()) {
            Method[] methods = c.getMethods();
            // res stores the first found abstract method
            Method res = null;
            for (Method mi : methods) {
                // ignore methods, that are not abstract and from Object
                if (!Modifier.isAbstract(mi.getModifiers())) continue;
                // ignore trait methods which have a default implementation
                if (mi.getAnnotation(Traits.Implemented.class)!=null) continue;
                try {
                    Object.class.getMethod(mi.getName(), mi.getParameterTypes());
                    continue;
                } catch (NoSuchMethodException e) {/*ignore*/}

                // we have two methods, so no SAM
                if (res!=null) return null;
                res = mi;
            }
            return res;

        } else {

            LinkedList<Method> methods = new LinkedList();
            getAbstractMethods(c, methods);
            if (methods.isEmpty()) return null;
            ListIterator<Method> it = methods.listIterator();
            while (it.hasNext()) {
                Method m = it.next();
                if (hasUsableImplementation(c, m)) it.remove();
            }
            return getSingleNonDuplicateMethod(methods);
        }
    }
205943
private static Method getMethod(String methodName, Class<?> clazz, Class<?>... args) {
        Method method;
        try {
            method = clazz.getMethod(methodName, args);
        } catch (NoSuchMethodException e1) {
            method = null;
        }
        return method;
    }
176334
public AnnotationInfoList getAnnotationInfo() {
        if (!scanResult.scanSpec.enableAnnotationInfo) {
            throw new IllegalArgumentException("Please call ClassGraph#enableAnnotationInfo() before #scan()");
        }
        return annotationInfo == null ? AnnotationInfoList.EMPTY_LIST
                : AnnotationInfoList.getIndirectAnnotations(annotationInfo, /* annotatedClass = */ null);
    }
156628
private String getMethodName(Method method) {
        StatName statNameAnnotation = method.getAnnotation(StatName.class);
        return statNameAnnotation != null ? statNameAnnotation.value() : method.getName();
    }