Java class loader memo

Source: Internet
Author: User

<! -- [If gte mso 9]> <! [Endif] --> <! -- [If gte mso 9]> <! [Endif] --> <! -- [If gte mso 10]>

<! [Endif] -->

Class Loader

The custom ClassLoader must inherit the ClassLoader class and override the findClass method of the parent class. Because the loadClass method contains the delegate mechanism of the Class Loader, we still retain the loadClass method of the parent class, then, use defineClass to load the class file to the memory through the byte stream. because of the delegate mechanism, we need to put the class file to be loaded under the directory we specified, so that when the parent class loader cannot find the file to be loaded, there will be our custom class loaders for loading.

When a class is loaded by the parent class of its loader class, the parent loader also loads all classes associated with the class. Otherwise, an error occurs. because when class A references Class B, Class B is loaded by the class loader of Class, therefore, Class A cannot be loaded if Class B is not found when the class loader loads Class.

Example of myServlet

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.