I have spent some time learning what are Java Native methods and that they are implemented in platform dependent code(mostly C).
But where can I find those native implementations of Java? eg : sleep(long millis) method of Thread class is native. But where is its implementation code???
The native code is implemented within the JVM (Java Virtual Machine). The Java developer isn't supposed to worry about their implementation as they relate to the inner working of the virtual machine. However, you can write your own native methods using JNI or see how they are implemented for a specific JVM.
But where can I find those native implementations of Java?
You'll have to download the complete source of some JDK. In OpenJDK for instance, you'll find lots of files related to threads:
./jdk/src/share/native/java/lang/Thread.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With