On Sun, 1 May 2022 14:35:28 GMT, Rémi Forax <fo...@openjdk.org> wrote:
>> Doug Lea has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Address review comments > > 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"); > ... > }; Sorry, I don't understand how it would be more readable. I like new switch features because they extend the range of applicability of switch. But this (and the two others) are just plain vanilla enum-based switches that were handled well, and seem to have the same numbers of lines and structure either way? ------------- PR: https://git.openjdk.java.net/jdk/pull/8490