Java Reflection Method Parameter getMethod(Class declaringClass, String name, Class... parameterTypes)

Here you can find the source of getMethod(Class declaringClass, String name, Class... parameterTypes)

Description

Convenience for getting a method from a class.

License

Apache License

Parameter

Parameter Description
declaringClass containing class
name name of method
parameterTypes types of parameters

Exception

Parameter Description
RuntimeException if any error (such as method not found)

Return

the Method

Declaration

@SuppressWarnings("unchecked")
public static Method getMethod(Class declaringClass, String name,
        Class... parameterTypes) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.lang.reflect.Method;

public class Main {
    /**//  w  w  w.  j  a  v a  2  s  .  c o m
     * Convenience for getting a method from a class.
     * 
     * @param declaringClass
     *            containing class
     * @param name
     *            name of method
     * @param parameterTypes
     *            types of parameters
     * @return the Method
     * @throws RuntimeException
     *             if any error (such as method not found)
     */
    @SuppressWarnings("unchecked")
    public static Method getMethod(Class declaringClass, String name,
            Class... parameterTypes) {
        try {
            return declaringClass.getMethod(name, parameterTypes);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
}

Related

  1. getMethod(Class cl, String methodName, String obfName, Class... parameterTypes)
  2. getMethod(Class clazz, String methodName, Class... parameterTypes)
  3. getMethod(Class clazz, String methodName, Class... parameterTypes)
  4. getMethod(Class clazz, String name, Class... parameterTypes)
  5. getMethod(Class clazz, String name, Class[] parameters)
  6. getMethod(Class klass, String methodName, Class[] parameterTypes)
  7. getMethod(Class target, String methodName, Class[] parameterTypes)
  8. getMethod(Class type, String methodName, Class... parameterTypes)
  9. getMethod(Class type, String name, Class[] parameterTypes)