changeset 947:44ab1e6cf0e8

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 2ce63129b64a
children 6f579dd103da
files src/jdk/nashorn/internal/codegen/CodeGenerator.java test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu Jul 31 18:14:46 2014 +0530
+++ b/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/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Thu Jul 31 18:14:46 2014 +0530
+++ b/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