Java Utililty Methods Reflection Method Name

List of utility methods to do Reflection Method Name

Description

The list of methods to do Reflection Method Name are organized into topic(s).

Method

MethodgetMethodIfAvailable(Class clazz, String methodName, Class... paramTypes)
Determine whether the given class has a public method with the given signature, and return it if available (else return null ).
if (paramTypes != null) {
    try {
        return clazz.getMethod(methodName, paramTypes);
    } catch (NoSuchMethodException ex) {
        return null;
} else {
    Set<Method> candidates = new HashSet<Method>(1);
...
MethodgetMethodIncludingSuperClass(Class clazz, String methodName)
get Method Including Super Class
for (Class<?> tmp = clazz; tmp != null && tmp != Object.class; tmp = tmp.getSuperclass()) {
    try {
        return clazz.getDeclaredMethod(methodName);
    } catch (NoSuchMethodException e) {
return null;
MethodgetMethodInternal(Class clazz, String methodName)
Does the actual search for the method
if (clazz == null) {
    return null;
final Method method = (Method) fieldMethodCache.get(clazz.getName() + "." + methodName);
if (method != null) {
    return method;
final Method[] methods = clazz.getDeclaredMethods();
...
StringgetMethodName()
Liefert den Namen des Aufruferes zurck
try {
    StackTraceElement trace[] = new Throwable().getStackTrace();
    String lineNumber = trace[1].getLineNumber() > 0 ? "(" + trace[1].getLineNumber() + ")" : "";
    return trace[1].getClassName() + "." + trace[1].getMethodName() + lineNumber;
} catch (Exception e) {
    e.printStackTrace();
return "";
...
StringgetMethodName()
Gets the name of the method that calls this method.
return doGetMethodName(false, false, (Object[]) null);
StringgetMethodName(final int depth)
get Method Name
try {
    StackTraceElement element = (StackTraceElement) m.invoke(new Throwable(), depth + 1);
    return element.getMethodName();
} catch (Exception e) {
    e.printStackTrace();
    return null;
StringgetMethodName(Method method)
get Method Name
boolean flag = false;
char temp;
char[] methods = method.toString().toCharArray();
int size = methods.length;
StringBuffer sbr = new StringBuffer(size);
for (int i = 0; i < size; i++) {
    temp = methods[i];
    if (temp == '(') {
...
StringgetMethodName(Method method)
get Method Name
String methodName = method.getName();
if (methodName.startsWith("_"))
    methodName = methodName.substring(1);
return methodName;
StringgetMethodName(Method method)
get Method Name
return method.getName();
StringgetMethodName(Method method, boolean useSegment, String segment, String value)
get Method Name
String name = value != null && value.length() > 0 ? value : method.getName();
return useSegment ? segment + name : name;