Java36 lecture notes - talk about your understanding of the Java platform

The first lecture talks about your understanding of the Java platform

Answer

Java itself is an object-oriented language. The most notable features are two aspects. One is that it is very easy to obtain cross-platform capabilities, and the other is GC. Java reclaims and allocates memory through the garbage collector.

JREThat is, the Java runtime environment, including JVMand Java class libraries, as well as some modules.

JDKCan be seen as JREa superset, providing more tools, such 编译器as 各种诊断工具等.

Java is to explain the implementation of this sentence is not very accurate .

Java source code—compiled into bytecode by javac —converts the bytecode into final machine code bytecodeat runtime by an embedded interpreter.JVM

But common ones JVM, such as Oracle JDKprovided ones Hotspot JVM, all provide JIT(Just-In-Time)compilers, that is 动态编译器, they can compile hot code into machine code at runtime. In this case, some hot codes belong 编译执行, not 解释执行.

expand

For the understanding of the Java platform, we can talk about it from many aspects:

  • Java Language Features - Generics, Lambda
  • Basic class libraries - collections, IO/NIO, networking, concurrency, security, etc.
  • JVM basic concepts and mechanisms - Java class loading mechanism, basic principles of garbage collection

Dig deeper into the issue of interpreted execution and compiled execution:

Java is usually divided into compile time and runtime. The compilation of javac, the compilation of Java source code .classis actually in the generated file 字节码, not directly executable 机器码. Java shields the details of the operating system and hardware through the cross-platform abstraction of bytecode and the Java virtual machine . This is 一次编译,到处执行the basis of implementation.

At runtime, the bytecode is loaded JVMthrough the class loader , interpreted or compiled for execution. Class-LoaderWhen the Java virtual machine starts, you can specify different parameters to select the running mode.

For example -Xint- JVM only interprets execution. This mode discards the advantages brought by JIT, because the interpreter is read one by one, and interpreted and executed one by one. For example -Xcomp- the JVM closes the interpreter and does not interpret the execution, which may cause JVMthe startup to be much slower.

In addition to the common Java usage patterns, there are new compilation methods - AOT(Ahead-of-Time-Compilation)directly compiling bytecode into machine code, which avoids the JIToverhead of warm-up and other aspects. Oracle JDKSupport layered compilation and AOT collaborative use.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325807963&siteId=291194637