JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
JavaFileManager fileManager = CompilerUtils.getStringSourceJavaFileManager(compiler, null, null, Charset.forName("UTF-8"));
boolean result = false;
try {
CompilationTask task = compiler.getTask(null, fileManager, null, null, null,Arrays.asList(new JavaSourceFromString("com.test.Say", source)));
result = task.call();
} finally {
fileManager.close();
}