RFR 8144262: LogRecord.getMillis() method is a convenience API that should not have been deprecated

Lance Andersen lance.andersen at oracle.com
Wed Dec 2 20:33:49 UTC 2015


+1
On Dec 2, 2015, at 3:10 PM, Daniel Fuchs <daniel.fuchs at oracle.com> wrote:

> Hi,
> 
> Please find below a fix for
> 8144262: LogRecord.getMillis() method is a convenience API that
>         should not have been deprecated
> https://bugs.openjdk.java.net/browse/JDK-8144262
> 
> 
> webrev:
> http://cr.openjdk.java.net/~dfuchs/webrev_8144262/webrev.00
> 
> specdiff:
> http://cr.openjdk.java.net/~dfuchs/webrev_8144262/specdiff-logging/java/util/logging/LogRecord.html
> 
> 
> When 8072645:java.util.logging should use java.time to get more
>     precise time stamps
> was implemented we decided to deprecate LogRecord.getMillis()
> and LogRecord.setMillis() in favor of the new LogRecord.getInstant()
> and LogRecord.setInstant().
> 
> This may have been a bit hasty as LogRecord.getMillis() can in fact
> be seen as a convenience method - a shortcut to
> LogRecord.getInstant().toEpochMillis().
> The only method we really wanted to deprecate was LogRecord.setMillis()
> as that would truncate the instant to milliseconds:
> in other words, LogRecord.setMillis(LogRecord.getMillis()) was no longer
> idempotent.
> 
> This changes proposes to restore LogRecord.getMillis() to its previous
> status, and also fixes LogRecord.setInstant to reject instant values
> which would not fit in a long milliseconds-since-epoch - which would
> have caused serialization to fail and LogRecord.getMillis() to throw
> an undocumented ArithmeticException.
> 
> Rationale about this proposed change have also been discussed in this
> thread:
> http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-November/037039.html
> 
> best regards,
> 
> -- daniel
> 



Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering 
1 Network Drive 
Burlington, MA 01803
Lance.Andersen at oracle.com






More information about the core-libs-dev mailing list