# HG changeset patch # User alundblad # Date 1415647798 -3600 # Node ID 7687cc8669cd780006037ddb372bc8e49434e234 # Parent 55a03b691be28c17cbd2dffe9c8878feb653ea0c 8062737: Sjavac creates unnecessarily many SjavacClient/PooledSjavac/SjavacImpl instances Summary: Moved sjavac initialization out of loop body. Reviewed-by: jfranck, ohrstrom diff -r 55a03b691be2 -r 7687cc8669cd langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/ClientMain.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/ClientMain.java Fri Oct 24 10:08:51 2014 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/ClientMain.java Mon Nov 10 20:29:58 2014 +0100 @@ -218,21 +218,21 @@ // Collect the name of all compiled packages. Set recently_compiled = new HashSet<>(); boolean[] rc = new boolean[1]; + boolean background = Util.extractBooleanOption("background", options.getServerConf(), true); Sjavac sjavac; - boolean background = Util.extractBooleanOption("background", options.getServerConf(), true); + // Create an sjavac implementation to be used for compilation + if (background) { + sjavac = new SjavacClient(options); + } else { + int poolsize = Util.extractIntOption("poolsize", options.getServerConf()); + if (poolsize <= 0) + poolsize = Runtime.getRuntime().availableProcessors(); + sjavac = new PooledSjavac(new SjavacImpl(), poolsize); + } + do { // Clean out artifacts in tainted packages. javac_state.deleteClassArtifactsInTaintedPackages(); - // Create an sjavac implementation to be used for compilation - if (background) { - sjavac = new SjavacClient(options); - } else { - int poolsize = Util.extractIntOption("poolsize", options.getServerConf()); - if (poolsize <= 0) - poolsize = Runtime.getRuntime().availableProcessors(); - sjavac = new PooledSjavac(new SjavacImpl(), poolsize); - } - again = javac_state.performJavaCompilations(sjavac, options, recently_compiled, rc); if (!rc[0]) break; } while (again);