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

Merged
merged 1 commit into from
Dec 30, 2024

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

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.

@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
Copy link
Author

cz6ace commented Dec 27, 2024

Hi @matthiasblaesing ,

even though I was able to debug the javascript on my side, I also had those weird breakpoints you mentioned in the screenshots - and in fact, they revealed that I brought some regression(s). I'll work on it before the vacation ends.

Libor

@cz6ace
Copy link
Author

cz6ace commented Dec 28, 2024

Hi @matthiasblaesing,

with the last commit I can debug in both cases, I tried

  • OpenJDK 11 (commented the Nashorn in the pom.xml)
  • OpenJDK 17 with enabled Nashorn in the pom.xml
    First, it stops in the javascript, second, it does not stop in the Nashorn sources (your screenshots)

If you could please check on your side again, it will be appreciated.

My results:
JDK 11:
image

JDK 17:
image

@matthiasblaesing matthiasblaesing added this to the NB25 milestone Dec 29, 2024
@matthiasblaesing matthiasblaesing added JavaScript [ci] enable web job and extra JavaScript tests (webcommon/javascript2.editor) Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) debugger labels Dec 29, 2024
@apache apache locked and limited conversation to collaborators Dec 29, 2024
@apache apache unlocked this conversation Dec 29, 2024
@matthiasblaesing
Copy link
Contributor

Thank you for the update. I confirm, that it works for me and I think we should get this in. @cz6ace would you please squash this, so that I can invoke a final CI/CD run. The current test failure is caused by CI/CD picking up commit messages, that are obviously not final.

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.

Co-authored-by: Matthias Bläsing <[email protected]>
@cz6ace cz6ace force-pushed the NETBEANS-7069_nashorn-15 branch from b701ada to 9a5a9d7 Compare December 29, 2024 19:51
@cz6ace
Copy link
Author

cz6ace commented Dec 29, 2024

Good to hear it works on your side too. I did the squash and rebased to the latest master to be sure there's no surprise.
Please execute the CI/CD, thx!

@mbien mbien linked an issue Dec 29, 2024 that may be closed by this pull request
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.

Looks sane to me. Lets get this in.

@matthiasblaesing matthiasblaesing merged commit 5151af3 into apache:master Dec 30, 2024
36 checks passed
@matthiasblaesing
Copy link
Contributor

@cz6ace thank you for looking into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debugger Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) JavaScript [ci] enable web job and extra JavaScript tests (webcommon/javascript2.editor)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for debugging Nashorn 15.4 for OpenJDK >= 15
2 participants