Here you can find the source of getMethod(final Class> aClass, final String methodName, Class>[] parameterTypes)
Parameter | Description |
---|---|
aClass | a class |
methodName | the name of the method to find |
parameterTypes | an array owning the type of the parameters of the called method |
Parameter | Description |
---|---|
NoSuchMethodException | an exception |
SecurityException | an exception |
public static Method getMethod(final Class<?> aClass, final String methodName, Class<?>[] parameterTypes) throws SecurityException, NoSuchMethodException
//package com.java2s; /***************************************************************************** * Copyright (c) 2012 CEA LIST./* w ww . j a v a2s . c o m*/ * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation *****************************************************************************/ import java.lang.reflect.Method; public class Main { /** * Warning : each call of this method should be tested with a JUnit test, in order to know * when the API has changed * * @param aClass * a class * @param methodName * the name of the method to find * @param parameterTypes * an array owning the type of the parameters of the called method * @return * the wanted method * @throws NoSuchMethodException * @throws SecurityException */ public static Method getMethod(final Class<?> aClass, final String methodName, Class<?>[] parameterTypes) throws SecurityException, NoSuchMethodException { Method m = null; m = aClass.getDeclaredMethod(methodName, parameterTypes); m.setAccessible(true); return m; } }