Android
java.lang.reflect
public class

java.lang.reflect.Proxy

java.lang.Object
java.lang.reflect.Proxy Serializable

This class provides methods to creating dynamic proxy classes and instances.

Summary

Fields

protected      InvocationHandler  h   

Protected Constructors

            Proxy(InvocationHandler h)

Public Methods

      static    InvocationHandler  getInvocationHandler(Object proxy)
Return the proxy instance's invocation handler.
      static    Class<?>  getProxyClass(ClassLoader loader, Class[]<?> interfaces)
Return the dynamically build class for the given interfaces, build a new one when necessary.
      static    boolean  isProxyClass(Class<?> cl)
Return whether the supplied class is a dynamically generated proxy class.
      static    Object  newProxyInstance(ClassLoader loader, Class[]<?> interfaces, InvocationHandler h)
Return an instance of the dynamically build class for the given interfaces that forwards methods to the specified invocation handler.
Methods inherited from class java.lang.Object

Details

Fields

protected InvocationHandler h

Protected Constructors

protected Proxy(InvocationHandler h)

Public Methods

public static InvocationHandler getInvocationHandler(Object proxy)

Return the proxy instance's invocation handler.

Parameters

proxy the proxy instance.

Returns

  • the proxy's invocation handler object

Throws

IllegalArgumentException if the supplied proxy is not a proxy object.

public static Class<?> getProxyClass(ClassLoader loader, Class[]<?> interfaces)

Return the dynamically build class for the given interfaces, build a new one when necessary. The order of the interfaces is important. The interfaces must be visible from the supplied class loader; no duplicates are permitted. All non-public interfaces must be defined in the same package.

Parameters

loader the class loader that will define the proxy class.
interfaces an array of Class objects, each one identifying an interface that the new proxy must implement

Returns

  • a proxy class that implements all of the interfaces referred to in the contents of interfaces.

Throws

IllegalArgumentException
NullPointerException if either interfaces or any of its elements are null.
IllegalArgumentException

public static boolean isProxyClass(Class<?> cl)

Return whether the supplied class is a dynamically generated proxy class.

Parameters

cl the class.

Returns

  • true if the class is a proxy class and false otherwise.

Throws

NullPointerException if the class is null.

public static Object newProxyInstance(ClassLoader loader, Class[]<?> interfaces, InvocationHandler h)

Return an instance of the dynamically build class for the given interfaces that forwards methods to the specified invocation handler. The interfaces must be visible from the supplied class loader; no duplicates are permitted. All non-public interfaces must be defined in the same package.

Parameters

loader the class loader that will define the proxy class.
interfaces the list of interfaces to implement.
h the invocation handler for the forwarded methods.

Returns

  • a new proxy object that delegates to the handler h

Throws

IllegalArgumentException
NullPointerException if the interfaces or any of its elements are null.
IllegalArgumentException
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48