On Fri, 24 Jul 2026 21:13:29 GMT, Mikhail Yankelevich 
<[email protected]> wrote:

>> Adding new methods to `X509Certificate` to return `Instant` instead of 
>> `Date` as well as moving away from `Date` in internal packages wherever 
>> possible.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Mikhail Yankelevich has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Update X509Certificate.java

src/java.base/share/classes/java/security/cert/X509Certificate.java line 192:

> 190:      * @throws    NullPointerException if the supplied instant is {@code 
> null}.
> 191:      * @throws    IllegalArgumentException if supplied instant is 
> outside the
> 192:      * range supported by Date (e.g., Instant.MAX).

The conversion to `Date` is an implementation detail of the default 
implementation and does not belong to the spec.

In fact, there is no need to fail in this case. We can

* @implSpec
     * The default implementation converts the specified {@code Instant} to
     * a {@code Date} using the {@link Date#from(Instant)} method and calls
     * {@code checkValidity(Date)} on the result. Note that converting to a
     * {@code Date} will cause any excess nanoseconds in the instant to be
     * truncated. If {@code instant} falls outside the range representable by
     * {@code Date}, the nearest {@code Date} is used. For instants too large
     * to be represented as a {@code Date}, {@code new Date(Long.MAX_VALUE)}
     * is used, and for instants too small to be represented as a {@code Date},
     * {@code new Date(Long.MIN_VALUE)} is used.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30047#discussion_r3814709110

Reply via email to