I have asked my peers and I have found various different answers, so which has led me to ask here. I apologize if this is a very simple question, but where are the implementation details or built in classes located at in Java? I have heard that the compiler will hold the implementation details of Java. However, I have also heard how the JRE will have the classes or details of the implementation for Java, specifically the rt.jar. I originally thought that the java standard library would have all the details to run java and be able to write java code since it comes with the java.lang package, which carries classes that are fundamental to the design of the Java programming language. Sorry for the confusion, but is there a clear answer to this. Is it possible that multiple of these things hold such info.?
Where are the implementation details or built in classes located at in Java?
The implementation details are... everything. The entire Java JRE or JDK installation is implementation details. You could say... everything in the OpenJDK source tree is implementation details.
The builtin (Java) classes that comprise the Java SE class libraries are in different places depending on the Java version.
For Java 8 and earlier, the compiled classes for the Java SE class libraries are in the "rt.jar" file. Additional classes (for example the JDK tools) are in other JAR files.
For Java 9 and later, the compiled classes are stored in the "jmods" directory. These are no longer JAR files.
Note that "rt.jar" (+ other JARs) and the "jmods" directory are not the complete implementation:
Some Java SE classes have native
methods which are implemented in native (C or C++) code. Classloading, threads and low-level I/O support are examples of this.
Much of the Java runtime implementation does not have any direct relation with any Java classes. For example, the bytecode interpreter, the JIT compiler and the garbage collector, along with the various agent and monitoring hooks are implemented in C / C++ and (typically) part of the main java
executable.
I have heard that the compiler will hold the implementation details of Java.
That is not correct. The compiler has a small amount of built-in knowledge of the signatures for some classes in the java.lang
package. However, in most cases a Java compiler loads ".class" files from "rt.jar" or "jmods" or wherever.
I originally thought that the java standard library would have all the details to run java and be able to write java code since it comes with the
java.lang
package, which carries classes that are fundamental to the design of the Java programming language.
That is certainly not true.
Besides you are conflating lots of things. Firstly, you are conflating design and implementation. They are different things. Really.
Secondly, you are conflating the design of the Java language with the design of the Java runtime system . In reality, the design has many parts:
It is worth noting that the respective specifications are separable to a significant degree:
Finally, as explained above, most of the implementation of the JLS and JVMS is in native code and (to a lesser extent) Java classes that are not formally 1 part of the Java SE class library.
Would it be safe to say that the
java.lang
basically provides the barebones of the java language?
No. See above. The design of the Java language (its syntax and semantics) are in the JLS. The implementation (which maps the design to something that works) comprises the Java bytecode compiler, bytecode interpreter, JIT compiler and so on.
If you really want to understand how this all works, you should start by downloading the OpenJDK source tree. All of the code is in there...
1 - I am talking here about "internal" classes, and classes that (in Java 8 and earlier) were part of "tools.jar". For example, the Java source code for the javac
bytecode compiler.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.