java.lang.reflect - Proxy Class


Advertisements


Introduction

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

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

public class Proxy
   extends Object
      implements Serializable

Fields

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

  • 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 −

  • java.lang.Object


Advertisements
E-Books Store