Class.forName and Classloader.loadclass, etc.

Source: Internet
Author: User

class

First, the class class can record information about the properties, methods, and so on for all classes. This is the runtime category tag, which records the class information for all objects (such as int,myclass,void, arrays, and so on ) .

Class Object

The JVM will have corresponding class objects for each object used, either this type of class object is created or a new class object is created .

ClassLoader class

the ClassLoader class is responsible for loading a class. That is, given this class-related name, locate or generate this class-related definition information. ClassLoader Object . LoadClass (" class name ") =classloader object . LoadClass (" class name ", parsing class = False).

The loading process of the class

load ------> Links ( verify ---- Prepare ---- Resolve "JVM replaces symbolic references in constant pools with direct references")------ > Initialize ------> ...

get the Class object

class. forname (" Name of Class" ) =class.forname (" Name of Class ", initialization =true,c Lassloader Object ), after the initialization of the CLass object, which is the execution of a static method in the class

ClassLoader.loadclass( fully qualified name of Class) does not perform initialization

To generate a new class object

The class object that was generated in the previous step executes the . newinstance () method

The initialization method of the class object is automatically executed when the n ew class name () is not initialized

In addition, if the parent class object is not initialized, the initialization method of the parent class class object is executed first when the subclass is called .

Class.forName and Classloader.loadclass, etc.

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.