Commit 65544c64 authored by Ahmed Ashour's avatar Ahmed Ashour Committed by skylot

test: warn about compiler not found, and gracefully report failure (PR #511)

parent b49acfda
......@@ -4,6 +4,10 @@ import javax.tools.JavaCompiler;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.ToolProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
......@@ -14,6 +18,8 @@ import static javax.tools.JavaCompiler.CompilationTask;
public class DynamicCompiler {
private static final Logger LOG = LoggerFactory.getLogger(DynamicCompiler.class);
private final ClassNode clsNode;
private JavaFileManager fileManager;
......@@ -29,6 +35,10 @@ public class DynamicCompiler {
String code = clsNode.getCode().toString();
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) {
LOG.error("Can not find compiler, please use JDK instead");
return false;
}
fileManager = new ClassFileManager(compiler.getStandardFileManager(null, null, null));
List<JavaFileObject> jFiles = new ArrayList<>(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment