Needs warmup to manifest itself
function tryItOut(c) {
var f = tryCompiling(c);
if (f !== null && c.indexOf('infloop') === -1) {
tryRunning(f);
}
}
function tryCompiling(c) {
try { return Function(c); } catch(e) { return null; }
}
function tryRunning(f) {
try {
return f();
} catch (e) {
if (e instanceof java.lang.Throwable) e.printStackTrace();
}
}
tryItOut("return;");
tryItOut("var x = [];");
tryItOut("var y = [];");
tryItOut("var z = [];");
tryItOut("return;");
tryItOut("Math.min");
tryItOut("Math.log");
tryItOut("Math.cos");
tryItOut("Math.max");
tryItOut("Math.sin");
tryItOut("Math.random");
tryItOut("");
tryItOut("return 1e81;");
tryItOut("{}");
tryItOut("((new Function(\"([,,]);\")).apply)(3.14);");
tryItOut("Math.tan");
tryItOut("Math.pow");
tryItOut("([,,]);");
java.lang.ClassCastException: jdk.nashorn.internal.runtime.Undefined cannot be cast to java.lang.Number
at sun.invoke.util.ValueConversions.primitiveConversion(ValueConversions.java:199)
at sun.invoke.util.ValueConversions.unboxDouble(ValueConversions.java:119)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:656)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
at jdk.nashorn.internal.scripts.Script$Recompilation$10$213A$a.tryRunning(/tmp/a.js:14)
at jdk.nashorn.internal.scripts.Script$Recompilation$7$a.tryItOut(/tmp/a.js:4)
at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636)
at jdk.nashorn.internal.scripts.Script$Recompilation$1$a.:program(/tmp/a.js:37)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636)
...