JDK-8250241 : Address use of default constructors in the java.util.concurrent
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 16
  • Submitted: 2020-07-23
  • Updated: 2020-07-24
  • Resolved: 2020-07-24
Related Reports
CSR :  
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


Comments
Moving to Approved.
24-07-2020