Am 2014-03-12 12:44, schrieb Tal Liron:
Hannes, I would like to test this.
It doesn't seem to be on the main Nashorn repository:
http://hg.openjdk.java.net/nashorn/jdk8/nashorn
Is there a separate repository I should be using?
You can get it here:
http://hg.openjdk.java.net/jdk9/dev/nashorn
In case you have problems with building I can send you a nashorn.jar via
private mail. Just let me know.
Hannes
On 03/12/2014 05:50 PM, Hannes Wallnoefer wrote:
Hi Tal,
I'm right now pushing a change for JDK-8021350 that allows sharing
script classes between global scopes. Currently, script classes are
bound to the global object in various ways, so the change is not
trivial, and it's not possible to share compiled scripts between
global scopes with the nashorn.jar in current JDK8 builds. The script
sharing feature is planned for the 8u20 release.
The class sharing will be per script engine, meaning that if you use
multiple scopes with one script engine classes will be reused, when
you use multiple script engines scripts will be recompiled for each
engine.
I'd be interested to know whether this would work for you. If you'd
like to test the class sharing feature I can help you getting started.
Hannes
Am 2014-03-12 10:27, schrieb Tal Liron:
In Nashorn, the ClassCache is set per Global instance.
This is fine if your application has only one global instance.
However, my application design involves creating many Global
instances. (Actually, I create and destroy them on the fly per user
request in an HTTP server scenario.) The problem is that all code
has to constantly be recompiled, and the cache is essentially never
used. Since recompilation is so very expensive in Nashorn, this
results in awful performance.
How can I implement a shared ClassCache? I can't extend and modify
Global behavior, because it's a final class.
I've tried to cache ScriptFunction instances myself, but I get
exceptions when I try to run them with a different Global instance
than the one that created them.