Here you can find the source of getMethod(Class declaringClass, String name, Class... parameterTypes)
Parameter | Description |
---|---|
declaringClass | containing class |
name | name of method |
parameterTypes | types of parameters |
Parameter | Description |
---|---|
RuntimeException | if any error (such as method not found) |
@SuppressWarnings("unchecked") public static Method getMethod(Class declaringClass, String name, Class... parameterTypes)
//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); } } }