1 package org.simantics.scl.reflection.functions;
3 import java.lang.reflect.InvocationTargetException;
4 import java.lang.reflect.Method;
5 import java.util.Arrays;
7 import org.simantics.scl.runtime.function.FunctionImplN;
9 public class InstanceMethodFunction extends FunctionImplN {
12 public InstanceMethodFunction(Method method) {
13 super(method.getParameterTypes().length+1);
17 public Method getMethod() {
22 public Object doApply(Object... ps) {
24 return method.invoke(ps[0], Arrays.copyOfRange(ps, 1, ps.length));
25 } catch (IllegalArgumentException e) {
26 throw new RuntimeException(e);
27 } catch (IllegalAccessException e) {
28 throw new RuntimeException(e);
29 } catch (InvocationTargetException e) {
30 throw new RuntimeException(e.getCause());
35 public String toString() {
36 return method.getName();