Clover coverage report - DynamicJava Test Coverage (dynamicjava-20120303-r5436)
Coverage timestamp: Sat Mar 3 2012 03:02:19 CST
file stats: LOC: 45   Methods: 2
NCLOC: 34   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SpecialMethod.java 0% 0% 0% 0%
coverage
 1    package edu.rice.cs.dynamicjava.symbol;
 2   
 3    import static edu.rice.cs.plt.debug.DebugUtil.debug;
 4   
 5    import java.lang.reflect.InvocationTargetException;
 6    import java.lang.reflect.Method;
 7   
 8    import edu.rice.cs.plt.iter.IterUtil;
 9    import edu.rice.cs.plt.lambda.WrappedException;
 10    import edu.rice.cs.dynamicjava.Options;
 11    import edu.rice.cs.dynamicjava.interpreter.EvaluatorException;
 12    import edu.rice.cs.dynamicjava.interpreter.RuntimeBindings;
 13   
 14    /**
 15    * Abstract parent for special implicit methods. The evaluation details are handled
 16    * here, allowing the implementation to be based on a method with a different signature.
 17    */
 18    public abstract class SpecialMethod implements DJMethod {
 19   
 20    protected abstract Method implementation() throws ClassNotFoundException, NoSuchMethodException;
 21   
 22  0 public DJMethod declaredSignature() { return this; }
 23  0 public Object evaluate(Object receiver, Iterable<Object> args, RuntimeBindings bindings,
 24    Options options) throws EvaluatorException {
 25  0 if (receiver == null) {
 26  0 throw new WrappedException(new EvaluatorException(new NullPointerException()));
 27    }
 28  0 try {
 29  0 Method m = implementation();
 30  0 try { m.setAccessible(true); /* override protected access */ }
 31  0 catch (SecurityException e) { debug.log(e); /* ignore -- we can't relax accessibility */ }
 32  0 return m.invoke(receiver, IterUtil.toArray(args, Object.class));
 33    }
 34  0 catch (ClassNotFoundException e) { throw new RuntimeException(e); }
 35  0 catch (NoSuchMethodException e) { throw new RuntimeException(e); }
 36  0 catch (InvocationTargetException e) { throw new EvaluatorException(e.getCause(), EXTRA_STACK); }
 37  0 catch (IllegalAccessException e) { throw new RuntimeException(e); }
 38    }
 39   
 40    private static final String[] EXTRA_STACK =
 41    new String[] { "java.lang.reflect.Method.invoke",
 42    "sun.reflect.DelegatingMethodAccessorImpl.invoke",
 43    "sun.reflect.NativeMethodAccessorImpl.invoke",
 44    "sun.reflect.NativeMethodAccessorImpl.invoke0" };
 45    }