Skip to content

Remove Thread.stop() usage #4952

Closed

Description

@mbien

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/

Activity

  1. added
    kind:bug
    priority:high
    on Nov 9, 2022
  2. BradWalker commented on Nov 9, 2022

    @BradWalker
    Member

    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..

  3. added this to the NB18 milestone on Jan 18, 2023
  4. matthiasblaesing commented on Feb 10, 2023

    @matthiasblaesing
    Contributor

    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:
    
  5. mbien commented on Mar 13, 2023

    @mbien
    MemberAuthor

    @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 :))

  6. matthiasblaesing commented on Mar 13, 2023

    @matthiasblaesing
    Contributor

    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:

  7. mbien commented on Mar 14, 2023

    @mbien
    MemberAuthor

    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.

  8. mbien commented on Mar 18, 2023

    @mbien
    MemberAuthor

    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.

  9. neilcsmith-net commented on May 2, 2023

    @neilcsmith-net
    Member

    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?

  10. mbien commented on May 2, 2023

    @mbien
    MemberAuthor

    @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.

  11. modified the milestones: NB18, NB19 on May 2, 2023
  12. added
    Upgrade JDK
    on Jun 1, 2023
  13. modified the milestones: NB19, NB20 on Jul 13, 2023
  14. removed this from the NB20 milestone on Oct 14, 2023
  15. mbien commented on Jun 27, 2024

    @mbien
    MemberAuthor

    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

  16. mbien commented on Jun 27, 2024

    @mbien
    MemberAuthor

    instead of fixing this, should we get rid of the downloader package+functionality?

  17. BradWalker commented on Jun 27, 2024

    @BradWalker
    Member

    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?

  18. mbien commented on Jul 3, 2024

    @mbien
    MemberAuthor

    the experiment at #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.

  19. mbien commented on Jul 3, 2024

    @mbien
    MemberAuthor

    see #7542 for NBI update

  20. matthiasblaesing commented on Jul 3, 2024

    @matthiasblaesing
    Contributor

    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?

    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.

  21. added
    Java
    on Feb 18, 2025
  22. mbien commented on Nov 16, 2025

    @mbien
    MemberAuthor

    this is mostly done, #9017 will remove whatever slipped through so far until nb builds on JDK 26 (which has now stop/suspend/resume removed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavaUpgrade JDKkind:bugpriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions