Nashorn caches compiled code? Can I clear the cache?
Kaj Magnus Lindberg
kajmagnus79 at gmail.com
Mon Jun 15 03:55:32 UTC 2015
Nashorn caches compiled scripts in-meomory somehow right? Is there any way
to clear this cache?
I'm wondering, because when Play Framework (that's a Scala web framework)
reloads my Scala application after I've edited some source code files, all
Scala and Java classes are properly reloaded. (Play Framework reloads
classes "live", without terminating the process.) Except for Scala code
that gets run after I've called back from Nashorn to Scala: when inside
Nashorn, old code gets reused, Nashorn apparently doesn't know that Play
Framework wants everyone to refresh all classes.
So I think perhaps I can tell Nashorn to discard its compiled code cache so
it starts using the new classes instead. Can I do that somehow? Like,
I'm not sure if what I'm asking is a good idea. If not, or if it's just not
possible, then I suppose I'll have to kill my app instead of just
"soft-reloading" it, if I've changed anything that Nashorn uses.
(The effects of Nashorn using old classes, are for example that singletons
get duplicated: when inside Nashorn, a singleton object resolves to an old
instance with an old field value = 333, but when outside Nashorn, the
singleton resolves to a new version of the class with newly added fields
and the value that was previously 333 now instead correctly shows 444 (I
edited it to 444).)
I hope this is the right place to ask. Thanks for building Nashorn and best
More information about the nashorn-dev