Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { private static Method executeMethod(Object obj, Method executeMethod) { try { if (executeMethod != null) { if (!executeMethod.isAccessible()) executeMethod.setAccessible(true); executeMethod.invoke(obj, new Object[] {}); } } catch (Exception e) { executeMethod = null; e.printStackTrace(); } finally { return executeMethod; } } }