Java Virtual machine: Java architecture

Source: Internet
Author: User

Java Architecture: Java design language, Java class file, Java Api,java virtual machine.

One, Java Virtual machine:

1, the main task of the Java Virtual machine is to load class me and execute the bytecode. A Java Virtual machine contains a class loader that can load class files from programs and APIs.

The JAVA API requires only those classes that are required to be loaded when the program executes. The byte code is executed by the execution engine.

Java Virtual machine: 1, a simple execution engine, is a one-time interpretation of bytecode. 2, the execution engine quickly, consumes memory, in this case, the first executed bytecode will be translated into the Local machine code,

The compiled native machine code is cached and can be reused when the method is called. 3. The third execution engine is an adaptive optimizer. In this method, the virtual machine interprets the byte code at the beginning of the operation, but will monitor the program's

The most frequent code snippets are active and logged. Only the most frequent code snippets are translated into local machine code.

2. When the Java virtual machine is implemented by the software of the operating system on the host, the Java program interacts with the host by invoking the local method. There are two methods in Java, Java methods and local methods. Java methods are compiled into bytecode, stored in class files, and local methods are written in other languages and compiled into processor-related machine code. Local methods are saved in the dynamic-link library, and the format is available on each platform. When a running Java program calls the local method, the virtual machine loads the dynamic library containing the local method and calls the method. With local methods, Java programs can directly access the underlying operating system's resources. The Java Local interface (JNI) enables local methods to run on any one of the Java platform implementations of a particular host system. However, the Java platform vendor does not necessarily have to support JNI.

Ii. the architecture of Class loaders

1. There are two types of class loaders: The loader that initiates the class loader and the user-defined class. The Startup class loader is part of the Java Virtual Machine implementation. The startup class loader typically uses some sort of default way to load classes from a local disk, including Java API classes. The Startup class loader is also known as the original class mount, the System class loader, or the default loader.
Java applications can install user-defined class loaders at run time, which can be used to load classes in a custom manner.

2. When each class is loaded, the Java Virtual machine monitors the class to see if it is loaded by the class loader or by the user-defined class loader. When the loaded class references another class, the virtual machine uses the class loader that loads the first class--to load the referenced class. For example, a virtual opportunity uses a particular class loader to load the volcano class, which also uses this class loader to load all classes referenced in the Volcano class.

3. Because the Java virtual machine is loading classes in this way as described in 2, the loaded class can see only the classes that are loaded by the same class loader by default. In this way, the architecture of Java allows multiple namespaces to be built in a Java application, and every class loader in the runtime's Java program has its own namespace.

4. A Java application can instantiate multiple user-defined class loaders from the same class or from multiple classes . The classes loaded by different class loaders are stored in different namespaces and cannot be accessed by each other unless the application shows that they are allowed to do so. In this way, malicious code can be prevented from gaining access to and destroying good-natured code.

Third, Java class file

Java class files make Java more adaptable to the web, primarily in terms of platform independence and network mobility. The task in terms of platform independence is to provide Java programs with a binary form of service independent of the underlying host platform. In addition to platform-agnostic design, the Java class file design is compact and can be quickly transmitted over the network. The Java program is dynamically linked and dynamically extended, and the class file is downloaded when needed.

Iv. Java API

The Java API is a set of runtime libraries that provide a standard way to access the resources of a confidant system. The class file on the Java API is inherently closely related to the host platform. Before a platform can support Java programs, the functionality of the API must be specifically implemented on this platform. To access local resources on the host, the Java API calls the local method. The Java API provides a Java program for the underlying host with a standard interface that is platform agnostic.

V. Java programming language

Object-oriented, multi-threading, structured error handling, garbage collection, dynamic linking, and dynamic scaling.

Java Virtual machine: Java architecture

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.