Deprecation of LogRecord.getMillis in JDK9

Daniel Fuchs daniel.fuchs at oracle.com
Wed Dec 2 19:25:05 UTC 2015


On 02/12/15 02:13, Stuart Marks wrote:
> I'd recommend making setInstant() be more explicit about the range of
> Instant values that are allowed, namely those created from
> Instant.ofEpochMilli(long), which allows ± 292 million years from the
> epoch. Otherwise the reader is forced to try to understand when
> Instant.toEpochMilli() throws the exception.

Hi Stuart,

That would not be completely exact - since it excludes all the
Instant values that have a nano second adjustment - and could
give the impression that only instants truncated at milliseconds
resolution are valid.

So I think I prefer to refer to Instant.toEpochMilli() - though
I may try to word the @throws differently:

      * Sets the instant that the event occurred.
      * <p>
      * If the given {@code instant} represents a point on the time-line too
      * far in the future or past to fit in a {@code long} milliseconds and
      * nanoseconds adjustment, then an {@code ArithmeticException} will be
      * thrown.
      *
      * @param instant the instant that the event occurred.
      *
      * @throws NullPointerException if {@code instant} is null.
      * @throws ArithmeticException if numeric overflow would occur while
      *         calling {@link Instant#toEpochMilli() 
instant.toEpochMilli()}.

I will send a RFR on core-libs-dev shortly - so if you have
other suggestion/feedback maybe you could reply on the RFR :-)

best regards,

-- daniel




More information about the core-libs-dev mailing list