The Java Reflection mechanism provides the following functions: To determine the class to which any object belongs at run time, to construct an object of any class at run time, to determine the member variables and methods that any class has at run time, to invoke a method of any object at run time, and to generate a dynamic proxy.
Sometimes we say that a language is highly dynamic, and sometimes we distinguish between dynamic and static techniques and practices. We have catchy dynamic bindings, dynamic linking, dynamic loading, and so on. However, the term "dynamic" is not strictly and universally applicable strict definition, and sometimes even like object-oriented in the beginning of the field of programming, one person a number, each blowing the tune.
In general, the developer community speaks of dynamic language, which is broadly agreed to as a definition: "When a program is run, it is allowed to change the program structure or variable type, which is called Dynamic language." From this point of view, Perl,python,ruby is a dynamic language, and c++,java,c# is not a dynamic language.
Although Java is not a dynamic language under such definitions and classifications, it has a very prominent dynamic correlation mechanism: Reflection. This word means "reflection, image, reflection," which is used in Java to refer to the classes that we can load, detect, and use completely unknown during compilation. In other words, a Java program can load a runtime to know the name of a class, learn its full construct (but not including the methods definition), and generate its object entities, or set values on its fields, or evoke its methods. This ability to "See Through Class" (the ability of the program to examine itself) is called introspection (introspection, vipassana, introspection). Reflection and introspection are the two terms that are often and are mentioned.
How can Java make the dynamic features described above? This is a far-reaching topic, and this article simply introduces some concepts. The whole space is mostly about reflection APIs, which is to let the reader know how to explore the structure of class, how to create a copy of an entity for a "class that knows the name at runtime", set a value for its fields, and call its methods. This article will talk about Java.lang.Class, as well as Java.lang.reflect in the method, Field, constructor and so on classes.
Java Reflection mechanism