MCPcopy Create free account
hub / github.com/apache/pig / compile

Method compile

src/org/apache/pig/impl/util/JavaCompilerHelper.java:66–86  ·  view source on GitHub ↗
(String target, JavaSourceFromString... sources)

Source from the content-addressed store, hash-verified

64 }
65
66 public void compile(String target, JavaSourceFromString... sources) {
67 LOG.info("compiling java classes to "+target);
68 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
69 JavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
70 DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
71
72 List<String> optionList = Lists.newArrayList();
73 // Adds the current classpath to the compiler along with our generated code
74 optionList.add("-classpath");
75 optionList.add(classPath);
76 optionList.add("-d");
77 optionList.add(target);
78
79 if (!compiler.getTask(null, fileManager, diagnostics, optionList, null, Arrays.asList(sources)).call()) {
80 LOG.warn("Error compiling Printing compilation errors and shutting down.");
81 for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics.getDiagnostics()) {
82 LOG.warn("Error on line " + diagnostic.getLineNumber() + ": " + diagnostic.getMessage(Locale.US));
83 }
84 throw new RuntimeException("Unable to compile");
85 }
86 }
87
88 public void addToClassPath(String path) {
89 this.classPath = this.classPath + System.getProperty("path.separator") + path;

Callers 4

testImportListMethod · 0.95
compileCodeStringMethod · 0.95
UtilsClass · 0.45

Calls 7

infoMethod · 0.80
getDiagnosticsMethod · 0.80
addMethod · 0.65
warnMethod · 0.65
callMethod · 0.45
getLineNumberMethod · 0.45
getMessageMethod · 0.45

Tested by 2

testImportListMethod · 0.76