Hello,

did anyone try to get CDS working with NetBeans before?

I just ran a little experiment and tried to start NB 12.1 with dynamic class data archives[1][2].

(dynamic CDS (java 13+) is basically a fancy word for a second application specific archive, layered on top of the JDK specific class data archive, which is mapped into shared memory on jvm startup for various reasons. (faster startup, potential of saving mem by sharing it between mult. JVMs etc))

unfortunately i couldn't get it to work at first because NB thought the JDK disappeared as soon the JVM was started with the archive :)


what i did (JDK 15, NB 12.1 on linux, started with "sh bin/netbeans" to see startup errors right away + to be able to use relative filename paths):

0) remove the evil -J-XX:+IgnoreUnrecognizedVMOptions from netbeans.conf->netbeans_default_options before starting any experiment

1) first I verified that the JDK base CDS file exists and is working by adding -J-Xshare:on and checked if it still starts - worked fine. (if this doesn't work, you can regenerate the JDK CDS with "sudo [JDK]/bin/java -Xshare:dump")

2) start with -J-Xshare:on -J-XX:ArchiveClassesAtExit=nb.jsa

Opened a pom, edited a java file and built a maven project. Closed IDE. (the JVM will keep going for a few moments until the archiving is finished)

a file called nb.jsa should be now in the netbeans folder. 154 MB large in my case.

3) start with -J-Xshare:on -J-XX:SharedArchiveFile=nb.jsa

and i got this exception:

[mbien@longbow netbeans_12.1]$ sh bin/netbeans
java.lang.IllegalStateException: Were trying to install a module that had never been checked: StandardModule:org.netbeans.api.debugger.jpda jarFile: /home/mbien/dev/netbeans_12.1/java/modules/org-netbeans-api-debugger-jpda.jar
    at org.netbeans.ModuleManager.enable(ModuleManager.java:1363)
    at org.netbeans.ModuleManager.enable(ModuleManager.java:1254)
    at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:315)
    at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:251)
    at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:298)
    at org.netbeans.core.startup.Main.getModuleSystem(Main.java:156)
    at org.netbeans.core.startup.Main.getModuleSystem(Main.java:125)
    at org.netbeans.core.startup.Main.start(Main.java:282)
    at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:98)
    at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: org.netbeans.InvalidException: <b>The JDK is missing and is required to run some NetBeans modules</b><br> Please use the --jdkhome command line option to specify a JDK<br>installation or see <a href="http://wiki.netbeans.org/FaqRunningOnJre";>http://wiki.netbeans.org/FaqRunningOnJre</a> for<br> more information.
    at org.netbeans.ModuleManager.enable(ModuleManager.java:1345)
    ... 9 more

@ https://github.com/apache/netbeans/blob/12.1/platform/o.n.bootstrap/src/org/netbeans/ModuleManager.java#L1345

after staring at the code for a bit i decided to remove the check [3] and test again... and it worked. (Btw i don't think the exception msg text is correct, maybe the check used to do something else once?)

thats when i ran out of time so i thought i write it down and send it to the list.


note1: older JDKs will require slightly different JVM flags e.g additional -XX:+UseAppCDS + the enable experimental options flag, so i recommend to use the latest JDK for now to keep it simple

note2: i did also try the old approach which would work on JDK 11 (JEP 310, java 10+):

1) -J-Xshare:off -J-XX:DumpLoadedClassList=nbclasses.list
2) -J-Xshare:dump -J-XX:SharedClassListFile=nbclasses.list -J-XX:SharedArchiveFile=app.jsa
3) -J-Xshare:on -J-XX:SharedArchiveFile=app.jsa

smaller file but same result


best regards,

michael

[1] https://openjdk.java.net/jeps/350

[2] https://mbien.dev/blog/entry/dynamic-application-class-data-sharing (old blog entry)

[3] https://github.com/apache/netbeans/blob/12.1/platform/o.n.bootstrap/src/org/netbeans/ModuleManager.java#L1336-L1350


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Reply via email to