The key issue is their intrinsic connection. Although you can look at the source code, including the class library. But to abstract them out helps to understand.
In the customer class (that is, the client class for the following code), statement manager managerproxy=
(Manager) Proxy.newproxyinstance (Managerimpl.getclass (). getClassLoader (), Managerimpl.getclass (). GetInterfaces (), Securityhandler);
As you can see, the Newproxyinstance method in the proxy (library Class) is invoked, which returns an instance of the proxy object and then transitions up to its corresponding interface.
The problem is what the method has done before it returns. Let's look at the third of its arguments: Securityhandler, which is an instance of the Invocationhandler interface implementation class: Securityhandler. Because there is an invoke method in the Invocationhandler interface, the implementation class certainly needs to implement this method, that is, its implementation class (This is the Businesshandler Class) has an Invoke method, and if the Invoke method is to be invoked, Can only be invoked through the Businesshandler class object.
In the following source code class Proxy0, there are three places that have already invoked the Invoke method with Businesshandler class objects, respectively, in the codes of these methods: Publicfinalbooleanequals (Objectobj) ; Publicfinalinthashcode (); publicfinalstringtostring (). You may have a question, this method also does not see where to be Proxy0, there are three places have already used Businesshandler class object to invoke Invoke method, they are in the code of these methods respectively: Publicfinal Boolean equals ( Object obj), public final int hashcode (), Public final String toString (). You may have a question, this method also did not see where to be called by the Proxy0 object, how can execute Invoke method? But please look at the Proxy0.