[9] RFR of 8069269: (spec) Defect in the System.nanoTime spec

Brian Burkhalter brian.burkhalter at oracle.com
Fri Jan 23 20:56:51 UTC 2015


Please review at your convenience:

Issue:	https://bugs.openjdk.java.net/browse/JDK-8069269
Patch:	http://cr.openjdk.java.net/~bpb/8069269/webrev.00/

The effective change is line 391 -> 393; the remainder is reformatting.

Consider these hypothetical nanoTime values:

        long t0 = Long.MAX_VALUE - 41;
        long t1 = t0 + 42;

Ignoring numerical overflow, the second value is mathematically equal to 2^63 which is greater than the first value.

The results of the old and new comparison methodologies applied to the two long values are:

old:

        (t1 - t0) < 0: false
        t1 < t0:         true

new:

        (t0 - t1) < 0: true
        t0 < t1:         false

This exhibits that the old documentation is incorrect regarding the methodology to be used when comparing two nanoTime values in the case of numerical overflow, and that the new documentation is accurate in this case.

Thanks,

Brian


More information about the core-libs-dev mailing list