public static <T> Class<T> getClass(String name, String source)
      throws CompileException, ClassNotFoundException {
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    InMemoryFileManager fileManager =
        new InMemoryFileManager(compiler.getStandardFileManager(null, null, null));
    DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
    JavaCompiler.CompilationTask task =
        compiler.getTask(
            null,
            fileManager,
            diagnostics,
            ImmutableList.of("-classpath", classpathSupplier.get()),
            null,
            Collections.singletonList(new InMemoryFileManager.InputJavaFileObject(name, source)));
    boolean result = task.call();
    if (!result) {
      throw new CompileException(diagnostics);
    } else {
      return (Class<T>) fileManager.getClassLoader().loadClass(name);
    }
  }
@Test
  public void testGetClass() throws Exception {
    Class<?> clazz = StringCompiler.getClass("Square", SQUARE_SOURCE);
    assertTrue(Function.class.isAssignableFrom(clazz));
    assertEquals("Square", clazz.getSimpleName());
  }