Here you can find the source of getMethod(Class> cls, String name)
Parameter | Description |
---|---|
cls | the class to retrieve from |
name | name of the method |
public static Method getMethod(Class<?> cls, String name) throws Exception
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { /**/*from w ww .j ava 2 s .com*/ * Retrieve method with 0 parameter count and with given name from given * class * * @param cls the class to retrieve from * @param name name of the method * @return retrieved method * @see Class#getDeclaredMethod(String, Class...) */ public static Method getMethod(Class<?> cls, String name) throws Exception { return getMethod(cls, name, new Class[0]); } /** * Retrieve method with given name and parameter types from given class * * @param cls the class to retrieve from * @param name name of the method * @param parameterTypes parameter types * @return retrieved method * @see Class#getDeclaredMethod(String, Class...) */ public static Method getMethod(Class<?> cls, String name, Class<?>... parameterTypes) throws Exception { try { return cls.getDeclaredMethod(name, parameterTypes); } catch (Exception e) { throw e; } } }