The following illustration shows the normal loading process of a class, the principle of reflection, and the class object:Ĭlass objects have always been. To the structure of the class, so our image is called reflection. This object is like a mirror through which you can see You can see the structure of the class through this object. After loading the class, a Class-type object (one) is generated in the method area of heap memoryĬlass has only one Class object, which contains the complete class structure information.Use the Reflection API to get the internal information of any class and directly manipulate the inside of any object Reflection is the key to what is considered a dynamic language, and the reflection mechanism allows the program to run at execution time.Reflection allows you to dynamically create objects and invoke their properties at runtime without having to know who the running object is at compile time in advance. While the program may need to load some classes dynamically at run time, they are not loaded into JVM because they were not used before. ![]() ![]() The type of object in the program is determined at compile time. (2) Java belongs to the language that compiles and runs first. Essentially, after the JVM gets the class object, it decompiles it to get all kinds of information about the object. (1) The core of Java reflection mechanism is to dynamically load classes and obtain detailed information about them while the program is running, thereby manipulating the properties and methods of classes or objects. Overview of Java Reflection Mechanism What is reflection:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |