| 1 | package org.jpype; |
| 2 | |
| 3 | import java.lang.reflect.InvocationTargetException; |
| 4 | import java.lang.reflect.Method; |
| 5 | |
| 6 | public class Reflector0 implements JPypeReflector |
| 7 | { |
| 8 | |
| 9 | public Reflector0() |
| 10 | {} |
| 11 | |
| 12 | /** |
| 13 | * Call a method using reflection. |
| 14 | * |
| 15 | * This method creates a stackframe so that caller sensitive methods will |
| 16 | * execute properly. |
| 17 | * |
| 18 | * @param method is the method to call. |
| 19 | * @param obj is the object to operate on, it will be null if the method is |
| 20 | * static. |
| 21 | * @param args the arguments to method. |
| 22 | * @return the object that results form the invocation. |
| 23 | * @throws java.lang.Throwable throws whatever type the called method |
| 24 | * produces. |
| 25 | */ |
| 26 | public Object callMethod(Method method, Object obj, Object[] args) |
| 27 | throws Throwable |
| 28 | { |
| 29 | try |
| 30 | { |
| 31 | return method.invoke(obj, args); |
| 32 | } catch (InvocationTargetException ex) |
| 33 | { |
| 34 | // ex.printStackTrace(); |
| 35 | throw ex.getCause(); |
| 36 | } |
| 37 | } |
| 38 | } |