MyVisitor { {{ public void invokeMethod(String name, Object obj, Class cl) { try { Method meth = getMethod(name, cl); if (meth != null) { meth.setAccessible(true); meth.invoke(this, new Object[] { obj }); } } catch (SecurityException e) { throw new RuntimeException("\n" + e); } catch (IllegalAccessException e) { throw new RuntimeException("\n" + e); } catch (InvocationTargetException e) { e.printStackTrace(); // prints to stderr throw new RuntimeException("\n" + e.getTargetException()); } } }} }