Javareflect 简明教程

java.lang.reflect - Proxy Class

Introduction

java.lang.reflect.Proxy 类提供用于创建动态代理类和实例的静态方法,它也是由此方法创建的所有动态代理类的超类。

The java.lang.reflect.Proxy class provides static methods for creating dynamic proxy classes and instances, and it is also the superclass of all dynamic proxy classes created by those methods.

Class declaration

以下是对 java.lang.reflect.Proxy 类的声明 −

Following is the declaration for java.lang.reflect.Proxy class −

public class Proxy
   extends Object
      implements Serializable

Fields

以下是对 java.lang.reflect.Proxy 类的字段 −

Following are the fields for java.lang.reflect.Proxy class −

  1. protected InvocationHandler h − the invocation handler for this proxy instance.

Constructors

Sr.No.

Constructor & Description

1

*protected Proxy(InvocationHandler h)*Constructs a new Proxy instance from a subclass (typically, a dynamic proxy class) with the specified value for its invocation handler.

Class methods

Sr.No.

Method & Description

1

static InvocationHandler getInvocationHandler(Object proxy)Returns the invocation handler for the specified proxy instance.

2

static Class<?> getProxyClass(ClassLoader loader, Class<?>…​ interfaces)Returns the java.lang.Class object for a proxy class given a class loader and an array of interfaces.

3

static boolean isProxyClass(Class<?> cl)Returns true if and only if the specified class was dynamically generated to be a proxy class using the getProxyClass method or the newProxyInstance method.

4

static Object newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h)Returns an instance of a proxy class for the specified interfaces that dispatches method invocations to the specified invocation handler.

Methods inherited

此类从以下类中继承方法:

This class inherits methods from the following classes −

  1. java.lang.Object