Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NETBEANS-7069] Support Nashorn 15.x for JDK >= 15 #7972

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cz6ace
Copy link

@cz6ace cz6ace commented Nov 17, 2024

Netbeans does support debugging of legacy Nashorn JavaScript engine bundled with OpenJDK < 15.0. It does not support the the most recent Nashorn 15.4 extracted from OpenJDK, that has different package name.

Change allows debugging both legacy Nashorn JavaScript and also extracted Nashorn with new org.openjdk.nashorn package name.

See issue #7069

Netbeans does support debugging of legacy Nashorn JavaScript engine
bundled with OpenJDK < 15.0. It does not support the the most recent
Nashorn 15.4 extracted from OpenJDK, that has different package name.

Change allows debugging both legacy Nashorn JavaScript and also
extracted Nashorn with new org.openjdk.nashorn package name.
Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this. I left a first set of comments inline. The bad part is, that it does not work for me.

This is the project I used to test: mavenproject3.zip

Baseline is (more or less) current master. I configure the maven project to use JDK 11 for execution and comment out the Nashorn dependency. Then I place a breakpoint in the test.js file, line 5. Then I invoke "Debug" from the context menu of the project. The IDE starts the programm and the breakpoint in the JS code is hit. This looks like the expected behavior.

I then reconfigured the maven project to run with JDK 21 and reenabled the Nashorn dependency (only out-of-jdk Nashorn is run). With that baseline does not break anywhere, programm just runs through.

Side information I noticed while testing was, that when both out-of-jdk Nashorn and in-jdk Nashorn are present (dependency commented in and running on JDK 11), the out-of-jdk version if preferred by ScriptEngineManager.

With this PR and the same setup I get several hits in java code:

grafik

grafik

grafik

grafik

grafik

grafik

But none in JS. I would first look inside JSJavaBreakpointsManager.java. One thing to keep in mind in that class is, that it might be called multiple times. NetBeans supports multiple debugging sessions in parallel and then engineAdded is called multiple times, without calls to engineRemoved in between.

@@ -64,7 +64,7 @@
@LazyActionsManagerListener.Registration(path="netbeans-JPDASession/Java")
public class StepIntoJSHandler extends LazyActionsManagerListener implements PropertyChangeListener {

private static final String SCRIPT_ACCESS_CLASS = "jdk.nashorn.internal.runtime.ScriptFunctionData"; // NOI18N
private static final String SCRIPT_ACCESS_CLASS = "org.openjdk.nashorn.internal.runtime.ScriptFunctionData"; // NOI18N
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, this also need to be duplicated so that both in-jdk and external nashorn are supported.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, you are correct, I missed this. Need to apply for both Nashorns too.

@cz6ace
Copy link
Author

cz6ace commented Nov 22, 2024

Hi @matthiasblaesing ,
thank you for comments, I'll check. To be honest, I tried both scenarios with external application and I simply attached via socket to the jvm. And the debugger stopped in JDK, but following "step" got me into the javascript.

I'll try your project.

And yes, problem will be most probably in the JSJavaBreakpointsManager, this is tricky part, because one has to create breakpoints in advance and the debugger instance not available, so I created two sets of breakpoints. I need also put some explanation for potential reader.

cz6ace and others added 3 commits November 22, 2024 10:48
…ls/CallStackFrameImpl.java

Co-authored-by: Matthias Bläsing <[email protected]>
…s/vars/JSVariable.java


Of course this was wrong typo.

Btw, I'll squash all commits later on.

Co-authored-by: Matthias Bläsing <[email protected]>
…s/vars/JSVariable.java

Co-authored-by: Matthias Bläsing <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants