Skip to content

Use of deprecated Thread.stop prevents interruption on Java 20+ #1379

@Jengamon

Description

@Jengamon

Steps to reproduce

  1. Install a JDK/JRE for Java 20 or later.
  2. Open an Ammonite REPL using that JDK/JRE (using Scala 3, but that isn't too relevant maybe)
  3. Run the line while true do () (Scala 3)
  4. Attempt to Ctrl-C
  5. You should see
Exception in thread "SIGINT handler" java.lang.UnsupportedOperationException
        at java.base/java.lang.Thread.stop(Thread.java:1705)
        at ammonite.repl.Repl.$anonfun$action$5(Repl.scala:191)
        at ammonite.repl.Signaller$$anon$1.handle(Signaller.scala:21)
        at jdk.unsupported/sun.misc.Signal$InternalMiscHandler.handle(Signal.java:198)
        at java.base/jdk.internal.misc.Signal$1.run(Signal.java:218)
        at java.base/java.lang.Thread.run(Thread.java:1623)

because in Java 20 (https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/lang/Thread.html#stop()) the function has been "removed" and apparently should be replaced with Thread.interrupt and interruption checking/allowing on the execution thread.

The problematic line seems to be here:

Expected behavior

I expected to be able to interrupt long running programs, which was one of the advertised benefits of Ammonite-REPL.

Environment

Ammonite: 3.0.0-M0-53-084f7f4e
Scala: 3.3.1
Java: 20

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions