Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8320598

Remove Thread/ThreadGroup suspend/resume

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 23
    • core-libs
    • None
    • source, binary, behavioral
    • low
    • Hide
      The methods throw UOE since Java 19/20. It's possible there is code somewhere that "wraps" a Thread or ThreadGroup and delegates all methods. This code will no longer compile without change. Code compiled to older releases will continue to run but if any of these methods are invoked, NoSuchMethodError will be thrown instead of UnsupportedOperationException.

      Corpus analysis of 176180458 classes in 484751 artifacts found no usages of ThreadGroup.suspend/resume except for artifacts that had copies of java.lang.ThreadGroup. The analysis found 87 uses of Thread.suspend and 86 uses of Thread.resume.
      Show
      The methods throw UOE since Java 19/20. It's possible there is code somewhere that "wraps" a Thread or ThreadGroup and delegates all methods. This code will no longer compile without change. Code compiled to older releases will continue to run but if any of these methods are invoked, NoSuchMethodError will be thrown instead of UnsupportedOperationException. Corpus analysis of 176180458 classes in 484751 artifacts found no usages of ThreadGroup.suspend/resume except for artifacts that had copies of java.lang.ThreadGroup. The analysis found 87 uses of Thread.suspend and 86 uses of Thread.resume.
    • Java API
    • SE

    Description

      Summary

      Remove java.lang.Thread.suspend, java.lang.Thread.resume, java.lang.ThreadGroup.suspend, and java.lang.ThreadGroup.resume.

      Problem

      The deadlock prone suspend/resume methods date from JDK 1.0. These methods were deprecated in JDK 1.2 (1998), and deprecated for removal in Java 14. The ThreadGroup.suspend/resume method were re-specified/degraded to throw UnsupportedOperationException (UOE) in Java 19. The Thread.suspend/resume method were re-specified/degraded to throw UOE in Java 20.

      It is time to finally remove these method from the API.

      Solution

      • Remove the 4 methods.

      • Adjust java.lang.management.ThreadInfo::isSuspended so that it doesn't link to Thread.suspend.

      • Update the "Java Thread Primitive Deprecation" docs page, linked from the Thread.stop deprecation text, to remove the two questions/answers related to thread suspension.

      Specification

      Remove java.lang.Thread.suspend, java.lang.Thread.resume, java.lang.ThreadGroup.suspend, and java.lang.ThreadGroup.resume.

      Adjust the specification of java.lang.management.ThreadInfo::isSuspended to link to the JVM TI SuspendThread function instead of Thread.suspend.

           /**
      -     * Tests if the thread associated with this {@code ThreadInfo}
      -     * is suspended.  This method returns {@code true} if
      -     * {@link Thread#suspend} has been called.
      +     * Tests if the thread associated with this {@code ThreadInfo} is
      +     * <a href="{@docRoot}/../specs/jvmti.html#SuspendThread">suspended</a>.
            *
            * @return {@code true} if the thread is suspended;
            *         {@code false} otherwise.
      +     *
      +     * @spec jvmti.html JVM Tool Interface
            */

      Attachments

        Issue Links

          Activity

            People

              alanb Alan Bateman
              alanb Alan Bateman
              David Holmes, Jaikiran Pai, Serguei Spitsyn
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: