Stepping into function in Nashorn

I have a Java app that also uses JavaScript. Everything works fine. However, I have a few nagging problems:

1. When I reach a JS function call in JS code, and do "Step Into", the IDEA debugger steps into some intermediate layer of code (inside Nashorn runtime), and NOT the JS funciton that's being called. I would prefer to NOT see the intervening Nashorn runtime code, but rather step directly into the called JS function. I can work around this by setting a breakpoint inside the called funciton, and then do Continue rather than Step Into, which gets me to where I want, but this is somewhat tedious.

2. Related to the above, when I debug JS code, I would prefer to ONLY see JS stackframes in the stack window, and NOT any intervening internal Nashorn functions called along the way.

3. It's often hard to see values of JS variables, as those are exposed as their underlying Java implementation. When debugging JS code, I would prefer to see variables like I do, e.g., in the Chrome Inspector, and not have to search through layers of Java wrappers to find the value somewhere deep inside.

-JM

8 comments

1. can't recreate. Are you using smart step into? May be related to https://youtrack.jetbrains.com/issue/IDEA-154665

2,3: please feel free to create feature requests in youtrack, https://youtrack.jetbrains.com/issues/IDEA

0

1. can't recreate. Are you using smart step into?

No, I'm not. Could doing so potentially solve the problem I'm describing?

-JM

 

 

 

0

No. Was asking because there is a known issue with Smart Step that looks similar - https://youtrack.jetbrains.com/issue/IDEA-154665

0

There is also a known problem with excluding java packages from stepping - https://youtrack.jetbrains.com/issue/IDEA-141323

0

OK. So I was NOT using the Smart Step function.

However, what I see matches what's described in IDEA-141323. Are you sayig you do NOT see that problem? So could this be related to some configuration setting, as there are apparently more users experiencing this annoyig problem?

 

-JM

0

there is not much you can configure there. i believe this mostly depends on a code being debugged/steps

0

Well, the code I have is plain and simple JavaScript, where one function calls another. When I hit "Step Into", I end up in intermediate Java code, as the other poster also says.

Are you saying that doesn't ALWAYS happen? Do you have some sample where stepping into a function works as expected, that I can test on my machine to ssee if I see the same?

-JM

0

In the example below, if I add breakpoint at printLog() call and hit F7 once breakpoint is hit, it steps directly to function code:

var HelloHelper = Java.type("demo.HelloHelper");
var helloHelper = new HelloHelper();

function sayHelloImpl(name) {
return helloHelper.getPrefix() + " " + name;
}

function newHelloWorld() {
printLog()
return new Packages.demo.HelloWorld() {
sayHello: sayHelloImpl
}
}
function printLog(){
console.log("printed")
}

var Vector = Packages.java.util.Vector;

newHelloWorld();
0

Please sign in to leave a comment.