langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java
changeset 32335 7df616378cf3
parent 31115 8d8e98052d5d
child 32542 f4e4f4c4f9f4
equal deleted inserted replaced
32334:fd65e32e16b3 32335:7df616378cf3
    30 import java.net.URI;
    30 import java.net.URI;
    31 import java.util.Arrays;
    31 import java.util.Arrays;
    32 import java.util.Collections;
    32 import java.util.Collections;
    33 import java.util.HashMap;
    33 import java.util.HashMap;
    34 import java.util.Map;
    34 import java.util.Map;
       
    35 import java.util.Random;
    35 import java.util.Set;
    36 import java.util.Set;
    36 
    37 
       
    38 import com.sun.tools.sjavac.comp.CompilationService;
    37 import com.sun.tools.sjavac.options.Options;
    39 import com.sun.tools.sjavac.options.Options;
    38 import com.sun.tools.sjavac.pubapi.PubApi;
    40 import com.sun.tools.sjavac.pubapi.PubApi;
    39 import com.sun.tools.sjavac.server.CompilationResult;
    41 import com.sun.tools.sjavac.server.CompilationSubResult;
    40 import com.sun.tools.sjavac.server.Sjavac;
       
    41 import com.sun.tools.sjavac.server.SysInfo;
    42 import com.sun.tools.sjavac.server.SysInfo;
    42 
    43 
    43 /**
    44 /**
    44  * This transform compiles a set of packages containing Java sources.
    45  * This transform compiles a set of packages containing Java sources.
    45  * The compile request is divided into separate sets of source files.
    46  * The compile request is divided into separate sets of source files.
    66 
    67 
    67     public void setExtra(Options a) {
    68     public void setExtra(Options a) {
    68         args = a;
    69         args = a;
    69     }
    70     }
    70 
    71 
    71     public boolean transform(final Sjavac sjavac,
    72     public boolean transform(final CompilationService sjavac,
    72                              Map<String,Set<URI>> pkgSrcs,
    73                              Map<String,Set<URI>> pkgSrcs,
    73                              final Set<URI>             visibleSources,
    74                              final Set<URI>             visibleSources,
    74                              final Map<URI,Set<String>> visibleClasses,
    75                              final Map<URI,Set<String>> visibleClasses,
    75                              Map<String,Set<String>> oldPackageDependents,
    76                              Map<String,Set<String>> oldPackageDependents,
    76                              URI destRoot,
    77                              URI destRoot,
    89 
    90 
    90         boolean rc = true;
    91         boolean rc = true;
    91         boolean concurrentCompiles = true;
    92         boolean concurrentCompiles = true;
    92 
    93 
    93         // Fetch the id.
    94         // Fetch the id.
    94         final String id = Util.extractStringOption("id", sjavac.serverSettings());
    95         final String id = String.valueOf(new Random().nextInt());
    95         // Only keep portfile and sjavac settings..
    96         // Only keep portfile and sjavac settings..
    96         //String psServerSettings = Util.cleanSubOptions(Util.set("portfile","sjavac","background","keepalive"), sjavac.serverSettings());
    97         //String psServerSettings = Util.cleanSubOptions(Util.set("portfile","sjavac","background","keepalive"), sjavac.serverSettings());
    97 
    98 
    98         // Get maximum heap size from the server!
       
    99         SysInfo sysinfo = sjavac.getSysInfo();
    99         SysInfo sysinfo = sjavac.getSysInfo();
   100         if (sysinfo == null) {
       
   101             Log.error("Could not query server for sysinfo!");
       
   102             return false;
       
   103         }
       
   104         int numMBytes = (int)(sysinfo.maxMemory / ((long)(1024*1024)));
   100         int numMBytes = (int)(sysinfo.maxMemory / ((long)(1024*1024)));
   105         Log.debug("Server reports "+numMBytes+"MiB of memory and "+sysinfo.numCores+" cores");
   101         Log.debug("Server reports "+numMBytes+"MiB of memory and "+sysinfo.numCores+" cores");
   106 
   102 
   107         if (numCores <= 0) {
   103         if (numCores <= 0) {
   108             // Set the requested number of cores to the number of cores on the server.
   104             // Set the requested number of cores to the number of cores on the server.
   203                 }
   199                 }
   204             }
   200             }
   205         }
   201         }
   206 
   202 
   207         // The return values for each chunked compile.
   203         // The return values for each chunked compile.
   208         final CompilationResult[] rn = new CompilationResult[numCompiles];
   204         final CompilationSubResult[] rn = new CompilationSubResult[numCompiles];
   209         // The requets, might or might not run as a background thread.
   205         // The requets, might or might not run as a background thread.
   210         final Thread[] requests  = new Thread[numCompiles];
   206         final Thread[] requests  = new Thread[numCompiles];
   211 
   207 
   212         long start = System.currentTimeMillis();
   208         long start = System.currentTimeMillis();
   213 
   209