public boolean compile(List sources, List options, StringWriter log) { if (IJ.debugMode) IJ.log("Compiler: using javax.tool.JavaCompiler"); try { JavaCompiler javac = getJavac(); DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>(); StandardJavaFileManager fileManager = javac.getStandardFileManager(diagnostics, null, null); Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromStrings(sources); JavaCompiler.CompilationTask task =javac.getTask(log, fileManager, null, options, null, compilationUnits); fileManager.close(); return task.call(); } catch (Exception e) { PrintWriter printer = new PrintWriter(log); e.printStackTrace(printer); printer.flush(); } return false; }
public boolean compile(List sources, List options, StringWriter log) { if (IJ.debugMode) IJ.log("Compiler: using javax.tool.JavaCompiler"); try { JavaCompiler javac = getJavac(); DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>(); StandardJavaFileManager fileManager = javac.getStandardFileManager(diagnostics, null, null); Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromStrings(sources); JavaCompiler.CompilationTask task =javac.getTask(log, fileManager, null, options, null, compilationUnits); fileManager.close(); return task.call(); } catch (Exception e) { PrintWriter printer = new PrintWriter(log); e.printStackTrace(printer); printer.flush(); } return false; }
public static CompilerTool getDefault() { CompilerTool javax = new JavaxCompilerTool(); if (javax.isSupported()) return javax; CompilerTool legacy = new LegacyCompilerTool(); if (legacy.isSupported()) return legacy; return null; }
public static CompilerTool getDefault() { CompilerTool javax = new JavaxCompilerTool(); if (javax.isSupported()) return javax; CompilerTool legacy = new LegacyCompilerTool(); if (legacy.isSupported()) return legacy; return null; }