• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.robolectric.internal.bytecode;
2 
3 import java.lang.invoke.MethodHandle;
4 import java.lang.invoke.MethodType;
5 import org.robolectric.util.ReflectionHelpers;
6 
7 public class RobolectricInternals {
8 
9   @SuppressWarnings("UnusedDeclaration")
10   private static ClassHandler classHandler; // initialized via magic by SdkEnvironment
11 
12   @SuppressWarnings("UnusedDeclaration")
13   private static ShadowInvalidator shadowInvalidator;
14 
15   @SuppressWarnings("UnusedDeclaration")
16   private static ClassLoader classLoader;
17 
18   @SuppressWarnings("UnusedDeclaration")
classInitializing(Class clazz)19   public static void classInitializing(Class clazz) throws Exception {
20     classHandler.classInitializing(clazz);
21   }
22 
23   @SuppressWarnings("UnusedDeclaration")
initializing(Object instance)24   public static Object initializing(Object instance) throws Exception {
25     return classHandler.initializing(instance);
26   }
27 
28   @SuppressWarnings("UnusedDeclaration")
methodInvoked(String signature, boolean isStatic, Class<?> theClass)29   public static ClassHandler.Plan methodInvoked(String signature, boolean isStatic, Class<?> theClass) {
30     return classHandler.methodInvoked(signature, isStatic, theClass);
31   }
32 
getShadowCreator(Class<?> caller)33   public static MethodHandle getShadowCreator(Class<?> caller) {
34     return classHandler.getShadowCreator(caller);
35   }
36 
findShadowMethodHandle(Class<?> theClass, String name, MethodType methodType, boolean isStatic)37   public static MethodHandle findShadowMethodHandle(Class<?> theClass, String name,
38       MethodType methodType, boolean isStatic) throws IllegalAccessException {
39     return classHandler.findShadowMethodHandle(theClass, name, methodType, isStatic);
40   }
41 
42   @SuppressWarnings("UnusedDeclaration")
cleanStackTrace(Throwable exception)43   public static Throwable cleanStackTrace(Throwable exception) {
44     return classHandler.stripStackTrace(exception);
45   }
46 
intercept(String signature, Object instance, Object[] params, Class theClass)47   public static Object intercept(String signature, Object instance, Object[] params, Class theClass) throws Throwable {
48     try {
49       return classHandler.intercept(signature, instance, params, theClass);
50     } catch (java.lang.LinkageError e) {
51       throw new Exception(e);
52     }
53   }
54 
performStaticInitialization(Class<?> clazz)55   public static void performStaticInitialization(Class<?> clazz) {
56     ReflectionHelpers.callStaticMethod(clazz, ShadowConstants.STATIC_INITIALIZER_METHOD_NAME);
57   }
58 
getShadowInvalidator()59   public static ShadowInvalidator getShadowInvalidator() {
60     return shadowInvalidator;
61   }
62 
getClassLoader()63   public static ClassLoader getClassLoader() {
64     return classLoader;
65   }
66 }
67