The Class.forName and ClassLoader of Java notes

Source: Internet
Author: User

The class object returned by Class.forName can decide whether to initialize. The type returned by Classloader.loadclass is never initialized, and only the connection operation is done.
Class.forName can decide which classloader to request this type. And Classloader.loadclass is using the current ClassLoader to request.

The JDBC Registration driver basically uses class.forname.

public static class<?> forname (String name, Boolean Initialize,classloader loader) throws classnotfoundexception;
public static class<?> forname (String className) throws ClassNotFoundException;
Note: Initialize: If True, the type is connected, validated, and initialized before the class object is returned. (for example, execute code in a static block)
Loader: Use a custom class loader to request this type; Of course, you can also pass in null, using the bootstrap loader.

Protected synchronized class<?> loadclass (String name, Boolean resolve) throws ClassNotFoundException;
Public class<?> loadclass (String name) throws ClassNotFoundException;

Note: Resolve: Indicates whether the type needs to be connected, including a checksum class file, ready to allocate memory, type constant pool substitution, but not initialize the type.

The Class.forName and ClassLoader of Java notes

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.