Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8068730

Increase the precision of the implementation of java.time.Clock.systemUTC()

    Details

    • Subcomponent:
    • Resolved In Build:
      b50
    • Verification:
      Verified

      Backports

        Description

        The java.time.Clock.system() method (and variants thereof) are specified to "obtain a clock that returns the current instant using best available system clock". However the current implementation of the clock returned is based on System.currentTimeMillis() whereas the underlying native clock used by System.currentTimeMillis() has often a greater precision than milliseconds (for instance, on Linux, System.currentTimeMillis() is based on gettimeofday, which offers microseconds precision).

        This RFE propose to enhance the implementation of the system clocks returned by java.time.Clock, so that they offer at least the same precision than the underlying clock available on the system.

          Issue Links

          There are no Sub-Tasks for this issue.

            Activity

            Hide
            dfuchs Daniel Fuchs added a comment - - edited
            Text for release notes:

            Scope: JDK.
            Synopsis: The implementation of the clock returned by system factory methods in java.time.Clock has increased the resolution in JDK 9.

            The Java SE 8 specification for java.time.Clock states that "The system factory methods provide clocks based on the best available
            system clock. This may use System.currentTimeMillis(), or a higher resolution clock if one is available.". In JDK 8 the implementation
            of the clock returned was based on System.currentTimeMillis(), and thus has only a millisecond resolution. In JDK 9, the implementation
            is based on the underlying native clock that System.currentTimeMillis() is using, providing the maximum resolution available from that clock.
            On most systems this can be microseconds, or sometimes even tenth of microseconds.

            An application making the assumption that the clock returned by these system factory methods will always have milliseconds precision
            and actively depends on it, may therefore need to be updated in order to take into account the possibility of a greater resolution, as was
            stated in the API documentation.

            Show
            dfuchs Daniel Fuchs added a comment - - edited Text for release notes: Scope: JDK. Synopsis: The implementation of the clock returned by system factory methods in java.time.Clock has increased the resolution in JDK 9. The Java SE 8 specification for java.time.Clock states that "The system factory methods provide clocks based on the best available system clock. This may use System.currentTimeMillis(), or a higher resolution clock if one is available.". In JDK 8 the implementation of the clock returned was based on System.currentTimeMillis(), and thus has only a millisecond resolution. In JDK 9, the implementation is based on the underlying native clock that System.currentTimeMillis() is using, providing the maximum resolution available from that clock. On most systems this can be microseconds, or sometimes even tenth of microseconds. An application making the assumption that the clock returned by these system factory methods will always have milliseconds precision and actively depends on it, may therefore need to be updated in order to take into account the possibility of a greater resolution, as was stated in the API documentation.
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/hs-rt/jdk/rev/d6a5cbeb8198
            User: dfuchs
            Date: 2015-01-29 03:52:24 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/hs-rt/jdk/rev/d6a5cbeb8198 User: dfuchs Date: 2015-01-29 03:52:24 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/hs-rt/hotspot/rev/fca33371ff0b
            User: dfuchs
            Date: 2015-01-29 03:52:28 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/hs-rt/hotspot/rev/fca33371ff0b User: dfuchs Date: 2015-01-29 03:52:28 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/fca33371ff0b
            User: lana
            Date: 2015-02-11 23:06:13 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/fca33371ff0b User: lana Date: 2015-02-11 23:06:13 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/d6a5cbeb8198
            User: lana
            Date: 2015-02-11 23:06:32 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/d6a5cbeb8198 User: lana Date: 2015-02-11 23:06:32 +0000

              People

              • Assignee:
                dfuchs Daniel Fuchs
                Reporter:
                dfuchs Daniel Fuchs
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: