NashornScriptEngine.java 文件源码

java
阅读 50 收藏 0 点赞 0 评论 0

项目:OLD-OpenJDK8 作者:
private CompiledScript asCompiledScript(final Source source) throws ScriptException {
    final ScriptFunction func = compileImpl(source, context);
    return new CompiledScript() {
        @Override
        public Object eval(final ScriptContext ctxt) throws ScriptException {
            final ScriptObject globalObject = getNashornGlobalFrom(ctxt);
            // Are we running the script in the correct global?
            if (func.getScope() == globalObject) {
                return evalImpl(func, ctxt, globalObject);
            }
            // ScriptContext with a different global. Compile again!
            // Note that we may still hit per-global compilation cache.
            return evalImpl(compileImpl(source, ctxt), ctxt, globalObject);
        }
        @Override
        public ScriptEngine getEngine() {
            return NashornScriptEngine.this;
        }
    };
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号