---
title: "java dynamic proxy class"
author: "standalone"
date: "2009-07-23T21:30:18Z"
tags: []
categories: ["编程语言"]
slug: "java-dynamic-proxy-class"
draft: false
lastmod: "2013-06-04T09:42:52Z"
id: 431894
url: "https://standalone.iteye.com/blog/431894"
---

A *dynamic proxy class* (simply referred to as a *proxy class* below) is a class that implements a list of interfaces specified at runtime when the class is created, with behavior as described below. A *proxy interface* is such an interface that is implemented by a proxy class. A *proxy instance* is an instance of a proxy class. Each proxy instance has an associated *invocation handler* object, which implements the interface [`InvocationHandler`](http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/InvocationHandler.html "interface in java.lang.reflect") . A method invocation on a proxy instance through one of its proxy interfaces will be dispatched to the [`invoke`](http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/InvocationHandler.html#invoke%28java.lang.Object,%20java.lang.reflect.Method,%20java.lang.Object%5B%5D%29) method of the instance's invocation handler, passing the proxy instance, a `java.lang.reflect.Method` object identifying the method that was invoked, and an array of type `Object` containing the arguments. The invocation handler processes the encoded method invocation as appropriate and the result that it returns will be returned as the result of the method invocation on the proxy instance.