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

Inappropriate uses of os::javaTimeMillis()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 14
    • Fix Version/s: 15
    • Component/s: hotspot
    • Subcomponent:
    • Resolved In Build:
      b08

      Description

      There are various places that use os::javaTimeMillis() to calculate durations which are used for various purposes. It looks like a convenient way to get the current time in milliseconds. Unfortunately, it is (by definition) subject to external clock adjustment, making it unsuitable for most such duration calculations. (Indeed, there are several comments about it not being used because it doesn't guarantee monotonicity.) It should probably (almost) never be used for such interval calculations. Some of the current uses may be actual lurking bugs, where some timeout may either expire too early or possibly really, really late (for example, if an interval is negative because of clock adjustment).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dholmes David Holmes
              Reporter:
              kbarrett Kim Barrett
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: