What the Java dynamic agent is based on (not finished)

Source: Internet
Author: User

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)

Related Article

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.