Four core concepts in java

Source: Internet
Author: User

 

Java has become a huge and complex technology platform. for developers, it is essential to have a better grasp of Java technology and have a deep understanding of the underlying technical processing details. Here we will introduce four core concepts of java:

1. Java Virtual Machine

The main task of the Java Virtual Machine is to install the class file and execute the bytecode. The Java Virtual Machine contains a class loader that can load class files from programs and APIs. In Java APIs, only the classes required for program execution are loaded. Bytecode is executed by the execution engine. Different Java virtual machines may implement different execution engines. In virtual machines implemented by software, the simplest execution engine is to interpret bytecode at one time.

Another execution engine is faster, but also consumes more memory, called "instant compiler (just-in-time compiler )". In this case, the bytecode that is executed for the first time will be compiled by the local machine code. The locally compiled machine code is cached and can be reused when the method is called later.

The third type of execution engine is the adaptive optimizer. In this method, the virtual machine starts to interpret bytecode, But it monitors the activity of running programs and records the most frequently used code segments. When the program is running, the virtual machine only compiles the Code with the most frequent activities at the cost. Other codes are retained as bytecode because they are not frequently used. The virtual machine will continue to explain them.

An adaptive optimizer allows the Java Virtual Machine ~ Execute optimized local code in 90% of the time, and only need to compile 10% ~ 20% of the Code that has an impact on performance.

2. architecture of the Class Loader

A Java application can use two types of loaders: the "bootstrap" Class Loader and the user-defined class loader. Starting the Class Loader (which is the only one in the system) is part of the implementation of the Java Virtual Machine. The start class loader usually loads classes from the local disk in some default mode, including Java API classes (the startup class loader is also called the original Class Loader, system class loader, or default Class Loader ).

Java applications can install user-defined class loaders at runtime, which can be loaded in a custom manner. For example, download the class file from the network. Although the start class loader is the essential part of Virtual Machine implementation, and the user-defined class loader is not, the user-defined class loader can be written in Java, it can be compiled into class files, loaded by virtual machines, and instantiated like other objects.

3. Java class file

Java class files make Java more suitable for the network in terms of platform independence and Network Mobility. In terms of platform independence, it provides binary services independent of the underlying host platform for Java programs. This approach breaks the tradition of C, C ++, and other languages. programs written in these traditional languages are usually compiled first, then it is connected to a separate binary file dedicated to supporting specific hardware platforms and operating systems.

Generally, binary executable files on one platform cannot work on other platforms. Java class files can run binary files on any hardware platform and operating system that supports Java virtual machines.

4. Java API

By supporting platform independence and security, Java APIs adapt Java to network applications. Java API is a collection of runtime libraries. It provides a set of standard methods for accessing host system resources. The Java API class file used by the class file of the virtual machine to load the program when running the Java program. All mounted class files (including extracted from applications and Java APIs) and all loaded dynamic libraries (including local methods) together, the entire program runs on the Java Virtual Machine.

I hope this article will help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.