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

Add support for debugging Nashorn 15.4 for OpenJDK >= 15 #7069

Closed
cz6ace opened this issue Feb 14, 2024 · 10 comments · Fixed by #7972
Closed

Add support for debugging Nashorn 15.4 for OpenJDK >= 15 #7069

cz6ace opened this issue Feb 14, 2024 · 10 comments · Fixed by #7972
Labels
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) kind:feature A feature request

Comments

@cz6ace
Copy link

cz6ace commented Feb 14, 2024

Description

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.

Request is to add debug support for the Nashorn 15.4.

Use case/motivation

Citing from Wikipedia:
With the release of Java 11, Nashorn was deprecated citing challenges to maintenance, and has been removed from JDK 15 onwards - https://openjdk.org/jeps/372

Nashorn development continues on GitHub as a standalone OpenJDK project. Because it has renamed the package name(s), the support located in below mentioned modules does not work:

  • org-netbeans-modules-debugger-jpda.jar
  • org-netbeans-modules-debugger-jpda-js.jar

Quick and dirty renaming of constants describing the new package of Nashorn works for me. Question is if the Netbeans maintainers are willing to accept the fix. Bellow you can find the dirty patch:
nashorn-15.patch

I'd like to open discussion if and how the support can be added into Netbeans:
a) just polish attached patch, discarding the support for the old Nashorn
b) maintain support for both Nashorn engines at the same time - automatic detection
c) maintain support for both Nashorn engines at the same time - by turning an option in preferences
d) any other suggestion?

Thank you,
Libor

Related issues

No response

Are you willing to submit a pull request?

Yes

@cz6ace cz6ace added kind:feature A feature request needs:triage Requires attention from one of the committers labels Feb 14, 2024
@mbien mbien 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) labels Feb 15, 2024
@matthiasblaesing
Copy link
Contributor

I would try to go down way (b). That way the discussion whether or not to drop $featureX in favor of $featureY does not need to happen.
The interesting question is: How ugly can it get and what should be supported? Could nashorn-jdk and nashorn-standalone coexist in a single VM and if so, is it possible to modify the routines, to cover both cases?

@cz6ace
Copy link
Author

cz6ace commented Apr 26, 2024

@matthiasblaesing,
I missed your question, sorry about that.

The interesting question is: How ugly can it get and what should be supported?

Ugly ... it depends on personal subjective feelings, only those constants will be doubled, not a big deal.

Could nashorn-jdk and nashorn-standalone coexist in a single VM

I guess so, they have different name space (package)

is it possible to modify the routines, to cover both cases?

Yes, it is.

Based on the question I deduct the fix for new Nashorn has a chance to be accepted, I'll prepare fix that supports both engines in one source code.

@matthiasblaesing
Copy link
Contributor

@cz6ace your interpretation is correct. Thanks for taking this on.

@ChrisHuebsch-FLIG
Copy link

Any chance that this ticket gets some progress?
Netbeans was the only IDE which was able to properly debug nashorn/js.
It's a bit sad that it no longer is.

@matthiasblaesing
Copy link
Contributor

matthiasblaesing commented Nov 14, 2024

@ChrisHuebsch-FLIG provide exakt steps of what you expect to work and people might look at it. Just talking about it won't help.

@cz6ace
Copy link
Author

cz6ace commented Nov 14, 2024

Any chance that this ticket gets some progress? Netbeans was the only IDE which was able to properly debug nashorn/js. It's a bit sad that it no longer is.

I know, I know, if there's really someone looking for it, I'll provide patch. I was terribly busy, but I did not forgot. Promise.

@ChrisHuebsch-FLIG
Copy link

I know, I know, if there's really someone looking for it, I'll provide patch. I was terribly busy, but I did not forgot. Promise.

I just got the current version from the git, added your patch, compiled it and now I am able to remote debug JS again. :-)

Works great. I really appreciate it.

@matthiasblaesing
Copy link
Contributor

@ChrisHuebsch-FLIG what I meant was, that to check if any changes worked, there needs to be an example what should happen. I.e. a sample project and what are to be executed in the IDE to reach the target state (initial debugging). The patch from @cz6ace looks sane to me and most probably it can be extended to cover both "JDK bundled" and "external nashorn" case. We went down the "just scan for the other named class" road already for the JavaEE/JakartaEE transition, so we know, that it works in principle.

@cz6ace
Copy link
Author

cz6ace commented Nov 17, 2024

I've prepared second patch that should work with both Nashorns - see attached
nashorn-15-both.patch
Before Pull request I tried to rebase (from Netbeans 20) to the latest master and I'm not able to compile. ant clean build did not help and whole Sunday is exhausted by this.

@ChrisHuebsch-FLIG could you please try this second patch? And what JDK do you have (I have OpenJDK 17.0.12 in Ubuntu 22) ? Any special environment set for compilation?

Edit: I was able to compile on master by moving to Ubuntu 24

@ChrisHuebsch-FLIG
Copy link

@ChrisHuebsch-FLIG could you please try this second patch? And what JDK do you have (I have OpenJDK 17.0.12 in Ubuntu 22) ? Any special environment set for compilation?

I am using Windows 10 & Adoptium OpenJDK 17.0.13_11

I was using a git bash to apply your (first) patch and used the method given by netbeans to compile it. (Set ANT_HOME and JAVA_HOME and run the ant.)
Although I got lots of warnings regarding deprecated APIs and "unsafe" casts, I got a working version.

For testing your second patch I need to find some time.

@mbien mbien removed the needs:triage Requires attention from one of the committers label Dec 29, 2024
@mbien mbien linked a pull request Dec 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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) kind:feature A feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants