RFR: 8268056: Update java.net and java.nio to use switch expressions

Daniel Fuchs dfuchs at openjdk.java.net
Tue Jun 1 17:01:23 UTC 2021


On Tue, 1 Jun 2021 16:44:38 GMT, Patrick Concannon <pconcannon at openjdk.org> wrote:

> Hi,
> 
> Could someone please review my code for updating the code in the `java.net` and `java.nio` packages to make use of the switch expressions?
> 
> Kind regards,
> Patrick

src/java.base/share/classes/java/net/URLDecoder.java line 228:

> 226:                         // A trailing, incomplete byte encoding such as
> 227:                         // "%x" will cause an exception to be thrown
> 228: 

This change is a bit difficult to review and there doesn't appear much gain in changing from a regular switch to a switch expression in this case. Maybe we should just keep the regular switch here?

src/java.base/share/classes/java/nio/file/attribute/FileTime.java line 240:

> 238:                         Long.MAX_VALUE / SECONDS_PER_HOUR);
> 239:                 case MINUTES -> secs = scale(value, SECONDS_PER_MINUTE,
> 240:                         Long.MAX_VALUE / SECONDS_PER_MINUTE);

It would be nicer to keep the second line aligned with the opening parenthesis, as it was before.

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

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


More information about the nio-dev mailing list