可能重複:
Where to find source code for java.lang native methods?我在哪裏可以找到Java本機方法實現?
我在哪裏可以找到JDK 1.6的Windows平臺的Java的本機方法實現?
可能重複:
Where to find source code for java.lang native methods?我在哪裏可以找到Java本機方法實現?
我在哪裏可以找到JDK 1.6的Windows平臺的Java的本機方法實現?
下面是谷歌Dalvik VM如何實現它,我無法想象的Windows或任何其他版本有很大的不同。
241 /*
242 * static long currentTimeMillis()
243 *
244 * Current time, in miliseconds. This doesn't need to be internal to the
245 * VM, but we're already handling java.lang.System here.
246 */
247 static void Dalvik_java_lang_System_currentTimeMillis(const u4* args,
248 JValue* pResult)
249 {
250 struct timeval tv;
251
252 UNUSED_PARAMETER(args);
253
254 gettimeofday(&tv, (struct timezone *) NULL);
255 long long when = tv.tv_sec * 1000LL + tv.tv_usec/1000;
256
257 RETURN_LONG(when);
258 }
這取決於其虛擬機所使用。太陽/甲骨文的JDK的源可以在這裏找到:
http://stackoverflow.com/questions/2292629/where-to-find-source-code-for-java -lang-native-methods – pholser