List of usage examples for jdk.nashorn.api.scripting NashornException NashornException
protected NashornException(final String msg, final Throwable cause)
From source file:reactor.js.test.NashornJUnitTestRunner.java
License:Open Source License
private static void addStaticMethods(Class<?> type, Bindings bindings) { for (Method method : type.getDeclaredMethods()) { if (Modifier.isStatic(method.getModifiers())) { final Method methodToInvoke = method; method.setAccessible(true);/*from w ww.jav a2 s. co m*/ bindings.put(method.getName(), new AbstractJSObject() { @Override public Object call(Object thiz, Object... args) { try { return methodToInvoke.invoke(null, args); } catch (Exception e) { return new NashornException(e.getMessage(), e) { }; } } @Override public boolean isFunction() { return true; } @Override public boolean isStrictFunction() { return true; } }); } } }