<i18n dev> RFR: 8269124: Update java.time to use switch expressions (part II) [v2]

Patrick Concannon pconcannon at openjdk.java.net
Tue Jun 22 16:07:16 UTC 2021


On Tue, 22 Jun 2021 15:40:12 GMT, Aleksei Efimov <aefimov at openjdk.org> wrote:

>> Patrick Concannon has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8269124: Added missing brace; fixed build issue
>
> src/java.base/share/classes/java/time/Instant.java line 852:
> 
>> 850:     public Instant plus(long amountToAdd, TemporalUnit unit) {
>> 851:         if (unit instanceof ChronoUnit) {
>> 852:             switch ((ChronoUnit) unit) {
> 
> It looks like we need to put `return` here, otherwise `UnsupportedTemporalTypeException` will be thrown every time the method is called:
> 
> jshell> Instant.now()
> $2 ==> 2021-06-22T15:35:28.771128667Z
> 
> jshell> $2.plus(10L, ChronoUnit.SECONDS)
> |  Exception java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Seconds
> |        at Instant.plus (Instant.java:862)
> |        at (#5:1)

I've made that change now. See 5fa4e3c

> src/java.base/share/classes/java/time/ZonedDateTime.java line 1311:
> 
>> 1309:                 }
>> 1310:                 default -> resolveLocal(dateTime.with(field, newValue));
>> 1311:         };
> 
> It looks like that the closing braces `}` is missing here.

Hi Aleksei, thanks for spotting this. I've added that in now. See 5fa4e3c

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

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


More information about the i18n-dev mailing list