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

Address use of default constructors in the java.util.concurrent

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 16
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      The explicit constructors are functionally equivalent to the default ones they're replacing.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Replace default constructors in java.util.concurrent with equivalent explicit constructors.

      Problem

      Default constructors considered harmful in formal APIs.

      Solution

      Add explicit constructors.

      Specification

      diff -r d62da6fc4074 src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java
      --- a/src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java Thu Jul 23 20:25:41 2020 +0100
      +++ b/src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java Thu Jul 23 14:59:38 2020 -0700
      @@ -77,6 +77,11 @@
       public abstract class AbstractExecutorService implements ExecutorService {
      
           /**
      +     * Constructor for subclasses to call.
      +     */
      +    public AbstractExecutorService() {}
      +
      +    /**
            * Returns a {@code RunnableFuture} for the given runnable and default
            * value.
            *
      diff -r d62da6fc4074 src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java
      --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java    Thu Jul 23 20:25:41 2020 +0100
      +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java    Thu Jul 23 14:59:38 2020 -0700
      @@ -242,6 +242,11 @@
           private static final int SIGNAL   = 1 << 16; // true if joiner waiting
           private static final int SMASK    = 0xffff;  // short bits for tags
      
      +    /**
      +     * Constructor for subclasses to call.
      +     */
      +    public ForkJoinTask() {}
      +
           static boolean isExceptionalStatus(int s) {  // needed by subclasses
               return (s & THROWN) != 0;
           }
      diff -r d62da6fc4074 src/java.base/share/classes/java/util/concurrent/RecursiveAction.java
      --- a/src/java.base/share/classes/java/util/concurrent/RecursiveAction.java Thu Jul 23 20:25:41 2020 +0100
      +++ b/src/java.base/share/classes/java/util/concurrent/RecursiveAction.java Thu Jul 23 14:59:38 2020 -0700
      @@ -166,6 +166,11 @@
           private static final long serialVersionUID = 5232453952276485070L;
      
           /**
      +     * Constructor for subclasses to call.
      +     */
      +    public RecursiveAction() {}
      +
      +    /**
            * The main computation performed by this task.
            */
           protected abstract void compute();
      diff -r d62da6fc4074 src/java.base/share/classes/java/util/concurrent/RecursiveTask.java
      --- a/src/java.base/share/classes/java/util/concurrent/RecursiveTask.java   Thu Jul 23 20:25:41 2020 +0100
      +++ b/src/java.base/share/classes/java/util/concurrent/RecursiveTask.java   Thu Jul 23 14:59:38 2020 -0700
      @@ -69,6 +69,11 @@
           private static final long serialVersionUID = 5232453952276485270L;
      
           /**
      +     * Constructor for subclasses to call.
      +     */
      +    public RecursiveTask() {}
      +
      +    /**
            * The result of the computation.
            */
           @SuppressWarnings("serial") // Conditionally serializable
      diff -r d62da6fc4074 src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
      --- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java    Thu Jul 23 20:25:41 2020 +0100
      +++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java    Thu Jul 23 14:59:38 2020 -0700
      @@ -65,6 +65,11 @@
      
           private static final long serialVersionUID = 7373984972572414692L;
      
      +    /**
      +     * Constructor for subclasses to call.
      +     */
      +    public AbstractQueuedLongSynchronizer() {}
      +
           /*
            * To keep sources in sync, the remainder of this source file is
            * exactly cloned from AbstractQueuedSynchronizer, replacing class

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                darcy Joe Darcy
                Reporter:
                darcy Joe Darcy
                Reviewed By:
                Martin Buchholz
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: