langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java
equal
deleted
inserted
replaced
40 import java.util.concurrent.Callable; |
40 import java.util.concurrent.Callable; |
41 import java.util.concurrent.ExecutionException; |
41 import java.util.concurrent.ExecutionException; |
42 import java.util.concurrent.ExecutorService; |
42 import java.util.concurrent.ExecutorService; |
43 import java.util.concurrent.Executors; |
43 import java.util.concurrent.Executors; |
44 import java.util.concurrent.Future; |
44 import java.util.concurrent.Future; |
|
45 import java.util.regex.Pattern; |
|
46 import java.util.stream.Stream; |
45 |
47 |
46 import com.sun.tools.sjavac.comp.CompilationService; |
48 import com.sun.tools.sjavac.comp.CompilationService; |
47 import com.sun.tools.sjavac.options.Options; |
49 import com.sun.tools.sjavac.options.Options; |
48 import com.sun.tools.sjavac.pubapi.PubApi; |
50 import com.sun.tools.sjavac.pubapi.PubApi; |
49 import com.sun.tools.sjavac.server.CompilationSubResult; |
51 import com.sun.tools.sjavac.server.CompilationSubResult; |
87 final Map<String,Map<String, Set<String>>> packageCpDependencies, |
89 final Map<String,Map<String, Set<String>>> packageCpDependencies, |
88 final Map<String, PubApi> packagePubapis, |
90 final Map<String, PubApi> packagePubapis, |
89 final Map<String, PubApi> dependencyPubapis, |
91 final Map<String, PubApi> dependencyPubapis, |
90 int debugLevel, |
92 int debugLevel, |
91 boolean incremental, |
93 boolean incremental, |
92 int numCores, |
94 int numCores) { |
93 final Writer out, |
|
94 final Writer err) { |
|
95 |
95 |
96 Log.debug("Performing CompileJavaPackages transform..."); |
96 Log.debug("Performing CompileJavaPackages transform..."); |
97 |
97 |
98 boolean rc = true; |
98 boolean rc = true; |
99 boolean concurrentCompiles = true; |
99 boolean concurrentCompiles = true; |
217 if (cc.srcs.isEmpty()) { |
217 if (cc.srcs.isEmpty()) { |
218 continue; |
218 continue; |
219 } |
219 } |
220 |
220 |
221 String chunkId = id + "-" + String.valueOf(i); |
221 String chunkId = id + "-" + String.valueOf(i); |
|
222 Log log = Log.get(); |
222 compilationCalls.add(() -> { |
223 compilationCalls.add(() -> { |
|
224 Log.setLogForCurrentThread(log); |
223 CompilationSubResult result = sjavac.compile("n/a", |
225 CompilationSubResult result = sjavac.compile("n/a", |
224 chunkId, |
226 chunkId, |
225 args.prepJavacArgs(), |
227 args.prepJavacArgs(), |
226 Collections.<File>emptyList(), |
228 Collections.<File>emptyList(), |
227 cc.srcs, |
229 cc.srcs, |
228 visibleSources); |
230 visibleSources); |
229 synchronized (lock) { |
231 synchronized (lock) { |
230 safeWrite(result.stdout, out); |
232 Util.getLines(result.stdout).forEach(Log::info); |
231 safeWrite(result.stderr, err); |
233 Util.getLines(result.stderr).forEach(Log::error); |
232 } |
234 } |
233 return result; |
235 return result; |
234 }); |
236 }); |
235 } |
237 } |
236 |
238 |
244 for (Future<CompilationSubResult> fut : futs) { |
246 for (Future<CompilationSubResult> fut : futs) { |
245 try { |
247 try { |
246 subResults.add(fut.get()); |
248 subResults.add(fut.get()); |
247 } catch (ExecutionException ee) { |
249 } catch (ExecutionException ee) { |
248 Log.error("Compilation failed: " + ee.getMessage()); |
250 Log.error("Compilation failed: " + ee.getMessage()); |
249 } catch (InterruptedException ee) { |
251 Log.error(ee); |
250 Log.error("Compilation interrupted: " + ee.getMessage()); |
252 } catch (InterruptedException ie) { |
|
253 Log.error("Compilation interrupted: " + ie.getMessage()); |
|
254 Log.error(ie); |
251 Thread.currentThread().interrupt(); |
255 Thread.currentThread().interrupt(); |
252 } |
256 } |
253 } |
257 } |
254 exec.shutdownNow(); |
258 exec.shutdownNow(); |
255 |
259 |
288 long minutes = duration/60000; |
292 long minutes = duration/60000; |
289 long seconds = (duration-minutes*60000)/1000; |
293 long seconds = (duration-minutes*60000)/1000; |
290 Log.debug("Compilation of "+numSources+" source files took "+minutes+"m "+seconds+"s"); |
294 Log.debug("Compilation of "+numSources+" source files took "+minutes+"m "+seconds+"s"); |
291 |
295 |
292 return rc; |
296 return rc; |
293 } |
|
294 |
|
295 private void safeWrite(String str, Writer w) { |
|
296 if (str.length() > 0) { |
|
297 try { |
|
298 w.write(str); |
|
299 } catch (IOException e) { |
|
300 Log.error("Could not print compilation output."); |
|
301 } |
|
302 } |
|
303 } |
297 } |
304 |
298 |
305 /** |
299 /** |
306 * Split up the sources into compile chunks. If old package dependents information |
300 * Split up the sources into compile chunks. If old package dependents information |
307 * is available, sort the order of the chunks into the most dependent first! |
301 * is available, sort the order of the chunks into the most dependent first! |