try {
return mbeanServer.invoke(Kernel.KERNEL, methodName, args, types);
} catch (Exception e) {
Throwable cause = unwrapJMException(e);
if (cause instanceof InstanceNotFoundException) {
throw new InternalKernelException("Kernel is not loaded", cause);
} else if (cause instanceof NoSuchMethodException) {
StringBuffer buf = new StringBuffer("KernelDelegate is out of synch with Kernel on ");
buf.append(methodName).append("(");
if(types != null) {
for (int i = 0; i < types.length; i++) {
String type = types[i];
if(i>0) buf.append(",");
buf.append(type);
}
}
buf.append(")");
throw new InternalKernelException(buf.toString());
} else if (cause instanceof JMException) {
throw new InternalKernelException(cause);
} else if (cause instanceof JMRuntimeException) {
throw new InternalKernelException(cause);
} else if (cause instanceof Error) {
throw (Error) cause;
} else if (cause instanceof Exception) {
throw (Exception) cause;
} else {
throw new InternalKernelException("Unknown throwable", cause);
}
}
}