On Fri, 9 Sep 2022 12:44:31 GMT, Alan Bateman <[email protected]> wrote:
> Degrade Thread.stop to throw UOE unconditionally, deprecate ThreadDeath for
> removal, and remove the remaining special handling of ThreadDeath from the
> JDK.
>
> Thread.stop is inherently unsafe and has been deprecated since JDK 1.2 (1998)
> with a link to a supplementary page that explains the rationale. Some of the
> API surface has already been degraded or removed: Thread.stop(Throwable) was
> degraded to throw UOE in Java 8 and removed in Java 11, and ThreadGroup.stop
> was degraded to throw UOE in Java 19. As of Java 19, the no-arg Thread.stop
> continues to work as before for platform threads but throws UOE for virtual
> threads. The next step in the glacial pace removal is the degrading of the
> no-arg Thread.stop method to throw UOE for all threads.
>
> To keep things manageable, the change proposed here leaves JVM_StopThread in
> place. A separate issue will remove it and do other cleanup/removal in the
> VM. We have another JBS issue for the updates to the JLS and JVMS where
> asynchronous exceptions are defined. There is also some remaining work on a
> test class used by 6 jshell tests - if they aren't done in time then we will
> temporarily exclude them.
>
> The change here has no impact on the debugger APIs (JVM TI StopThread, JDWP
> ThreadReference/Stop, and JDI ThreadReference.stop). Debuggers can continue
> to cause threads to throw an asynchronous exception, as might be done when
> simulating code throwing an exception at some point in the code.
src/java.base/share/classes/java/lang/ThreadDeath.java line 42:
> 40: */
> 41: @Deprecated(since="20")
> 42: public class ThreadDeath extends Error {
Actually, `ThreadDeath` is thrown manually by **JShell** instrumentation code
since [JDK‑8289613] ([GH‑10166])[^1].
[JDK‑8289613]: https://bugs.openjdk.org/browse/JDK-8289613
[GH‑10166]: https://github.com/openjdk/jdk/pull/10166
[^1]:
https://github.com/openjdk/jdk/blob/00befddd7ce97d324250807824469daaa9434eef/src/jdk.jshell/share/classes/jdk/jshell/execution/LocalExecutionControl.java#L104-L107
-------------
PR: https://git.openjdk.org/jdk/pull/10230