System.nanoTime()
returns different values when the same code is compiled and run against java 7 and java 8.
This piece of code:
public class nanoTime
{
public static void main(String... args)
{
System.out.println("Found JVM: "
+ " " + System.getProperty("java.vm.vendor")
+ " " + System.getProperty("java.version")
+ " " + System.getProperty("java.vm.name")
);
System.out.println("time is "+ System.nanoTime());
}
}
prints this on java 7
~ gdate +%s%N && javac7-oraclejdk nanoTime.java && java7-oraclejdk nanoTime
1480143769271605000
Found JVM: Oracle Corporation 1.7.0_80 Java HotSpot(TM) 64-Bit Server VM
time is 1480143769807547000
and this on java 8
~ gdate +%s%N && javac nanoTime.java && java nanoTime
1480143724152650000
Found JVM: Oracle Corporation 1.8.0_92 Java HotSpot(TM) 64-Bit Server VM
time is 527819867675375
Why and how does this happen?
The runtime environment is mac Sierra.