Java VM (ii) the virtual machine initiates operations on the class

Source: Internet
Author: User
Tags object object

Operation of a virtual machine on a class in startup

    1. Virtual machine load Class (ClassLoader), class for processing after the byte code, virtual machine know can do the following things. The process from hard disk to memory
    2. Link
      1. To validate the class, the header of the class is saved in two bytes, and this information, for details, is placed here with a professional documentation link.
      2. Allocate memory for the class, give the corresponding variable postscript the default value int give him a 0 Integer to give him a null ...
      3. Parsing special characters should be similar to spring's parsing of @autowrite, with its own routines, (find a suitable example to put here)
    3. The initialization variable assigns the correct value to the specific heat of the private String name= "Sky Cloud", first doing 2.2, allocating space, giving the default value null here gives him "Sky Cloud".

When does the initialization of a class occur?

The class (interface) is initialized only when it is "actively invoked" by the Java program for the first time.

What a good word!

First ~ ~ ~ Call

So how do I call calling it an active call

    1. When the class is instantiated, Object Object=new object ();
    2. Accesses a static variable of a class or interface, or assigns a value to the static variable object.name=b; (here is the question must be static?) )
    3. Call the static method of the class Object.exit ();
    4. Reflective Class.forName ("com.william.test")
    5. Initializes a subclass of a class. Object a=new String ();
    6. Class (Java Test) that is marked as the startup class when the Java virtual machine is started

The above can prove to write a class but not the active call, then do not have to worry about the logic inside, because the program cannot go anywhere.

Java VM (ii) the virtual machine initiates operations on the class

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.