code: @SuppressWarnings("unchecked")
      static <T, G extends T> Class<G> generateProxyClass(Context context, Class<T> baseClass)
              throws IOException {
          // Cache missed; generate the proxy class.
          final DexMaker dexMaker = new DexMaker();
  
          final String proxyClassName = getClassNameForProxyOf(baseClass);
          final TypeId<G> generatedType = TypeId.get("L" + proxyClassName + ";");
          final TypeId<T> baseType = TypeId.get(baseClass);
  
          generateConstructorAndFields(dexMaker, generatedType, baseType);
          generateOnMeasureMethod(dexMaker, generatedType, baseType);
          generateOnLayoutMethod(dexMaker, generatedType, baseType);
          generateDrawMethods(dexMaker, generatedType, baseType);
          generateRequestLayoutMethod(dexMaker, generatedType, baseType);
          generateForceLayoutMethod(dexMaker, generatedType, baseType);
          generateSetMeasuredDimension(dexMaker, generatedType, baseType);
          generateSetInterceptor(dexMaker, generatedType, baseType);
  
          dexMaker.declare(generatedType, proxyClassName + ".generated", PUBLIC, baseType,
                  INTERCEPTABLE_VIEW_TYPE);
  
          final ClassLoader classLoader = dexMaker.generateAndLoad(context.getClassLoader(),
                  context.getDir(DEX_CACHE_DIRECTORY, Context.MODE_PRIVATE));
          try {
              return (Class<G>) classLoader.loadClass(proxyClassName);
          } catch (IllegalAccessError e) {
              // Thrown when the base class is not accessible.
              throw new UnsupportedOperationException(
                      "cannot proxy inaccessible class " + baseClass, e);
          } catch (ClassNotFoundException e) {
              // Should not be thrown, we're sure to have generated this class.
              throw new AssertionError(e);
          }
      }
docs: Generates dynamic {@link android.view.View} proxy class.