neo4j/community — Issue #165: Update the JavaScript engine in the kernel to use Mozilla's Rhino 
Author: espeed
Created: 2012-01-01 17:49:38+00:00
State: open

The Rhino script engine that Neo4j presently uses for traversals is
the one that's bundled in the JRE. This is Sun's version of Rhino, not
Mozilla's, and it is based on Rhino 1.6R2
(http://docs.oracle.com/javase/6/docs/technotes/guides/scripting/programmer_guide/#jsengine),
which is several years old. The current version of Rhino
is 1.7R3.

Sun's version of Rhino is stripped down and less performant than
Mozilla's (http://stackoverflow.com/questions/4801037/sun-org-mozilla-rhino-and-extending-java-abstract-classes).

For example, Sun's doesn't compile scripts so it interprets
it each time, and it doesn't contain any of Mozilla's latest
optimizations.

But switching to Mozilla's Rhino is not as easy as including the
latest version in the POM because the bundled script engine doesn't
support it.

To use Mozilla's, you need to build and include the js-engine.jar
located here (http://java.net/projects/scripting/sources/svn/show/trunk/engines/javascript).
Unfortunately, this is not documented anywhere except in an old
newsgroup posting.

The java.net script engine is hardcoded for Rhino 1.6R7 and it's been
three years since its last update. While this is more recent that the
Sun version bundled in the JRE, it might be a good idea to fork it and
mavenize it for current versions.

I included the js-engine.jar in the JavaScript plugin's lib directory.

To use Mozilla's version, you use the script engine named
"rhino-nonjdk" instead of the standard "javascript" engine.