Skip to content

Properly handle UnsupportedOperationException thrown by Thread::stop in JDK 20+ #391

@kriegaex

Description

@kriegaex

Since JDK 20, Thread::stop throws an UnsupportedOperationException, see the corresponding code change in OpenJDK. Actually, the method was deprecated since JDK 1.2 and slated for removal long ago, too. See also JDK-8204243. The rationale behind deprecation and how to better stop a thread are explained in Oracle's "Java Thread Primitive Deprecation".

Not only does ExecJavaMojoTest::testUncooperativeThread use Thread::stop, which is why unit tests are failing since JDK 20, but more severely, mojo exec:java will fail, too, if option stopUnresponsiveDaemonThreads is active. At the very least, an UnsupportedOperationException must be handled and reported in ExecJavaMojo::terminateThreads. Furthermore, option stopUnresponsiveDaemonThreads should be documented accordingly and its use be warned about with special notice of JDK 20+ where it has no effect (other than those exceptions I just mentioned).

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