This is in response to http://mail.openjdk.java.net/pipermail/nashorn-dev/2015-December/005690.html [ I accidentally deleted the original email ]

Yes, objects from other ScriptContexts are indeed foreign - but nashorn allows you to call functions, access properties and so on.And even when you're using multiple ScriptContexts in the same engine -- compiled Classes (java.lang.Class instances) are shared. i.e., so long as you use same script, Nashorn will re-use Class objects. i.e., compiled code sharing is on per-engine basis. So, you can eval "common code" again and again -- you'll be re-using same Class object.

You don't share ECMAScript global objects (which are in ENGINE_SCOPE of the ScriptContexts you use) -- but that is only about objects including function objects. But you still share nashorn compiled code -- so long as you use the same script engine instance.

Hope that answers your concerns,
-Sundar

Reply via email to