MCPcopy Index your code
hub / github.com/apache/groovy / doCompile

Method doCompile

src/main/java/org/apache/groovy/util/JavaShell.java:194–224  ·  view source on GitHub ↗
(String className, String src, Iterable<String> options)

Source from the content-addressed store, hash-verified

192 }
193
194 private void doCompile(String className, String src, Iterable<String> options) throws IOException {
195 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
196 if (compiler == null) {
197 throw new IllegalStateException("JavaShell requires a JDK at runtime; "
198 + "ToolProvider.getSystemJavaCompiler() returned null (running on a JRE?).");
199 }
200 try (BytesJavaFileManager bjfm = new BytesJavaFileManager(compiler.getStandardFileManager(null, locale, charset))) {
201 StringBuilderWriter out = new StringBuilderWriter();
202 JavaCompiler.CompilationTask task =
203 compiler.getTask(
204 out,
205 bjfm,
206 null,
207 options,
208 Collections.emptyList(),
209 Collections.singletonList(
210 new MemJavaFileObject(className, src)
211 )
212 );
213
214 task.call();
215
216 if (bjfm.isEmpty()) {
217 throw new JavaShellCompilationException(out.toString());
218 }
219
220 final Map<String, byte[]> classMap = bjfm.getClassMap();
221
222 jscl.setClassMap(classMap);
223 }
224 }
225
226 /**
227 * Compile {@code src} and write each resulting class file beneath {@code outputDir}

Callers 3

compileMethod · 0.95
compileAllMethod · 0.95
compileAllToMethod · 0.95

Calls 6

toStringMethod · 0.95
singletonListMethod · 0.80
setClassMapMethod · 0.80
callMethod · 0.65
isEmptyMethod · 0.45
getClassMapMethod · 0.45

Tested by

no test coverage detected