Java Reflection Comprehension

Source: Internet
Author: User

1. The meaning of reflection is to load the external class into the virtual machine

2. Once a class is loaded into the JVM, initialization of the class is performed. such as static loading

3. The first step to run a program when class loads

4.java HelloWorld

command, the JVM loads the Helloworld.class into memory and forms a class object helloworld.class. 5. The class load, which is loaded by the ClassLoader. The JVM loads classes through the class loader. 6. Class loading complete regrets generating a class object in memory 7.1, when running a program, is always loaded by Appclass Loader (System ClassLoader) to start loading the specified class. 2. When the class is loaded, each classloader will hand the load task to its parent, if the parent cannot find it, and then load it by itself.
3, Bootstrap Loader (startup class loader) is the top class loader, and its parent loader is null. 9. If the class does not load, it will report ClassNotFound exception Ah, this is a typical IO exception ah 10. Your program can load classes or interfaces that are not known or exist at compile time, and dynamically connect them and perform selective parsing. 8.public class HelloWorld {
public static void Main (string[] args) {
HelloWorld Hello = new HelloWorld ();
Class C = Hello.getclass ();
ClassLoader loader = C.getclassloader ();
SYSTEM.OUT.PRINTLN (loader);
System.out.println (Loader.getparent ());
System.out.println (Loader.getparent (). GetParent ());
}
When the program runs, the class must be loaded. Loading a class is the first step in a program's run. Since the class has already been loaded, there must be class object 9 in memory. How do I dynamically load a class into the JVM? A: Class load class loading There are three ways: 1, the command line starts the application by the JVM initialization load 2, through the Class.forName () method dynamic loading 3, through the Classloader.loadclass () method dynamic loading

Java Reflection Comprehension

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.