import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.EmptyVisitor;
-import javax.tools.Diagnostic;
-import javax.tools.JavaFileObject;
+import javax.tools.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.ServerSocket;
if (hasSourcesToCompile) {
final Set<File> sourcePath = TEMPORARY_SOURCE_ROOTS_KEY.get(context, Collections.<File>emptySet());
- final boolean compiledOk = compileJava(files, classpath, platformCp, sourcePath, outs, context, diagnosticSink, outputSink);
+ final boolean compiledOk = compileJava(chunk, files, classpath, platformCp, sourcePath, outs, context, diagnosticSink, outputSink);
final Map<File, String> chunkSourcePath = ProjectPaths.getSourceRootsWithDependents(chunk, context.isCompilingTests());
final ClassLoader compiledClassesLoader = createInstrumentationClassLoader(classpath, platformCp, chunkSourcePath, outputSink);
return exitCode;
}
- private boolean compileJava(Collection<File> files,
+ private boolean compileJava(ModuleChunk chunk, Collection<File> files,
Collection<File> classpath,
Collection<File> platformCp,
Collection<File> sourcePath,
CompileContext context,
DiagnosticOutputConsumer diagnosticSink,
final OutputFileConsumer outputSink) throws Exception {
- final List<String> options = getCompilationOptions(context);
+ final List<String> options = getCompilationOptions(context, chunk);
final ClassProcessingConsumer classesConsumer = new ClassProcessingConsumer(context, outputSink);
try {
final boolean rc;
if (USE_EMBEDDED_JAVAC) {
- rc = JavacMain
- .compile(options, files, classpath, platformCp, sourcePath, outs, diagnosticSink, classesConsumer, context.getCancelStatus());
+ rc = JavacMain.compile(
+ options, files, classpath, platformCp, sourcePath, outs, diagnosticSink, classesConsumer, context.getCancelStatus()
+ );
}
else {
final JavacServerClient client = ensureJavacServerLaunched(context);
- final RequestFuture<JavacServerResponseHandler> future =
- client.sendCompileRequest(options, files, classpath, platformCp, sourcePath, outs, diagnosticSink, classesConsumer);
+ final RequestFuture<JavacServerResponseHandler> future = client.sendCompileRequest(
+ options, files, classpath, platformCp, sourcePath, outs, diagnosticSink, classesConsumer
+ );
try {
future.get();
}
final int port = findFreePort();
final int heapSize = getJavacServerHeapSize(context);
- final BaseOSProcessHandler processHandler =
- JavacServerBootstrap.launchJavacServer(vmExecPath, heapSize, port, Paths.getSystemRoot(), getCompilationVMOptions(context));
+ final BaseOSProcessHandler processHandler = JavacServerBootstrap.launchJavacServer(
+ vmExecPath, heapSize, port, Paths.getSystemRoot(), getCompilationVMOptions(context)
+ );
final JavacServerClient client = new JavacServerClient();
try {
client.connect(hostString, port);
return cached;
}
- private static List<String> getCompilationOptions(CompileContext context) {
+ private static List<String> getCompilationOptions(CompileContext context, ModuleChunk chunk) {
List<String> cached = JAVAC_OPTIONS.get(context);
if (cached == null) {
loadJavacOptions(context);
cached = JAVAC_OPTIONS.get(context);
}
return cached;
+ //final List<String> options = new ArrayList<String>(cached);
+ //final Module module = chunk.getModules().iterator().next();
+ //final String langlevel = module.getLanguageLevel();
+ //final Sdk sdk = module.getSdk();
+ //return options;
}
private static void loadJavacOptions(CompileContext context) {