| 13 | package clojure.lang; |
| 14 | |
| 15 | public class FnLoaderThunk extends RestFn{ |
| 16 | |
| 17 | private static final long serialVersionUID = 2194257205455463687L; |
| 18 | |
| 19 | final Var v; |
| 20 | final ClassLoader loader; |
| 21 | final String fnClassName; |
| 22 | IFn fn; |
| 23 | |
| 24 | public FnLoaderThunk(Var v, String fnClassName){ |
| 25 | this.v = v; |
| 26 | this.loader = (ClassLoader) RT.FN_LOADER_VAR.get(); |
| 27 | this.fnClassName = fnClassName; |
| 28 | fn = null; |
| 29 | } |
| 30 | |
| 31 | public Object invoke(Object arg1) { |
| 32 | load(); |
| 33 | return fn.invoke(arg1); |
| 34 | } |
| 35 | |
| 36 | public Object invoke(Object arg1, Object arg2) { |
| 37 | load(); |
| 38 | return fn.invoke(arg1,arg2); |
| 39 | } |
| 40 | |
| 41 | public Object invoke(Object arg1, Object arg2, Object arg3) { |
| 42 | load(); |
| 43 | return fn.invoke(arg1,arg2,arg3); |
| 44 | } |
| 45 | |
| 46 | protected Object doInvoke(Object args) { |
| 47 | load(); |
| 48 | return fn.applyTo((ISeq) args); |
| 49 | } |
| 50 | |
| 51 | private void load() { |
| 52 | if(fn == null) |
| 53 | { |
| 54 | try |
| 55 | { |
| 56 | fn = (IFn) Class.forName(fnClassName,true,loader).getDeclaredConstructor().newInstance(); |
| 57 | } |
| 58 | catch(Exception e) |
| 59 | { |
| 60 | throw Util.sneakyThrow(e); |
| 61 | } |
| 62 | v.root = fn; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | public int getRequiredArity(){ |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | public IObj withMeta(IPersistentMap meta){ |
| 71 | return this; |
| 72 | } |
nothing calls this directly
no outgoing calls
no test coverage detected