The Android Developer Challenge is back! Submit your idea before December 2.

BoundaryInterfaceReflectionUtil

public class BoundaryInterfaceReflectionUtil
extends Object

java.lang.Object
   ↳ org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil


A set of utility methods used for calling across the support library boundary.

Summary

Public constructors

BoundaryInterfaceReflectionUtil()

Public methods

static <T> T castToSuppLibClass(Class<T> clazz, InvocationHandler invocationHandler)

Returns an implementation of the boundary interface named clazz, by delegating method calls to the InvocationHandler invocationHandler.

static boolean containsFeature(Collection<String> features, String soughtFeature)

Check whether a set of features contains a certain feature .

static boolean containsFeature(String[] features, String soughtFeature)
static InvocationHandler createInvocationHandlerFor(Object delegate)

Create an InvocationHandler that delegates method calls to , making sure that the Method and parameters being passed to exist in the same ClassLoader as .

static InvocationHandler[] createInvocationHandlersForArray(Object[] delegates)

Plural version of createInvocationHandlerFor(Object).

static Method dupeMethod(Method method, ClassLoader delegateLoader)

Utility method for fetching a method from , with the same signature (package + class + method name + parameters) as a given method defined in another classloader.

static Object getDelegateFromInvocationHandler(InvocationHandler invocationHandler)

Assuming that the given InvocationHandler was created in the current classloader and is an InvocationHandlerWithDelegateGetter, return the object the InvocationHandler delegates its method calls to.

static boolean instanceOfInOwnClassLoader(Object obj, String className)

Check if an object is an instance of className, resolving className in the object's own ClassLoader.

Inherited methods

Public constructors

BoundaryInterfaceReflectionUtil

public BoundaryInterfaceReflectionUtil ()

Public methods

castToSuppLibClass

public static T castToSuppLibClass (Class<T> clazz, 
                InvocationHandler invocationHandler)

Returns an implementation of the boundary interface named clazz, by delegating method calls to the InvocationHandler invocationHandler.

Parameters
clazz Class

invocationHandler InvocationHandler

Returns
T

containsFeature

public static boolean containsFeature (Collection<String> features, 
                String soughtFeature)

Check whether a set of features contains a certain feature .

Returns
boolean

containsFeature

public static boolean containsFeature (String[] features, 
                String soughtFeature)

Parameters
features String

soughtFeature String

Returns
boolean

createInvocationHandlerFor

public static InvocationHandler createInvocationHandlerFor (Object delegate)

Create an InvocationHandler that delegates method calls to , making sure that the Method and parameters being passed to exist in the same ClassLoader as .

Returns
InvocationHandler

createInvocationHandlersForArray

public static InvocationHandler[] createInvocationHandlersForArray (Object[] delegates)

Plural version of createInvocationHandlerFor(Object).

Parameters
delegates Object

Returns
InvocationHandler[]

dupeMethod

public static Method dupeMethod (Method method, 
                ClassLoader delegateLoader)

Utility method for fetching a method from , with the same signature (package + class + method name + parameters) as a given method defined in another classloader.

Parameters
method Method

Returns
Method

Throws
ClassNotFoundException
NoSuchMethodException

getDelegateFromInvocationHandler

public static Object getDelegateFromInvocationHandler (InvocationHandler invocationHandler)

Assuming that the given InvocationHandler was created in the current classloader and is an InvocationHandlerWithDelegateGetter, return the object the InvocationHandler delegates its method calls to.

Parameters
invocationHandler InvocationHandler

Returns
Object

instanceOfInOwnClassLoader

public static boolean instanceOfInOwnClassLoader (Object obj, 
                String className)

Check if an object is an instance of className, resolving className in the object's own ClassLoader. This is useful when obj may have been created in a ClassLoader other than the current one (in which case obj instanceof Foo would fail but instanceOfInOwnClassLoader(obj, "Foo") may succeed).

Parameters
obj Object

className String

Returns
boolean