The java.lang.reflect defines a Method class that may be used to get information about a method in a Java class. Some of the main methods are:
public native int getModifiers(); // e.g. public, private, staticpublic Class getReturnType(); // primitive or object typepublic Class getDeclaringClass (); // class that declares this Methodpublic String getName(); // string name of the methodpublic Class[] getParameterTypes(); // parameter types passed inpublic Class[] getExceptionTypes(); // exception types thrown// Invoke this Methodpublic native Object invoke(Object o, Object[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException;
The first six methods listed here can provide all the details to determine the characteristics of a Java method. You can use these methods to obtain each of the elements that go in a method declaration. For example, a typical Java method will have this syntax:
[modifiers] (paramType1 param1, paramType2, param2,