CompilationTask task = compiler.getTask(null, fileManager, listener, compilerOptions, null, Collections.singleton(compilationUnit));
// Run the compiler.
if(!task.call()) {
throw new CompileException("Compilation failed", null);
} else if (!compilationUnit.isCompiled()) {
throw new ClassNotFoundException(className + ": Class file not created by compilation.");
}
// all good
return compilationUnit.getByteCode();