changeset 25826:3d2dd01a3a4a

8054223: Nashorn: AssertionError when use __DIR__ and ScriptEngine.eval() Reviewed-by: lagergren, hannesw
author sundar
date Mon, 04 Aug 2014 21:37:45 +0530
parents b97d77f4b98e
children c406ec905701
files nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu Jul 31 18:14:46 2014 +0530
+++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Mon Aug 04 21:37:45 2014 +0530
@@ -4742,7 +4742,7 @@
          */
         private void replaceCompileTimeProperty(final Object propertyValue) {
             assert method.peekType().isObject();
-            if(propertyValue instanceof String) {
+            if(propertyValue instanceof String || propertyValue == null) {
                 method.load((String)propertyValue);
             } else if(propertyValue instanceof Integer) {
                 method.load(((Integer)propertyValue).intValue());
--- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Thu Jul 31 18:14:46 2014 +0530
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Mon Aug 04 21:37:45 2014 +0530
@@ -607,6 +607,14 @@
         assertEquals(res, "hello");
     }
 
+    // @bug 8054223: Nashorn: AssertionError when use __DIR__ and ScriptEngine.eval()
+    @Test
+    public void check__DIR__Test() throws ScriptException {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        e.eval("__DIR__");
+    }
+
     // @bug 8050432:javax.script.filename variable should not be enumerable
     // with nashorn engine's ENGINE_SCOPE bindings
     @Test