Package org.robolectric.util.reflector
Class Reflector
java.lang.Object
org.robolectric.util.reflector.Reflector
Provides accessor objects for efficiently calling otherwise inaccessible (non-public) methods.
This is orders of magnitude faster than using reflection directly.
For example, to access a private method on some class Foo
, declare an accessor
interface:
class Foo { private String getName() { ... } } @ForType(Foo.class) interface _Foo_ { String getName(); } reflector(_Foo_.class, new Foo()).getName();
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
Returns an object which provides accessors for invoking otherwise inaccessible static methods and fields.static <T> T
Returns an object which provides accessors for invoking otherwise inaccessible methods and fields.
-
Constructor Details
-
Reflector
public Reflector()
-
-
Method Details
-
reflector
Returns an object which provides accessors for invoking otherwise inaccessible static methods and fields.- Parameters:
iClass
- an interface with methods matching private methods on the target
-
reflector
Returns an object which provides accessors for invoking otherwise inaccessible methods and fields.- Parameters:
iClass
- an interface with methods matching private methods on the targettarget
- the target object
-