]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/functions/ClassMethodFunction.java
Revert "Prime SCL BindingRegistry to shave ~0.5s from startup"
[simantics/platform.git] / bundles / org.simantics.scl.reflection / src / org / simantics / scl / reflection / functions / ClassMethodFunction.java
1 package org.simantics.scl.reflection.functions;
2
3 import java.lang.reflect.InvocationTargetException;
4 import java.lang.reflect.Method;
5
6 import org.simantics.scl.runtime.function.FunctionImplN;
7
8 public class ClassMethodFunction extends FunctionImplN {
9     Method method;
10
11     public ClassMethodFunction(Method method) {
12         super(method.getParameterTypes().length);
13         this.method = method;
14     }
15     
16     public Method getMethod() {
17         return method;
18     }
19
20     @Override
21     public Object doApply(Object... ps) {
22         try {
23             return method.invoke(null, ps);
24         } catch (IllegalArgumentException e) {
25             throw new RuntimeException(e);
26         } catch (IllegalAccessException e) {
27             throw new RuntimeException(e);
28         } catch (InvocationTargetException e) {
29             throw new RuntimeException(e.getCause());
30         }
31     }
32     
33     @Override
34     public String toString() {
35         return method.getName();
36     }
37 }