RFR: 8277090 : jsr166 refresh for jdk19

Rémi Forax forax at openjdk.java.net
Sun May 1 14:42:55 UTC 2022


On Sun, 1 May 2022 10:53:55 GMT, Doug Lea <dl at openjdk.org> wrote:

> This is the jsr166 refresh for jdk19. See https://bugs.openjdk.java.net/browse/JDK-8285450 and https://bugs.openjdk.java.net/browse/JDK-8277090

src/java.base/share/classes/java/util/concurrent/ExecutorService.java line 138:

> 136:  * @author Doug Lea
> 137:  */
> 138: public interface ExecutorService extends Executor, AutoCloseable {

The class documentation should be expanded to explain that an ExecutorService can be used with a try-with-resources

src/java.base/share/classes/java/util/concurrent/FutureTask.java line 222:

> 220:                 throw new IllegalStateException("Task has not completed");
> 221:         }
> 222:     }

I think the code will be more readable if a switch expression and the arrow syntax are used


return switch(state()) {
    case SUCCESS -> {
        @SuppressWarnings("unchecked")
        V result = (V) outcome;
        yield result;
    } 
    case FAILED -> throw new IllegalStateException("Task completed with exception");
    ...
};

src/java.base/share/classes/java/util/concurrent/FutureTask.java line 237:

> 235:                 throw new IllegalStateException("Task has not completed");
> 236:         }
> 237:     }

Same here !

src/java.base/share/classes/java/util/concurrent/FutureTask.java line 247:

> 245:             s = state;
> 246:         }
> 247:         switch (s) {

same here !

-------------

PR: https://git.openjdk.java.net/jdk/pull/8490


More information about the core-libs-dev mailing list