RFR: 8212895: ChronoField.INSTANT_SECONDS's range doesn't match the range of Instant

Jaikiran Pai jpai at openjdk.org
Tue Apr 9 00:55:09 UTC 2024


On Mon, 8 Apr 2024 18:16:04 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> src/java.base/share/classes/java/time/temporal/ChronoField.java line 590:
>> 
>>> 588:      * This is necessary to ensure interoperation between calendars.
>>> 589:      */
>>> 590:     // ValueRange matches the min and max epoch second supported by java.time.Instant
>> 
>> Would we want to include this in the javadoc?
>
> The code should reference the constants in Instant.java (though may need to make them package private.)
> 
> The javadoc can/should reference Instant.MIN and Instant.MAX (as the test does).

Hello Roger,

> The code should reference the constants in Instant.java (though may need to make them package private.)

The `ChronoField` class and the `Instant` class reside in separate packages, so making these two fields in `Instant`, package private will not help. I will have to make them public, which I think probably isn't a good idea. Unless you think we should do it? There is one other place already in the JDK where we have copy/pasted these values `src/java.base/share/classes/java/nio/file/attribute/FileTime.java`, so maybe we can continue with this copy/paste here too?

As for the javadoc, after we decide about this field access detail, I'll update it accordingly to note that the values min and max range complies with the min and max epoch seconds supported by `Instant`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18674#discussion_r1556676053


More information about the core-libs-dev mailing list