RFR 6523160: RuntimeMXBean.getUptime() returns negative values
Staffan Larsen
staffan.larsen at oracle.com
Wed Oct 2 02:23:34 PDT 2013
Looks good!
Thanks,
/Staffan
On 2 okt 2013, at 10:47, Jaroslav Bachorik <jaroslav.bachorik at oracle.com> wrote:
> Hello,
>
> currently the JVM uptime reported by the RuntimeMXBean is based on System.currentTimeMillis() which makes it susceptible to changes of the OS time (eg. changing timezone, NTP synchronization etc.). The uptime should not depend on the system time and should be calculated using a monotonic clock source.
>
> There is already the way to get the actual JVM uptime in ticks. It is accessible as Management::timestamp() and the ticks are convertible to milliseconds using Management::ticks_to_ms(ts_ticks) thus making it very easy to switch to the monotonic clock based uptime.
>
> The patch consists of the hotspot and jdk parts.
>
> For the hotspot a new constant needs to be introduced in src/share/vm/services/jmm.h and the actual logic to obtain the uptime in milliseconds is added in src/share/vm/services/management.cpp.
>
> For the jdk the changes comprise of adding the necessary JNI bridging methods in order to get the new uptime, introducing the same constant that is used in hotspot and changes to mapfile-vers files in order to properly build the native library.
>
> Issue: https://bugs.openjdk.java.net/browse/JDK-6523160
> Webrev: http://cr.openjdk.java.net/~jbachorik/6523160/webrev.00
>
> Thanks,
>
> -JB-
More information about the serviceability-dev
mailing list