Deep Dive into Java Virtual Machine

Source: Internet
Author: User
(1) In the following situations, the Java Virtual Machine ends its lifecycle-the system is executed. exit () method-end of normal program execution-an exception or error occurred while executing the program, causing termination of the Java VM process due to an error in the operating system (2) There are two types of classloaders -The built-in loader of the Java Virtual Machine
  • Root loader (bootstrap)
  • Extension)
  • System loader)
-User-defined class loader
  • Subclass of Java. Lang. classloader
  • You can customize the Loading Method of classes.
(3) The Class Loader does not need to load a class when it is "used for the first time". The JVM specification allows the class loader to load a class before it is expected to be used, if you encounter this problem during the pre-loading process. if the class file is missing or has an error, the Class Loader must report the error (linkageerror) only when the program takes the initiative to use the class for the first time, the Class Loader does not report errors. After the class is loaded, it enters the link stage, the link is to merge the binary data of the classes that have been read into the memory into the runtime environment of the virtual machine. (4) When a Java Virtual Machine initializes a class, it requires that all its parent classes have been initialized, but this rule does not apply to interfaces. When initializing a class, you do not need to initialize the interface it implements first; When initializing an interface, it does not initialize its parent interface first; therefore, a parent interface will not be initialized because of its sub-interface or implementation class initialization. Initialization of a specific interface is successful only when the program uses static variables of a specific interface for the first time. The handler calls the loadclass method of the classloader class to load a class. Instead of actively using the class, it will not cause class initialization. All user-defined class loaders should inherit the classloader class. Classes loaded by the same class loader belong to the same package constitute a runtime package. Determine whether the two classes belong to the same runtime package. It depends not only on whether their package names are the same, but also on whether the class loaders are the same. (Defines the class loader that actually loads the class.) The namespace of the ⑹ sub-loader contains the namespace of all parent loaders. Therefore, the class loaded by the sub-loader can see the class loaded by the parent loader. The class loaded by the parent class loader cannot see the class loaded by the subclass loader. If there is no direct or indirect parent-child relationship between the two loaders, their loaded classes are invisible to each other.

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.