src/jdk.compiler/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java

Print this page
rev 2819 : imported patch my-classpath-deps-00

*** 28,41 **** import java.io.File; import java.io.PrintStream; import java.net.URI; import java.util.Arrays; import java.util.Collections; ! import java.util.Set; import java.util.Map; import com.sun.tools.sjavac.options.Options; import com.sun.tools.sjavac.server.CompilationResult; import com.sun.tools.sjavac.server.Sjavac; import com.sun.tools.sjavac.server.SysInfo; /** --- 28,43 ---- import java.io.File; import java.io.PrintStream; import java.net.URI; import java.util.Arrays; import java.util.Collections; ! import java.util.HashMap; import java.util.Map; + import java.util.Set; import com.sun.tools.sjavac.options.Options; + import com.sun.tools.sjavac.pubapi.PubApi; import com.sun.tools.sjavac.server.CompilationResult; import com.sun.tools.sjavac.server.Sjavac; import com.sun.tools.sjavac.server.SysInfo; /**
*** 71,95 **** final Set<URI> visibleSources, final Map<URI,Set<String>> visibleClasses, Map<String,Set<String>> oldPackageDependents, URI destRoot, final Map<String,Set<URI>> packageArtifacts, ! final Map<String,Set<String>> packageDependencies, ! final Map<String,String> packagePubapis, int debugLevel, boolean incremental, int numCores, final PrintStream out, ! final PrintStream err) ! { boolean rc = true; boolean concurrentCompiles = true; // Fetch the id. final String id = Util.extractStringOption("id", sjavac.serverSettings()); // Only keep portfile and sjavac settings.. ! String psServerSettings = Util.cleanSubOptions(Util.set("portfile","sjavac","background","keepalive"), sjavac.serverSettings()); // Get maximum heap size from the server! SysInfo sysinfo = sjavac.getSysInfo(); if (sysinfo == null) { Log.error("Could not query server for sysinfo!"); --- 73,101 ---- final Set<URI> visibleSources, final Map<URI,Set<String>> visibleClasses, Map<String,Set<String>> oldPackageDependents, URI destRoot, final Map<String,Set<URI>> packageArtifacts, ! final Map<String,Map<String, Set<String>>> packageDependencies, ! final Map<String,Map<String, Set<String>>> packageCpDependencies, ! final Map<String, PubApi> packagePubapis, ! final Map<String, PubApi> dependencyPubapis, int debugLevel, boolean incremental, int numCores, final PrintStream out, ! final PrintStream err) { ! ! Log.debug("Performing CompileJavaPackages transform..."); ! boolean rc = true; boolean concurrentCompiles = true; // Fetch the id. final String id = Util.extractStringOption("id", sjavac.serverSettings()); // Only keep portfile and sjavac settings.. ! //String psServerSettings = Util.cleanSubOptions(Util.set("portfile","sjavac","background","keepalive"), sjavac.serverSettings()); // Get maximum heap size from the server! SysInfo sysinfo = sjavac.getSysInfo(); if (sysinfo == null) { Log.error("Could not query server for sysinfo!");
*** 208,231 **** for (int i=0; i<numCompiles; ++i) { final int ii = i; final CompileChunk cc = compileChunks[i]; // Pass the num_cores and the id (appended with the chunk number) to the server. ! final String cleanedServerSettings = psServerSettings+",poolsize="+numCores+",id="+id+"-"+i; ! requests[i] = new Thread() { @Override public void run() { rn[ii] = sjavac.compile("n/a", id + "-" + ii, args.prepJavacArgs(), Collections.<File>emptyList(), cc.srcs, visibleSources); ! packageArtifacts.putAll(rn[ii].packageArtifacts); ! packageDependencies.putAll(rn[ii].packageDependencies); ! packagePubapis.putAll(rn[ii].packagePubapis); } }; if (cc.srcs.size() > 0) { String numdeps = ""; --- 214,261 ---- for (int i=0; i<numCompiles; ++i) { final int ii = i; final CompileChunk cc = compileChunks[i]; // Pass the num_cores and the id (appended with the chunk number) to the server. ! Object lock = new Object(); requests[i] = new Thread() { @Override public void run() { rn[ii] = sjavac.compile("n/a", id + "-" + ii, args.prepJavacArgs(), Collections.<File>emptyList(), cc.srcs, visibleSources); ! // In the code below we have to keep in mind that two ! // different compilation results may include results for ! // the same package. ! synchronized (lock) { ! ! for (String pkg : rn[ii].packageArtifacts.keySet()) { ! Set<URI> pkgArtifacts = rn[ii].packageArtifacts.get(pkg); ! packageArtifacts.merge(pkg, pkgArtifacts, Util::union); ! } ! ! for (String pkg : rn[ii].packageDependencies.keySet()) { ! packageDependencies.putIfAbsent(pkg, new HashMap<>()); ! packageDependencies.get(pkg).putAll(rn[ii].packageDependencies.get(pkg)); ! } ! ! for (String pkg : rn[ii].packageCpDependencies.keySet()) { ! packageCpDependencies.putIfAbsent(pkg, new HashMap<>()); ! packageCpDependencies.get(pkg).putAll(rn[ii].packageCpDependencies.get(pkg)); ! } ! ! for (String pkg : rn[ii].packagePubapis.keySet()) { ! packagePubapis.merge(pkg, rn[ii].packagePubapis.get(pkg), PubApi::mergeTypes); ! } ! ! for (String pkg : rn[ii].dependencyPubapis.keySet()) { ! dependencyPubapis.merge(pkg, rn[ii].dependencyPubapis.get(pkg), PubApi::mergeTypes); ! } ! } } }; if (cc.srcs.size() > 0) { String numdeps = "";
*** 276,286 **** Log.debug("Compilation of "+numSources+" source files took "+minutes+"m "+seconds+"s"); return rc; } - /** * Split up the sources into compile chunks. If old package dependents information * is available, sort the order of the chunks into the most dependent first! * (Typically that chunk contains the java.lang package.) In the future * we could perhaps improve the heuristics to put the sources into even more sensible chunks. --- 306,315 ----