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

Inappropriate uses of os::javaTimeMillis()

XMLWordPrintable

    • b08

      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).

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

              Created:
              Updated:
              Resolved: