Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

BoundaryInterfaceReflectionUtil

open class BoundaryInterfaceReflectionUtil
kotlin.Any
   ↳ org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil

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

Summary

Public constructors

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

Public methods

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

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

open static Boolean
containsFeature(features: MutableCollection<String!>!, soughtFeature: String!)

Check whether a set of features {@param features} contains a certain feature {@param * soughtFeature}.

open static Boolean
containsFeature(features: Array<String!>!, soughtFeature: String!)

open static InvocationHandler!

Create an java.lang.reflect.InvocationHandler that delegates method calls to {@param delegate}, making sure that the java.lang.reflect.Method and parameters being passed to {@param delegate} exist in the same java.lang.ClassLoader as {@param * delegate}.

open static Array<InvocationHandler!>!

Plural version of createInvocationHandlerFor(Object).

open static Method!
dupeMethod(method: Method!, delegateLoader: ClassLoader!)

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

open static Any!

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.

open static Boolean
instanceOfInOwnClassLoader(obj: Any!, className: String!)

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

Public constructors

<init>

BoundaryInterfaceReflectionUtil()

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

Public methods

castToSuppLibClass

open static fun <T : Any!> castToSuppLibClass(clazz: Class<T>!, invocationHandler: InvocationHandler!): T

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

containsFeature

open static fun containsFeature(features: MutableCollection<String!>!, soughtFeature: String!): Boolean

Check whether a set of features {@param features} contains a certain feature {@param * soughtFeature}.

containsFeature

open static fun containsFeature(features: Array<String!>!, soughtFeature: String!): Boolean

createInvocationHandlerFor

open static fun createInvocationHandlerFor(delegate: Any!): InvocationHandler!

Create an java.lang.reflect.InvocationHandler that delegates method calls to {@param delegate}, making sure that the java.lang.reflect.Method and parameters being passed to {@param delegate} exist in the same java.lang.ClassLoader as {@param * delegate}.

createInvocationHandlersForArray

open static fun createInvocationHandlersForArray(delegates: Array<Any!>!): Array<InvocationHandler!>!

Plural version of createInvocationHandlerFor(Object).

dupeMethod

open static fun dupeMethod(method: Method!, delegateLoader: ClassLoader!): Method!

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

getDelegateFromInvocationHandler

open static fun getDelegateFromInvocationHandler(invocationHandler: InvocationHandler!): Any!

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.

instanceOfInOwnClassLoader

open static fun instanceOfInOwnClassLoader(obj: Any!, className: String!): Boolean

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).