Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can you find the native code in the JDK?

Tags:

java

I was looking at the Java code for FileInputStream and am interested in what the open and close methods do. These functions, or parts of them, are implemented natively. Do you know where I can find this code? Is this code part of the open source license for the JDK?

like image 642
Fostah Avatar asked Feb 25 '09 18:02

Fostah


People also ask

What is native code in Java?

Native code is computer programming (code) that is compiled to run with a particular processor (such as an Intel x86-class processor) and its set of instructions. If the same program is run on a computer with a different processor, software can be provided so that the computer emulates the original processor.

Where is Java native library?

LIB/MYLIB. LIB is the path that contains the native library you want to load using the System. loadLibrary() call, and myclass is the name of your Java application. For information about how a native library is located by the System.

What is native code in JVM?

The Java Native Interface (JNI) establishes a well-defined and platform-independent interface between the two. Native code can be used together with Java in two distinct ways: as "native methods" in a running JVM and as the code that creates a JVM using the "Invocation API".


3 Answers

http://java.sun.com/j2se/1.5.0/source_license.html
http://download.java.net/jdk6/source/
http://openjdk.java.net/
http://www.gnu.org/software/classpath/

Here is a link to the FileInputStream code... there is also code specific to Windows and presumably other platforms inthe approriate directories.

http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/0a5b87833562/src/share/native/java/io/FileInputStream.c

like image 165
TofuBeer Avatar answered Oct 05 '22 02:10

TofuBeer


OpenJDK should have everything you search for, e.g. the Java 7 mercurial (hg) repository. A zip file with everything from Feb 21th is also available.

If you don't want the brand new developer stuff from Java 7, there is also everything for the well known Java 6.

like image 44
Johannes Weiss Avatar answered Oct 05 '22 02:10

Johannes Weiss


The Sun source is available from java.net.

For FileInputStream, j2se/src/share/native/java/io/FileInputStream.c. If you replace native with windows, solaris or linux there will be platform specific code in those directories. JDK7 has a slightly different structure.

like image 26
Tom Hawtin - tackline Avatar answered Oct 02 '22 02:10

Tom Hawtin - tackline