Remove Thread.stop() usage
Those methods are deprecated since Java 1.2 and will throw UnsupportedOp exceptions from JDK 20+.
got reminded today again by getting this notification: https://inside.java/2022/11/09/quality-heads-up/
It is for issues like this, that I've been working on trying to clean up "old code". Because eventually it is going to bite us in a major way..
I asked jackpot for help and it answered (running the "Invoking Thread.stop()/suspend()/resume()" hint):
nbi/engine/src/org/netbeans/installer/downloader/dispatcher/impl/RoundRobinDispatcher.java:122:
nbi/engine/src/org/netbeans/installer/downloader/dispatcher/impl/RoundRobinDispatcher.java:168:
harness/o.n.insane/src/org/netbeans/insane/scanner/ScannerUtils.java:256:
harness/o.n.insane/src/org/netbeans/insane/scanner/ScannerUtils.java:267:
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerModule.java:84:
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerModule.java:151:
ide/httpserver/src/org/netbeans/modules/httpserver/HttpServerModule.java:157:
ide/extbrowser/test/ExtBrowser/qa-functional/src/org/netbeans/test/gui/web/util/HttpRequestWaitable.java:117:
ide/editor.search/test/unit/src/org/netbeans/modules/editor/search/EditorFindSupportTest.java:78:
ide/editor.search/test/unit/src/org/netbeans/modules/editor/search/EditorFindSupportTest.java:112:
ide/editor.search/test/unit/src/org/netbeans/modules/editor/search/EditorFindSupportTest.java:147:
ide/editor.search/test/unit/src/org/netbeans/modules/editor/search/EditorFindSupportTest.java:181:
ide/editor.search/test/unit/src/org/netbeans/modules/editor/search/EditorFindSupportTest.java:217:
ide/editor.search/test/unit/src/org/netbeans/modules/editor/search/EditorFindSupportTest.java:253:
extide/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/BridgeImpl.java:329:
java/lib.jshell.agent/agentsrc/org/netbeans/lib/jshell/agent/AgentWorker.java:493:
java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java:263:
webcommon/cordova/test/unit/src/org/netbeans/modules/web/clientproject/cordova/AndroidPlatformTest.java:208:
nb/deadlock.detector/test/unit/src/org/netbeans/modules/deadlock/detector/DetectorTest.java:106:
nb/deadlock.detector/test/unit/src/org/netbeans/modules/deadlock/detector/DetectorTest.java:107:
platform/openide.nodes/test/unit/src/org/openide/nodes/ChildrenKeysTest.java:192:
platform/openide.nodes/test/unit/src/org/openide/nodes/ChildrenKeysTest.java:193:
platform/core.execution/src/org/netbeans/core/execution/SecMan.java:82:
platform/core.execution/src/org/netbeans/core/execution/SecMan.java:84:
platform/openide.util/test/unit/src/org/openide/util/RequestProcessor180386Test.java:479:
platform/openide.util/test/unit/src/org/openide/util/RequestProcessor180386Test.java:504:
platform/o.n.core/src/org/netbeans/core/CLIOptions2.java:113:
@matthiasblaesing could you generate a new list so that we can see what is left to do? (or even better share the script which runs jackpot on all projects :))
Here you are:
nbi/engine/src/org/netbeans/installer/downloader/dispatcher/impl/RoundRobinDispatcher.java:122:
nbi/engine/src/org/netbeans/installer/downloader/dispatcher/impl/RoundRobinDispatcher.java:168:
extide/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/BridgeImpl.java:329:
java/lib.jshell.agent/agentsrc/org/netbeans/lib/jshell/agent/AgentWorker.java:493:
java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java:263:
webcommon/cordova/test/unit/src/org/netbeans/modules/web/clientproject/cordova/AndroidPlatformTest.java:208:
nb/deadlock.detector/test/unit/src/org/netbeans/modules/deadlock/detector/DetectorTest.java:106:
nb/deadlock.detector/test/unit/src/org/netbeans/modules/deadlock/detector/DetectorTest.java:107:
platform/openide.nodes/test/unit/src/org/openide/nodes/ChildrenKeysTest.java:192:
platform/openide.nodes/test/unit/src/org/openide/nodes/ChildrenKeysTest.java:193:
platform/core.execution/src/org/netbeans/core/execution/SecMan.java:82: warning:
platform/core.execution/src/org/netbeans/core/execution/SecMan.java:84: warning:
platform/openide.util/test/unit/src/org/openide/util/RequestProcessor180386Test.java:479:
platform/openide.util/test/unit/src/org/openide/util/RequestProcessor180386Test.java:504:
platform/o.n.core/src/org/netbeans/core/CLIOptions2.java:113:
This list is generated using jackpot like this:
- grab jackpot from: https://dist.apache.org/repos/dist/release/netbeans/netbeans-jackpot/netbeans-jackpot-13.0/apache-netbeans-jackpot-13.0-bin.zip
- run it as
PATH_TO_ZIP_CONTENTS/jackpot/jackpot --hint "Invoking Thread.stop()/suspend()/resume()" PATH_TO_NETBEANS
awesome, thanks. This doesn't look that bad anymore thanks to your work. If we remove all tests from that list, we get this:
nbi/engine/src/org/netbeans/installer/downloader/dispatcher/impl/RoundRobinDispatcher.java:122:
nbi/engine/src/org/netbeans/installer/downloader/dispatcher/impl/RoundRobinDispatcher.java:168:
extide/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/BridgeImpl.java:329:
java/lib.jshell.agent/agentsrc/org/netbeans/lib/jshell/agent/AgentWorker.java:493:
platform/core.execution/src/org/netbeans/core/execution/SecMan.java:82: warning:
platform/core.execution/src/org/netbeans/core/execution/SecMan.java:84: warning:
platform/o.n.core/src/org/netbeans/core/CLIOptions2.java:113:
BridgeImpluses stop as fallback, we could probably simply catch UOE there or guard against JDK 20+.
SecMan is full with deprecated code since SecurityManager itself is deprecated. This will be harder to solve.
AgentWorker for jshell might also cause problems, it should probably interrupt and pray.
SLIOptions2 uses stop too as last resort.
another bogeyman showed up: https://download.java.net/java/early_access/jdk20/docs/api/java.base/java/lang/ThreadGroup.html#stop() will throw UOEs too.
https://download.java.net/java/early_access/jdk20/docs/api/java.base/java/lang/ThreadGroup.html#destroy() is now a no-op.
Tested NB from master on JDK 20 a bit and things did work pretty well already. Canceling background tasks did also work, resetting JShell sessions worked, cancelling maven+ant builds seems to work too, project run -> stop had also no problem.
This is still open and marked high priority for NB18. Where are we at with this? Are there still things we need to address before release?
@neilcsmith-net we can move this to NB19. This is something we can do incrementally. I couldn't find any showstoppers while testing on JDK 20 so far. Matthias did also replace some important implementations already.
NBI can't be built on JDK 23 since it uses some of the removed methods, example:
[repeat] /home/runner/work/netbeans/netbeans/nbi/engine/src/org/netbeans/installer/downloader/dispatcher/impl/RoundRobinDispatcher.java:222: error: cannot find symbol
[repeat] current.resume();
https://github.com/apache/netbeans/actions/runs/9690496379
instead of fixing this, should we get rid of the downloader package+functionality?
instead of fixing this, should we get rid of the downloader package+functionality?
I am sill a believer that we should clearn up the usage of Thread.stop instead of removing the downloader package?
the experiment at https://github.com/apache/netbeans/pull/7538 showed that removal of downloader/* is likely the quickest option. It builds, it tests and I also generated an .exe installer and tested it manually (only on JDK 22 since the (native) installer can't parse ea java versions, but this is off topic).
NBI is in bad shape, unmaintained and NB is slowly transitioning to @neilcsmith-net's nbpackage, everything except windows is using it already. The NBI issue is preventing us from building or testing NetBeans on JDK 23 which is a problem.
I will open a proper PR soon, with the cleaned up changes which remove the online functionality from NBI to give it a small life time extension. This would go in first, then we can merge the nb-javac 23 PR once ready, then the CI-on-23 PR and we are (hopefully) good for the NB 23 cycle.
see https://github.com/apache/netbeans/pull/7542 for NBI update
instead of fixing this, should we get rid of the downloader package+functionality?
I am sill a believer that we should clearn up the usage of
Thread.stopinstead of removing the downloader package?
This was my first reaction and as @mbien writes in #7542 also his. But this needs someone to actually do the work and I decided for myself that I'm not willing to do it.
this is mostly done, https://github.com/apache/netbeans/pull/9017 will remove whatever slipped through so far until nb builds on JDK 26 (which has now stop/suspend/resume removed).