protected PsmMethodAction(Class c, String m, Class[] argArray) {
    // This prevents IllegalAccessExceptions when attempting to
    // invoke methods on a class that is in another package and not
    // defined 'public'.
    if (!Modifier.isPublic(c.getModifiers())) {
      throw new IllegalPsmMethodActionException("Action class must be public.");
    }

    try {
      method = c.getMethod(m, argArray);
    } catch (NoSuchMethodException ex) {
      throw new IllegalPsmMethodActionException(ex.toString() + ": method " + m);
    }

    // Check each exception this method declares thrown.  If it declares
    // exceptions, and any of them are not runtime exceptions, abort.
    Class[] exceptionTypes = method.getExceptionTypes();
    for (int i = 0; i < exceptionTypes.length; i++) {
      Class exceptionClass = exceptionTypes[i];
      if (!RuntimeException.class.isAssignableFrom(exceptionClass)) {
        throw new IllegalPsmMethodActionException(
            "Method must not declare non-Runtime " + "exceptions.");
      }
    }

    // Ensure that the method returns PsmEvent
    if (PsmEvent.class != method.getReturnType()) {
      throw new IllegalPsmMethodActionException("Method return type must be PsmEvent");
    }

    // Ensure that both the method is both public and static.
    if (!Modifier.isStatic(method.getModifiers()) || !Modifier.isPublic(method.getModifiers())) {
      throw new IllegalPsmMethodActionException("Method " + m + " must be static and public.");
    }
  }
 Object invoke(String method, Class[] argtypes, Object[] args) throws InvocationTargetException {
   try {
     Method m = fact.getClass().getMethod(method, argtypes);
     return m.invoke(fact, args);
   } catch (NoSuchMethodException e) {
     throw new RuntimeException(e);
   } catch (IllegalAccessException e) {
     throw new RuntimeException(e);
   }
 }
 protected PsmEvent run(PsmEvent event, PsmInterp interp, Object[] argArray) {
   try {
     return (PsmEvent) method.invoke(null, argArray);
   } catch (IllegalAccessException ex) {
     // This really should never happen, given the checks at
     // construction time.
     throw new PsmMethodActionException(ex.toString());
   } catch (InvocationTargetException ex) {
     // This may occur if the method throws a runtime exception.  Rather
     // than wrap it in a PsmMethodActionException, let it percolate up.
     // If not a RuntimeException, wrap it in a PsmMethodActionException.
     Throwable th = ex.getTargetException();
     if (th instanceof RuntimeException) {
       throw (RuntimeException) th;
     } else {
       throw new PsmMethodActionException(
           "Exception thrown from " + "target method invocation " + " is not a Runtime Exception",
           th);
     }
   }
 }
 public String toString() {
   return "[MethodAction: " + method.getName() + "]";
 }