-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b117
-
x86
-
windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8028901 | port-stage-ppc-aix | Jaroslav Bachorík | P3 | Resolved | Fixed | master |
FULL PRODUCT VERSION :
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Build 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
RuntimeMXBean.getUptime() incorrectly calculates uptime of JVM. The method assumes that uptime equals to (current_time - JVM_start_start). It's wrong because system time can be changed by some external process. Of couse, uptime (due to its semantics) cannot be less than 0. RuntimeMXBean.getUptime() should use OS timers to get elapsed time of JVM process.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run the attached sample
2. Change system time (for example with help of standard Windows utility) - one day before today
3. Take a look at program's output.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I should see growing sequence of non negative values
ACTUAL -
Something like this:
uptime = 3084
uptime = 3585
uptime = 4086
uptime = 4587
uptime = -604795913
uptime = -604795412
uptime = -604794912
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
/**
* @author Vladimir Kondratyev
*/
public class test {
public static void main(String[] args) throws Exception{
final Thread thread = new Thread(){
public void run() {
while (true) {
final RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
final long uptime = runtimeMXBean.getUptime();
System.out.println("uptime = " + uptime);
try {
Thread.sleep(500);
}
catch (final InterruptedException ignored) { }
}
}
};
thread.run();
}
}
---------- END SOURCE ----------
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Build 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
RuntimeMXBean.getUptime() incorrectly calculates uptime of JVM. The method assumes that uptime equals to (current_time - JVM_start_start). It's wrong because system time can be changed by some external process. Of couse, uptime (due to its semantics) cannot be less than 0. RuntimeMXBean.getUptime() should use OS timers to get elapsed time of JVM process.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run the attached sample
2. Change system time (for example with help of standard Windows utility) - one day before today
3. Take a look at program's output.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I should see growing sequence of non negative values
ACTUAL -
Something like this:
uptime = 3084
uptime = 3585
uptime = 4086
uptime = 4587
uptime = -604795913
uptime = -604795412
uptime = -604794912
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
/**
* @author Vladimir Kondratyev
*/
public class test {
public static void main(String[] args) throws Exception{
final Thread thread = new Thread(){
public void run() {
while (true) {
final RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
final long uptime = runtimeMXBean.getUptime();
System.out.println("uptime = " + uptime);
try {
Thread.sleep(500);
}
catch (final InterruptedException ignored) { }
}
}
};
thread.run();
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8028901 RuntimeMXBean.getUptime() returns negative values
- Resolved
- relates to
-
JDK-6526682 JConsole shows negative CPU Usage
- Resolved