// NOTE : be careful with "args" parameter. It is null
// if method signature has 0 arguments.
Class methodClass = method.getDeclaringClass();
if( methodClass == java.lang.Object.class ) {
return InvocationHandlerUtil.
invokeJavaObjectMethod(this, method, args);
}
Object returnValue = null;
Throwable t = null;
try {
Method m = delegate.getClass().getMethod
(method.getName(), method.getParameterTypes());
returnValue = m.invoke(delegate, args);
} catch(NoSuchMethodException nsme) {
t = nsme;
} catch(InvocationTargetException ite) {
t = ite.getCause();
} catch(Throwable c) {
t = c;
}
if( t != null ) {
if( t instanceof java.rmi.RemoteException ) {
EJBException ejbEx = new EJBException();
ejbEx.initCause(t);
throw ejbEx;
} else {
throw t;
}
}
return returnValue;