8062737: Sjavac creates unnecessarily many SjavacClient/PooledSjavac/SjavacImpl instances
authoralundblad
Mon, 10 Nov 2014 20:29:58 +0100
changeset 27550 7687cc8669cd
parent 27549 55a03b691be2
child 27551 14a74a56c4a0
8062737: Sjavac creates unnecessarily many SjavacClient/PooledSjavac/SjavacImpl instances Summary: Moved sjavac initialization out of loop body. Reviewed-by: jfranck, ohrstrom
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<String> 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);