eval in DebuggerSupport.java fails.

Kuperman Sergey seastranger at gmail.com
Tue Sep 30 08:36:17 UTC 2014


Kuperman Sergey <seastranger at ...> writes:

> 
> Hello ! I am not sure it is the right place to ask but i will try anyway )
> My team is trying to develop a JS debugger poc running Nashorn , and we
> encountered an issue when trying to implement evaluation in function context:
> We run some JS function with:
>         ScriptEngineManager sem = new ScriptEngineManager();
>         ScriptEngine engine = sem.getEngineByName("nashorn");
>         engine.eval("load (\"src/com/sap/rdl/runjs/file.js\");");
> in another app we set a breakpoint in a function, and try to invoke eval()
> function from DebuggerSupport.java , while passing to it :scope variable we
> received from the relevant frame's visibleVariables (JDI).
> eval succeeds when global or upper scope defined variables are involved, but
> if i use an expression with local function variable, i receive ECMAException
> no such variable defined.. it seems to me that eval needs local vars to be
> defined within the scope but they are not ..
> Is there anything i could do to make it work ?
> 
> Thanks in advance
> 
> Sergey
> SAP RDL development team
> 
> 

A little further investigation shows, that nashorn :scope loads variables
lazily - only when needed or if eval function is used inside js.
Is there a way to force :scope to contain all vars regardless of use ? I
mean except using dummy eval statement that would be an ugly workaround..
thanks in advance
Sergey




More information about the nashorn-dev mailing list