Dispatching Visit Calls Using Reflection
/**
* Dispatching visit calls using reflection
*/
public void visit_dispatch(Object o) {
Class[] formal = new Class[1];
formal[0] = o.getClass();
try {
Method m = getClass().getMethod("visit", formal);
Object[] actual = new Object[1];
actual[0] = o;
m.invoke(this, actual);
} catch (Exception e) {
e.printStackTrace(System.err);
}
}