List of usage examples for jdk.nashorn.api.scripting NashornScriptEngineFactory getEngineVersion
@Override
public String getEngineVersion()
From source file:net.codestory.http.compilers.NashornCompiler.java
License:Apache License
private NashornCompiler(String script) { NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); String engineVersion = factory.getEngineVersion(); String cacheLocation = Paths .get(System.getProperty("user.home"), ".code-story", "nashorn_code_cache_" + engineVersion).toFile() .getAbsolutePath();/*from w ww .ja v a2 s .com*/ System.setProperty("nashorn.persistent.code.cache", cacheLocation); // --optimistic-types=true in JDK 8u40 slows down everything // Don't use varargs because it was introduced only in 8u40 ScriptEngine nashorn = factory .getScriptEngine(new String[] { "--persistent-code-cache=true", "--lazy-compilation=false" }); try { compiledScript = ((Compilable) nashorn).compile(script); bindings = nashorn.getBindings(ENGINE_SCOPE); } catch (ScriptException e) { throw new IllegalStateException("Unable to compile javascript", e); } }