1> the reflection mechanism of Java is seldom used in the normal business development process, but it is widely used in the construction of some basic framework.
2> What is the Java reflection mechanism
The Java reflection mechanism is in the running state, for any class, can know all the properties and methods of this class, for any object, can invoke its arbitrary methods and properties; This dynamic acquisition of information and the ability to dynamically invoke object methods is called the reflection mechanism of the Java language.
What features are provided by the 3> reflection mechanism
----Determine the class to which any object belongs at run time
To construct an object of any class at run time----
----Determine the member variables and methods that any one class has at run time
----method of invoking any object at run time
----Generating dynamic agents
Application scenario of 4> reflection mechanism
----reverse code, such as anti-compilation
----framework that is combined with annotations, such as retrofit
----Simple reflection mechanism application framework, e.g. Eventbus 2.x
----dynamically generated class frameworks such as Gson
Advantages and disadvantages of 5> reflection mechanism:
----Advantages: Run-time type judgment, dynamic class loading, dynamic proxy use reflection
----Cons: Performance is a problem, and reflection is the equivalent of a series of explanatory actions that inform the JVM what to do, and performance is much slower than the direct Java code.
. The main function of Java is to get the internal structure of the program at runtime, including its construction method, the declared domain and the defined method, etc.
2JAVA comes with a dynamic agent based on the Java.lang.reflect.Proxy, Java.lang.reflect.InvocationHandler two classes, using the Java reflection mechanism, typically use the following method to create a proxy object: Object proxy = Proxy.newproxyinstance (the class loader that defines the proxy object, an array of attribution interfaces for the target object to be proxied, callback interface Invocationhandler)
See more: http://blog.sina.com.cn/s/blog_548c8a8301013j6u.html
Https://www.cnblogs.com/gshacnblogs/p/7159489.html
What the Java dynamic agent is based on (not finished)