RFR: 8268469: Update java.time to use switch expressions [v3]
Patrick Concannon
pconcannon at openjdk.java.net
Wed Jun 16 10:57:19 UTC 2021
On Wed, 9 Jun 2021 16:25:55 GMT, Naoto Sato <naoto at openjdk.org> wrote:
>> Patrick Concannon has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>>
>> - 8268469: Removed excessive spacing; corrected misplaced comments
>> - Merge remote-tracking branch 'origin/master' into JDK-8268469
>> - Merge remote-tracking branch 'origin/master' into JDK-8268469
>> - 8268469: Update java.time to use switch expressions
>
> src/java.base/share/classes/java/time/LocalDateTime.java line 1188:
>
>> 1186: case HOURS -> plusHours(amountToAdd);
>> 1187: case HALF_DAYS -> plusDays(amountToAdd / 256).plusHours((amountToAdd % 256) * 12);
>> 1188: default -> with(date.plus(amountToAdd, unit), time); // no overflow (256 is multiple of 2)
>
> The comment is misplaced.
Hi Naoto. Thanks for spotting this. I've corrected that now. Please see commit 2ae4a57
> src/java.base/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java line 310:
>
>> 308: case HOURS -> plusHours(amountToAdd);
>> 309: case HALF_DAYS -> plusDays(amountToAdd / 256).plusHours((amountToAdd % 256) * 12);
>> 310: default -> with(date.plus(amountToAdd, unit), time); // no overflow (256 is multiple of 2)
>
> Misplaced comment here too.
Comment corrected. Please see commit 2ae4a57
> src/java.base/share/classes/java/time/format/SignStyle.java line 127:
>
>> 125: boolean parse(boolean positive, boolean strict, boolean fixedWidth) {
>> 126: return switch (ordinal()) {
>> 127: // valid if negative or (positive and lenient)
>
> The comment should apply only to the `case 0`.
Comment corrected. Please see commit 2ae4a57
-------------
PR: https://git.openjdk.java.net/jdk/pull/4433
More information about the core-libs-dev
mailing list