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.

3
  • 2
    You can download the source for the entire OpenJDK and have it open as another project if you have the memory (At least I do. ;) Commented Jun 28, 2011 at 9:20
  • 1
    @Peter Lawrey are you referring download.java.net/openjdk/jdk6 ? Commented Jun 28, 2011 at 9:26
  • 2
    Yes the bundle is 4 months old and you can also download the latest from source control but its unlikely to matter. Commented Jun 28, 2011 at 9:38

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.