Here you can find the source of invokeGetter(Object obj, String methodName)
public static Object invokeGetter(Object obj, String methodName) throws Exception
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { public static Object invokeGetter(Object obj, String methodName) throws Exception { Method m = obj.getClass().getMethod(methodName, (Class[]) null); if (m != null) { if (m.getExceptionTypes().length != 0) { // It throws an exception. It's not a simple getter and setter return null; } else { return m.invoke(obj, (Object[]) null); }/* w ww. jav a 2s . c o m*/ } return null; } }