public static native long currentTimeMillis()
这是从Java类方法的源代码中提取的注释java.lang.System
。
* Returns the current time in milliseconds. Note that
* while the unit of time of the return value is a millisecond,
* the granularity of the value depends on the underlying
* operating system and may be larger. For example, many
* operating systems measure time in units of tens of
* milliseconds.
从这个评论中很明显,这个本地方法的行为是平台相关的。如果是这种情况,我们是否应该避免在 Java 中编写真正独立于平台的代码的本地方法调用?