View Javadoc

1   // MethodInvocation.java, created Sun Mar 11  2:21:10 2001 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.Bootstrap;
5   
6   import java.lang.reflect.InvocationTargetException;
7   import joeq.Class.jq_Method;
8   import joeq.Runtime.Reflection;
9   
10  /***
11   * MethodInvocation
12   *
13   * @author  John Whaley <jwhaley@alum.mit.edu>
14   * @version $Id: MethodInvocation.java 1941 2004-09-30 03:37:06Z joewhaley $
15   */
16  public class MethodInvocation {
17  
18      jq_Method method;
19      Object[] args;
20      
21      public MethodInvocation(jq_Method m, Object[] a) {
22          this.method = m;
23          this.args = a;
24      }
25  
26      public long invoke() throws Throwable {
27          try {
28              return Reflection.invoke(method, null, args);
29          } catch (InvocationTargetException x) {
30              throw x.getTargetException();
31          }
32      }
33      
34      public String toString() {
35          return "method "+method;
36      }
37  }