13

At first I want to let you know that this question is not related with What is native implementation in Java. I got many useful information from that thread.

I want to know that are the codes of the native implementations available? I have jdk source code but I can not find the native codes for System.currentTimeMillis or Runtime.getRuntime().availableProcessors() or other native method.

River
  • 8,585
  • 14
  • 54
  • 67
Tapas Bose
  • 28,796
  • 74
  • 215
  • 331

2 Answers2

12

Yes, see os::javaTimeMillis in /src/os/solaris/vm/os_solaris.cpp to see the Solaris implementation for instance.

There are a few layers of wrappers to get there though, see JVM_CurrentTimeMillis in /src/share/vm/prims/jvm.cpp

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Henrik Gustafsson
  • 51,180
  • 9
  • 47
  • 60
2

Because the underlying methods are intrinsic to the OS you are running Java on, you will not find their source code in the JDK documentation. I suppose you'd need to find out exactly which procedures are called on your platform, and if source code is available for those (which strongly depends on your OS).

Michael
  • 204
  • 2
  • 10