org.robolectric.internal.bytecode.ShadowImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sandbox Show documentation
Show all versions of sandbox Show documentation
An alternative Android testing framework.
The newest version!
package org.robolectric.internal.bytecode;
import java.lang.reflect.InvocationTargetException;
import org.robolectric.internal.IShadow;
import org.robolectric.util.ReflectionHelpers;
public class ShadowImpl implements IShadow {
private final ProxyMaker proxyMaker = new ProxyMaker(this::directMethodName);
@Override
@SuppressWarnings("TypeParameterUnusedInFormals")
public T extract(Object instance) {
return (T) ((ShadowedObject) instance).$$robo$getData();
}
@Override
public T newInstanceOf(Class clazz) {
return ReflectionHelpers.callConstructor(clazz);
}
@Override
public T newInstance(Class clazz, Class>[] parameterTypes, Object[] params) {
return ReflectionHelpers.callConstructor(
clazz, ReflectionHelpers.ClassParameter.fromComponentLists(parameterTypes, params));
}
/**
* Returns a proxy object that invokes the original $$robo$$-prefixed methods for {@code
* shadowedObject}.
*
* @deprecated This is incompatible with JDK17+. Use a {@link
* org.robolectric.util.reflector.Reflector} interface with {@link
* org.robolectric.util.reflector.Direct}.
*/
@Deprecated
@Override
public T directlyOn(T shadowedObject, Class clazz) {
return createProxy(shadowedObject, clazz);
}
@Override
@SuppressWarnings(value = {"unchecked", "TypeParameterUnusedInFormals"})
public R directlyOn(
Object shadowedObject,
String clazzName,
String methodName,
ReflectionHelpers.ClassParameter>... paramValues) {
try {
Class
© 2015 - 2024 Weber Informatics LLC | Privacy Policy