The question of dynamic proxies: what does the new operation do in the compile phase of the program __JVM

Source: Internet
Author: User
Tags reflection


OK, let's review the previous blog. Java Proxy mode and case study: Static agent/Dynamic Agent: 1, what is the proxy mode.
In 2,java, the difference between static agent and dynamic agent.
3,spring uses either the dynamic proxy for JDK or the cglib dynamic proxy.
The implementation principle of 4,JDK dynamic agent.
What is the difference between the dynamic proxy of 5,JDK and the implementation of Cglib dynamic Proxy.
6, you know, there are other dynamic agent technology. Please outline the implementation principle.

The previous blog post did not answer all the questions raised above. Like what:
3,spring uses either the dynamic proxy for JDK or the cglib dynamic proxy.
6, you know, there are other dynamic agent technology. Please outline the implementation principle.

Spring's dynamic proxy, which integrates the JDK's dynamic proxies and Cglib's dynamic proxies. You can switch between 2 people. This is the online statement, the specific situation
remains to be studied.

And, today, I sorted out my thoughts and found that this problem can be explored in a more in-depth way in the past. Before I explore, I have a personal understanding
To say, I understand static proxies with dynamic proxies. The key difference between static agent and dynamic agent lies in "static" and "dynamic". In Java, we
This concept is often mentioned. In fact, in the Java domain, static is the new keyword to generate objects, dynamic is the use of Java reflection mechanism to
Build the object. Or essentially, what is the difference between a new object and a reflection-generated object? Students who have studied the JVM should know that the new object is
The dependencies between objects are established during the compilation phase of the program, and reflection generation objects are dependencies before the object is established at the runtime stage of the program. Other words
The essential difference between a new object and a reflection-generated object is that the timing of object dependency is different.

So, I'm going to ask:
1, why the new object builds dependencies between objects during the compile phase of the program.
2, in the program's compile phase, what the new operation has done.
3,JDK Dynamic Agent, proxy.newinstance (), we need to pass three parameters:
* Target.getclass (). getClassLoader () class loader for target objects
* Target.getclass (). GetInterface () interface to the class implementation of the target object
* This is the current class object (that is, the object of the dynamic proxy class that you implemented)
Here's the problem: what class loader is the class loader for the target object: Bootstrap classloader,extended Classloader,
Application Classloader. Also, the dynamic proxy load class eventually invokes the Class.forName () method, which can load
Bytecode files, which are compiled Java files. So, Class.forName () method, can you load Java source files? If not,
So, what about the new keyword, can you load the Java source file with the New keyword?

To answer these questions, you need knowledge of the JVM, and although I have learned the knowledge of the JVM, let me answer the questions clearly,
Still very reluctant, so need to cultivate a paragraph, with these questions, and then to learn the knowledge of the JVM. Mark this blog post, the recent project Also
Very busy, afraid to forget, so first sorted out, mark, have time to continue to study.

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.