private static JavaCompiler.CompilationTask tryInstallClientCodeWrapperCallDispatcher(JavaCompiler.CompilationTask task, StandardJavaFileManager delegateTo) {
    try {
      final Class<? extends JavaCompiler.CompilationTask> taskClass = task.getClass();
      final Field contextField = findField(taskClass, new BooleanFunction<Field>() {
        private final Class<?> contextClass = Class.forName("com.sun.tools.javac.util.Context", true, taskClass.getClassLoader());
        @Override
        public boolean fun(Field field) {
          return contextClass.equals(field.getType());
        }
      });
      if (contextField != null) {
        final Object contextObject = contextField.get(task);
        final Method getMethod = contextObject.getClass().getMethod("get", Class.class);
        final Object currentManager = getMethod.invoke(contextObject, JavaFileManager.class);
        if (isClientCodeWrapper(currentManager, delegateTo)) {
          final Method putMethod = contextObject.getClass().getMethod("put", Class.class, Object.class);
          putMethod.invoke(contextObject, JavaFileManager.class, null);  // must clear previous value first
          putMethod.invoke(contextObject, JavaFileManager.class, APIWrappers.wrap(StandardJavaFileManager.class, currentManager, Object.class, delegateTo));
        }
        else {
          installCallDispatcherRecursively(currentManager, delegateTo, new HashSet<>());
        }
      }
    }
    catch (Throwable ignored) {
    }
    return task;
  }
private static JavaCompiler.CompilationTask tryInstallClientCodeWrapperCallDispatcher(JavaCompiler.CompilationTask task, StandardJavaFileManager delegateTo)