Skip to content

Commit 1c54023

Browse files
committed
WIP
This branch will only be necessary if we decide to explicitly ship the Rhino script engine version of JavaScript, as opposed to leaning on Nashorn's compatibility functions in Java 8. Time will tell whether the Nashorn backwards compatibility is good enough. But in the meantime, let's leave this branch for a while.
1 parent e9f0667 commit 1c54023

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
<url>http://scijava.org/</url>
1818
<inceptionYear>2008</inceptionYear>
1919

20+
<properties>
21+
<scijava.jvm.version>1.8</scijava.jvm.version>
22+
</properties>
23+
2024
<licenses>
2125
<license>
2226
<name>Simplified BSD License</name>

src/main/java/org/scijava/plugins/scripting/javascript/JavaScriptScriptLanguage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public ScriptEngine getScriptEngine() {
6464
final ScriptEngine engine = super.getScriptEngine();
6565
try {
6666
engine.eval("function load(path) {\n"
67-
+ " importClass(Packages.sun.org.mozilla.javascript.internal.Context);\n"
67+
+ " importClass(Packages.org.mozilla.javascript.Context);\n"
6868
+ " importClass(Packages.java.io.FileReader);\n"
6969
+ " var cx = Context.getCurrentContext();\n"
7070
+ " cx.evaluateReader(this, new FileReader(path), path, 1, null);\n"

src/test/java/org/scijava/plugins/scripting/javascript/JavaScriptTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ public void testBasic() throws InterruptedException, ExecutionException,
7575

7676
@Test
7777
public void testLocals() throws ScriptException {
78-
final Context context = new Context(ScriptService.class);
79-
final ScriptService scriptService = context.getService(ScriptService.class);
80-
81-
final ScriptLanguage language = scriptService.getLanguageByExtension("js");
82-
final ScriptEngine engine = language.getScriptEngine();
78+
// final Context context = new Context(ScriptService.class);
79+
// final ScriptService scriptService = context.getService(ScriptService.class);
80+
//
81+
// final ScriptLanguage language = scriptService.getLanguageByExtension("js");
82+
// final ScriptEngine engine = language.getScriptEngine();
83+
final ScriptEngine engine = new RhinoScriptEngine();
8384
assertTrue(engine.getClass().getName().endsWith(".RhinoScriptEngine"));
8485
engine.put("$hello", 17);
8586
assertEquals("17", engine.eval("$hello").toString());
@@ -123,7 +124,7 @@ public void testLoad() throws IOException, InterruptedException, ExecutionExcept
123124
final ScriptService scriptService = context.getService(ScriptService.class);
124125
final String script = "load('" + tmp.getPath() + "'); three();";
125126
final Object result = scriptService.run("three.js", script, false).get().getReturnValue();
126-
assertEquals(4.0, (Number) result);
127+
assertEquals(4, result);
127128
assertTrue(tmp.delete());
128129
}
129130
}

0 commit comments

Comments
 (0)