CompiledTypeInfo compile(TypeInfo typeInfo, ProcessingEnvironment processingEnv)
throws IOException, ClassNotFoundException {
PathInfo pathInfo = pathInfo(typeInfo);
String classOutputPath = classOutputPath(processingEnv);
List<String> options = ImmutableList.<String> builder()
.add(pathInfo.file())
.add("-d")
.add(classOutputPath)
.add("-classpath")
.add(classPath + PATH_SEPARATOR + pathInfo.sourceLocation())
.add("-proc:none")
.build();
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
javac.run(null, System.out, System.err, options.toArray(new String[] {}));
URL[] urls = ImmutableList.<URL> builder()
.addAll(urlList)
.add(new File(classOutputPath + FILE_SEPARATOR).toURI().toURL())
.build()
.toArray(new URL[] {});
try (URLClassLoader loader = new URLClassLoader(urls, getClass().getClassLoader())) {
Class<?> type = Class.forName(typeInfo.qualifiedName(), true, loader);
return CompiledTypeInfo.of(typeInfo, type);
}
}