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 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 |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
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 |
containsFeature
public static boolean containsFeature (Collection<String> features,
String soughtFeature)
Check whether a set of features contains a certain feature .
containsFeature
public static boolean containsFeature (String[] features,
String soughtFeature)
Parameters |
features |
String |
soughtFeature |
String |
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.
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 |
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 |