8054223: Nashorn: AssertionError when use __DIR__ and ScriptEngine.eval()

Reviewed-by: lagergren, hannesw
This commit is contained in:
Athijegannathan Sundararajan 2014-08-04 21:37:45 +05:30
parent a55d1b4b75
commit 578ec9d11e
2 changed files with 9 additions and 1 deletions
nashorn
src/jdk/nashorn/internal/codegen
test/src/jdk/nashorn/api/scripting

@ -4742,7 +4742,7 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
*/
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());

@ -607,6 +607,14 @@ public class ScriptEngineTest {
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