src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java

Wed, 10 Jun 2015 14:22:04 -0700

author
mfang
date
Wed, 10 Jun 2015 14:22:04 -0700
changeset 2815
d4051d4f5daf
parent 2413
fe033d997ddf
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8083601: jdk8u60 l10n resource file translation update 2
Reviewed-by: ksrini, yhuang

ohrstrom@1504 1 /*
jjg@1763 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
ohrstrom@1504 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohrstrom@1504 4 *
ohrstrom@1504 5 * This code is free software; you can redistribute it and/or modify it
ohrstrom@1504 6 * under the terms of the GNU General Public License version 2 only, as
ohrstrom@1504 7 * published by the Free Software Foundation. Oracle designates this
ohrstrom@1504 8 * particular file as subject to the "Classpath" exception as provided
ohrstrom@1504 9 * by Oracle in the LICENSE file that accompanied this code.
ohrstrom@1504 10 *
ohrstrom@1504 11 * This code is distributed in the hope that it will be useful, but WITHOUT
ohrstrom@1504 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohrstrom@1504 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohrstrom@1504 14 * version 2 for more details (a copy is included in the LICENSE file that
ohrstrom@1504 15 * accompanied this code).
ohrstrom@1504 16 *
ohrstrom@1504 17 * You should have received a copy of the GNU General Public License version
ohrstrom@1504 18 * 2 along with this work; if not, write to the Free Software Foundation,
ohrstrom@1504 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohrstrom@1504 20 *
ohrstrom@1504 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohrstrom@1504 22 * or visit www.oracle.com if you need additional information or have any
ohrstrom@1504 23 * questions.
ohrstrom@1504 24 */
ohrstrom@1504 25
ohrstrom@1504 26 package com.sun.tools.sjavac.server;
ohrstrom@1504 27
ohrstrom@1504 28 import java.io.BufferedReader;
ohrstrom@1504 29 import java.io.File;
ohrstrom@1504 30 import java.io.IOException;
ohrstrom@1504 31 import java.io.InputStreamReader;
ohrstrom@1504 32 import java.io.OutputStreamWriter;
ohrstrom@1504 33 import java.io.PrintWriter;
ohrstrom@1504 34 import java.io.StringWriter;
ohrstrom@1504 35 import java.net.Socket;
ohrstrom@1504 36 import java.net.URI;
ohrstrom@1504 37 import java.net.URISyntaxException;
ohrstrom@1504 38 import java.util.ArrayList;
ohrstrom@1504 39 import java.util.Arrays;
ohrstrom@1504 40 import java.util.HashSet;
ohrstrom@1504 41 import java.util.List;
ohrstrom@1504 42 import java.util.Set;
ohrstrom@1504 43 import java.util.Map;
ohrstrom@1504 44 import java.util.concurrent.Future;
ohrstrom@1504 45 import javax.tools.JavaFileManager;
ohrstrom@1504 46 import javax.tools.JavaFileObject;
ohrstrom@1504 47 import javax.tools.StandardJavaFileManager;
ohrstrom@1504 48
ohrstrom@1504 49 import com.sun.tools.javac.util.Context;
ohrstrom@1504 50 import com.sun.tools.javac.util.Log;
ohrstrom@1504 51 import com.sun.tools.javac.util.BaseFileManager;
jlahoda@2413 52 import com.sun.tools.javac.util.StringUtils;
ohrstrom@1504 53 import com.sun.tools.sjavac.comp.Dependencies;
ohrstrom@1504 54 import com.sun.tools.sjavac.comp.JavaCompilerWithDeps;
ohrstrom@1504 55 import com.sun.tools.sjavac.comp.SmartFileManager;
ohrstrom@1504 56 import com.sun.tools.sjavac.comp.ResolveWithDeps;
ohrstrom@1504 57
ohrstrom@1504 58 /**
ohrstrom@1504 59 * The compiler thread maintains a JavaCompiler instance and
ohrstrom@1504 60 * can receive a request from the client, perform the compilation
ohrstrom@1504 61 * requested and report back the results.
ohrstrom@1504 62 *
ohrstrom@1504 63 * * <p><b>This is NOT part of any supported API.
ohrstrom@1504 64 * If you write code that depends on this, you do so at your own
ohrstrom@1504 65 * risk. This code and its internal interfaces are subject to change
ohrstrom@1504 66 * or deletion without notice.</b></p>
ohrstrom@1504 67 */
ohrstrom@1504 68 public class CompilerThread implements Runnable {
ohrstrom@1504 69 private JavacServer javacServer;
ohrstrom@1504 70 private CompilerPool compilerPool;
ohrstrom@1504 71 private List<Future<?>> subTasks;
ohrstrom@1504 72
ohrstrom@1504 73 // Communicating over this socket.
ohrstrom@1504 74 private Socket socket;
ohrstrom@1504 75
ohrstrom@1504 76 // The necessary classes to do a compilation.
ohrstrom@1504 77 private com.sun.tools.javac.api.JavacTool compiler;
ohrstrom@1504 78 private StandardJavaFileManager fileManager;
ohrstrom@1504 79 private BaseFileManager fileManagerBase;
ohrstrom@1504 80 private SmartFileManager smartFileManager;
ohrstrom@1504 81 private Context context;
ohrstrom@1504 82
ohrstrom@1504 83 // If true, then this thread is serving a request.
ohrstrom@1504 84 private boolean inUse = false;
ohrstrom@1504 85
ohrstrom@1504 86 CompilerThread(CompilerPool cp) {
ohrstrom@1504 87 compilerPool = cp;
ohrstrom@1504 88 javacServer = cp.getJavacServer();
ohrstrom@1504 89 }
ohrstrom@1504 90
ohrstrom@1504 91 /**
ohrstrom@1504 92 * Execute a minor task, for example generating bytecodes and writing them to disk,
ohrstrom@1504 93 * that belong to a major compiler thread task.
ohrstrom@1504 94 */
ohrstrom@1504 95 public synchronized void executeSubtask(Runnable r) {
ohrstrom@1504 96 subTasks.add(compilerPool.executeSubtask(this, r));
ohrstrom@1504 97 }
ohrstrom@1504 98
ohrstrom@1504 99 /**
ohrstrom@1504 100 * Count the number of active sub tasks.
ohrstrom@1504 101 */
ohrstrom@1504 102 public synchronized int numActiveSubTasks() {
ohrstrom@1504 103 int c = 0;
ohrstrom@1504 104 for (Future<?> f : subTasks) {
ohrstrom@1504 105 if (!f.isDone() && !f.isCancelled()) {
ohrstrom@1504 106 c++;
ohrstrom@1504 107 }
ohrstrom@1504 108 }
ohrstrom@1504 109 return c;
ohrstrom@1504 110 }
ohrstrom@1504 111
ohrstrom@1504 112 /**
ohrstrom@1504 113 * Use this socket for the upcoming request.
ohrstrom@1504 114 */
ohrstrom@1504 115 public void setSocket(Socket s) {
ohrstrom@1504 116 socket = s;
ohrstrom@1504 117 }
ohrstrom@1504 118
ohrstrom@1504 119 /**
ohrstrom@1504 120 * Prepare the compiler thread for use. It is not yet started.
ohrstrom@1504 121 * It will be started by the executor service.
ohrstrom@1504 122 */
ohrstrom@1504 123 public synchronized void use() {
ohrstrom@1504 124 assert(!inUse);
ohrstrom@1504 125 inUse = true;
ohrstrom@1504 126 compiler = com.sun.tools.javac.api.JavacTool.create();
ohrstrom@1504 127 fileManager = compiler.getStandardFileManager(null, null, null);
ohrstrom@1504 128 fileManagerBase = (BaseFileManager)fileManager;
ohrstrom@1504 129 smartFileManager = new SmartFileManager(fileManager);
ohrstrom@1504 130 context = new Context();
ohrstrom@1504 131 context.put(JavaFileManager.class, smartFileManager);
ohrstrom@1504 132 ResolveWithDeps.preRegister(context);
ohrstrom@1504 133 JavaCompilerWithDeps.preRegister(context, this);
ohrstrom@1504 134 subTasks = new ArrayList<Future<?>>();
ohrstrom@1504 135 }
ohrstrom@1504 136
ohrstrom@1504 137 /**
ohrstrom@1504 138 * Prepare the compiler thread for idleness.
ohrstrom@1504 139 */
ohrstrom@1504 140 public synchronized void unuse() {
ohrstrom@1504 141 assert(inUse);
ohrstrom@1504 142 inUse = false;
ohrstrom@1504 143 compiler = null;
ohrstrom@1504 144 fileManager = null;
ohrstrom@1504 145 fileManagerBase = null;
ohrstrom@1504 146 smartFileManager = null;
ohrstrom@1504 147 context = null;
ohrstrom@1504 148 subTasks = null;
ohrstrom@1504 149 }
ohrstrom@1504 150
ohrstrom@1504 151 /**
ohrstrom@1504 152 * Expect this key on the next line read from the reader.
ohrstrom@1504 153 */
ohrstrom@1504 154 private static boolean expect(BufferedReader in, String key) throws IOException {
ohrstrom@1504 155 String s = in.readLine();
ohrstrom@1504 156 if (s != null && s.equals(key)) {
ohrstrom@1504 157 return true;
ohrstrom@1504 158 }
ohrstrom@1504 159 return false;
ohrstrom@1504 160 }
ohrstrom@1504 161
ohrstrom@1504 162 // The request identifier, for example GENERATE_NEWBYTECODE
ohrstrom@1504 163 String id = "";
ohrstrom@1504 164
ohrstrom@1504 165 public String currentRequestId() {
ohrstrom@1504 166 return id;
ohrstrom@1504 167 }
ohrstrom@1504 168
ohrstrom@1504 169 PrintWriter stdout;
ohrstrom@1504 170 PrintWriter stderr;
ohrstrom@1504 171 int forcedExitCode = 0;
ohrstrom@1504 172
ohrstrom@1504 173 public void logError(String msg) {
ohrstrom@1504 174 stderr.println(msg);
ohrstrom@1504 175 forcedExitCode = -1;
ohrstrom@1504 176 }
ohrstrom@1504 177
ohrstrom@1504 178 /**
ohrstrom@1504 179 * Invoked by the executor service.
ohrstrom@1504 180 */
ohrstrom@1504 181 public void run() {
ohrstrom@1504 182 // Unique nr that identifies this request.
ohrstrom@1504 183 int thisRequest = compilerPool.startRequest();
ohrstrom@1504 184 long start = System.currentTimeMillis();
ohrstrom@1504 185 int numClasses = 0;
ohrstrom@1504 186 StringBuilder compiledPkgs = new StringBuilder();
ohrstrom@1504 187 use();
ohrstrom@1504 188
ohrstrom@1504 189 PrintWriter out = null;
ohrstrom@1504 190 try {
ohrstrom@1504 191 javacServer.log("<"+thisRequest+"> Connect from "+socket.getRemoteSocketAddress()+" activethreads="+compilerPool.numActiveRequests());
ohrstrom@1504 192 BufferedReader in = new BufferedReader(new InputStreamReader(
ohrstrom@1504 193 socket.getInputStream()));
ohrstrom@1504 194 out = new PrintWriter(new OutputStreamWriter(
ohrstrom@1504 195 socket.getOutputStream()));
ohrstrom@1504 196 if (!expect(in, JavacServer.PROTOCOL_COOKIE_VERSION)) {
ohrstrom@1504 197 javacServer.log("<"+thisRequest+"> Bad protocol from ip "+socket.getRemoteSocketAddress());
ohrstrom@1504 198 return;
ohrstrom@1504 199 }
ohrstrom@1504 200
ohrstrom@1504 201 String cookie = in.readLine();
ohrstrom@1504 202 if (cookie == null || !cookie.equals(""+javacServer.getCookie())) {
ohrstrom@1504 203 javacServer.log("<"+thisRequest+"> Bad cookie from ip "+socket.getRemoteSocketAddress());
ohrstrom@1504 204 return;
ohrstrom@1504 205 }
ohrstrom@1504 206 if (!expect(in, JavacServer.PROTOCOL_CWD)) {
ohrstrom@1504 207 return;
ohrstrom@1504 208 }
ohrstrom@1504 209 String cwd = in.readLine();
ohrstrom@1504 210 if (cwd == null)
ohrstrom@1504 211 return;
ohrstrom@1504 212 if (!expect(in, JavacServer.PROTOCOL_ID)) {
ohrstrom@1504 213 return;
ohrstrom@1504 214 }
ohrstrom@1504 215 id = in.readLine();
ohrstrom@1504 216 if (id == null)
ohrstrom@1504 217 return;
ohrstrom@1504 218 if (!expect(in, JavacServer.PROTOCOL_ARGS)) {
ohrstrom@1504 219 return;
ohrstrom@1504 220 }
ohrstrom@1504 221 ArrayList<String> the_options = new ArrayList<String>();
ohrstrom@1504 222 ArrayList<File> the_classes = new ArrayList<File>();
ohrstrom@1504 223 Iterable<File> path = Arrays.<File> asList(new File(cwd));
ohrstrom@1504 224
ohrstrom@1504 225 for (;;) {
ohrstrom@1504 226 String l = in.readLine();
ohrstrom@1504 227 if (l == null)
ohrstrom@1504 228 return;
ohrstrom@1504 229 if (l.equals(JavacServer.PROTOCOL_SOURCES_TO_COMPILE))
ohrstrom@1504 230 break;
ohrstrom@1504 231 if (l.startsWith("--server:"))
ohrstrom@1504 232 continue;
ohrstrom@1504 233 if (!l.startsWith("-") && l.endsWith(".java")) {
ohrstrom@1504 234 the_classes.add(new File(l));
ohrstrom@1504 235 numClasses++;
ohrstrom@1504 236 } else {
ohrstrom@1504 237 the_options.add(l);
ohrstrom@1504 238 }
ohrstrom@1504 239 continue;
ohrstrom@1504 240 }
ohrstrom@1504 241
ohrstrom@1504 242 // Load sources to compile
ohrstrom@1504 243 Set<URI> sourcesToCompile = new HashSet<URI>();
ohrstrom@1504 244 for (;;) {
ohrstrom@1504 245 String l = in.readLine();
ohrstrom@1504 246 if (l == null)
ohrstrom@1504 247 return;
ohrstrom@1504 248 if (l.equals(JavacServer.PROTOCOL_VISIBLE_SOURCES))
ohrstrom@1504 249 break;
ohrstrom@1504 250 try {
ohrstrom@1504 251 sourcesToCompile.add(new URI(l));
ohrstrom@1504 252 numClasses++;
ohrstrom@1504 253 } catch (URISyntaxException e) {
ohrstrom@1504 254 return;
ohrstrom@1504 255 }
ohrstrom@1504 256 }
ohrstrom@1504 257 // Load visible sources
ohrstrom@1504 258 Set<URI> visibleSources = new HashSet<URI>();
jjg@1763 259 boolean fix_drive_letter_case =
jlahoda@2413 260 StringUtils.toLowerCase(System.getProperty("os.name")).startsWith("windows");
ohrstrom@1504 261 for (;;) {
ohrstrom@1504 262 String l = in.readLine();
ohrstrom@1504 263 if (l == null)
ohrstrom@1504 264 return;
ohrstrom@1504 265 if (l.equals(JavacServer.PROTOCOL_END))
ohrstrom@1504 266 break;
ohrstrom@1504 267 try {
ohrstrom@1504 268 URI u = new URI(l);
ohrstrom@1504 269 if (fix_drive_letter_case) {
ohrstrom@1504 270 // Make sure the driver letter is lower case.
ohrstrom@1504 271 String s = u.toString();
ohrstrom@1504 272 if (s.startsWith("file:/") &&
ohrstrom@1504 273 Character.isUpperCase(s.charAt(6))) {
ohrstrom@1504 274 u = new URI("file:/"+Character.toLowerCase(s.charAt(6))+s.substring(7));
ohrstrom@1504 275 }
ohrstrom@1504 276 }
ohrstrom@1504 277 visibleSources.add(u);
ohrstrom@1504 278 } catch (URISyntaxException e) {
ohrstrom@1504 279 return;
ohrstrom@1504 280 }
ohrstrom@1504 281 }
ohrstrom@1504 282
ohrstrom@1504 283 // A completed request has been received.
ohrstrom@1504 284
ohrstrom@1504 285 // Now setup the actual compilation....
ohrstrom@1504 286 // First deal with explicit source files on cmdline and in at file.
ohrstrom@1504 287 com.sun.tools.javac.util.ListBuffer<JavaFileObject> compilationUnits =
ohrstrom@1504 288 new com.sun.tools.javac.util.ListBuffer<JavaFileObject>();
ohrstrom@1504 289 for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(the_classes)) {
ohrstrom@1504 290 compilationUnits.append(i);
ohrstrom@1504 291 }
ohrstrom@1504 292 // Now deal with sources supplied as source_to_compile.
ohrstrom@1504 293 com.sun.tools.javac.util.ListBuffer<File> sourcesToCompileFiles =
ohrstrom@1504 294 new com.sun.tools.javac.util.ListBuffer<File>();
ohrstrom@1504 295 for (URI u : sourcesToCompile) {
ohrstrom@1504 296 sourcesToCompileFiles.append(new File(u));
ohrstrom@1504 297 }
ohrstrom@1504 298 for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(sourcesToCompileFiles)) {
ohrstrom@1504 299 compilationUnits.append(i);
ohrstrom@1504 300 }
ohrstrom@1504 301 // Log the options to be used.
ohrstrom@1504 302 StringBuilder options = new StringBuilder();
ohrstrom@1504 303 for (String s : the_options) {
ohrstrom@1504 304 options.append(">").append(s).append("< ");
ohrstrom@1504 305 }
ohrstrom@1504 306 javacServer.log(id+" <"+thisRequest+"> options "+options.toString());
ohrstrom@1504 307
ohrstrom@1504 308 forcedExitCode = 0;
ohrstrom@1504 309 // Create a new logger.
ohrstrom@1504 310 StringWriter stdoutLog = new StringWriter();
ohrstrom@1504 311 StringWriter stderrLog = new StringWriter();
ohrstrom@1504 312 stdout = new PrintWriter(stdoutLog);
ohrstrom@1504 313 stderr = new PrintWriter(stderrLog);
ohrstrom@1504 314 com.sun.tools.javac.main.Main.Result rc = com.sun.tools.javac.main.Main.Result.OK;
ohrstrom@1504 315 try {
ohrstrom@1504 316 if (compilationUnits.size() > 0) {
ohrstrom@1504 317 // Bind the new logger to the existing context.
ohrstrom@1504 318 context.put(Log.outKey, stderr);
ohrstrom@1504 319 Log.instance(context).setWriter(Log.WriterKind.NOTICE, stdout);
ohrstrom@1504 320 Log.instance(context).setWriter(Log.WriterKind.WARNING, stderr);
ohrstrom@1504 321 Log.instance(context).setWriter(Log.WriterKind.ERROR, stderr);
ohrstrom@1504 322 // Process the options.
ohrstrom@1504 323 com.sun.tools.javac.api.JavacTool.processOptions(context, smartFileManager, the_options);
ohrstrom@1504 324 fileManagerBase.setContext(context);
ohrstrom@1504 325 smartFileManager.setVisibleSources(visibleSources);
ohrstrom@1504 326 smartFileManager.cleanArtifacts();
ohrstrom@1504 327 smartFileManager.setLog(stdout);
ohrstrom@1504 328 Dependencies.instance(context).reset();
ohrstrom@1504 329
ohrstrom@1504 330 com.sun.tools.javac.main.Main ccompiler = new com.sun.tools.javac.main.Main("javacTask", stderr);
ohrstrom@1504 331 String[] aa = the_options.toArray(new String[0]);
ohrstrom@1504 332
ohrstrom@1504 333 // Do the compilation!
ohrstrom@1504 334 rc = ccompiler.compile(aa, context, compilationUnits.toList(), null);
ohrstrom@1504 335
ohrstrom@1504 336 while (numActiveSubTasks()>0) {
ohrstrom@1504 337 try { Thread.sleep(1000); } catch (InterruptedException e) { }
ohrstrom@1504 338 }
ohrstrom@1504 339
ohrstrom@1504 340 smartFileManager.flush();
ohrstrom@1504 341 }
ohrstrom@1504 342 } catch (Exception e) {
ohrstrom@1504 343 stderr.println(e.getMessage());
ohrstrom@1504 344 forcedExitCode = -1;
ohrstrom@1504 345 }
ohrstrom@1504 346
ohrstrom@1504 347 // Send the response..
ohrstrom@1504 348 out.println(JavacServer.PROTOCOL_STDOUT);
ohrstrom@1504 349 out.print(stdoutLog);
ohrstrom@1504 350 out.println(JavacServer.PROTOCOL_STDERR);
ohrstrom@1504 351 out.print(stderrLog);
ohrstrom@1504 352 // The compilation is complete! And errors will have already been printed on out!
ohrstrom@1504 353 out.println(JavacServer.PROTOCOL_PACKAGE_ARTIFACTS);
ohrstrom@1504 354 Map<String,Set<URI>> pa = smartFileManager.getPackageArtifacts();
ohrstrom@1504 355 for (String aPkgName : pa.keySet()) {
ohrstrom@1504 356 out.println("+"+aPkgName);
ohrstrom@1504 357 Set<URI> as = pa.get(aPkgName);
ohrstrom@1504 358 for (URI a : as) {
ohrstrom@1504 359 out.println(" "+a.toString());
ohrstrom@1504 360 }
ohrstrom@1504 361 }
ohrstrom@1504 362 Dependencies deps = Dependencies.instance(context);
ohrstrom@1504 363 out.println(JavacServer.PROTOCOL_PACKAGE_DEPENDENCIES);
ohrstrom@1504 364 Map<String,Set<String>> pd = deps.getDependencies();
ohrstrom@1504 365 for (String aPkgName : pd.keySet()) {
ohrstrom@1504 366 out.println("+"+aPkgName);
ohrstrom@1504 367 Set<String> ds = pd.get(aPkgName);
ohrstrom@1504 368 // Everything depends on java.lang
ohrstrom@1504 369 if (!ds.contains(":java.lang")) ds.add(":java.lang");
ohrstrom@1504 370 for (String d : ds) {
ohrstrom@1504 371 out.println(" "+d);
ohrstrom@1504 372 }
ohrstrom@1504 373 }
ohrstrom@1504 374 out.println(JavacServer.PROTOCOL_PACKAGE_PUBLIC_APIS);
ohrstrom@1504 375 Map<String,String> pp = deps.getPubapis();
ohrstrom@1504 376 for (String aPkgName : pp.keySet()) {
ohrstrom@1504 377 out.println("+"+aPkgName);
ohrstrom@1504 378 String ps = pp.get(aPkgName);
ohrstrom@1504 379 // getPubapis added a space to each line!
ohrstrom@1504 380 out.println(ps);
ohrstrom@1504 381 compiledPkgs.append(aPkgName+" ");
ohrstrom@1504 382 }
ohrstrom@1504 383 out.println(JavacServer.PROTOCOL_SYSINFO);
ohrstrom@1504 384 out.println("num_cores=" + Runtime.getRuntime().availableProcessors());
ohrstrom@1504 385 out.println("max_memory=" + Runtime.getRuntime().maxMemory());
ohrstrom@1504 386 out.println(JavacServer.PROTOCOL_RETURN_CODE);
ohrstrom@1504 387
ohrstrom@1504 388 // Errors from sjavac that affect compilation status!
ohrstrom@1504 389 int rcv = rc.exitCode;
ohrstrom@1504 390 if (rcv == 0 && forcedExitCode != 0) {
ohrstrom@1504 391 rcv = forcedExitCode;
ohrstrom@1504 392 }
ohrstrom@1504 393 out.println("" + rcv);
ohrstrom@1504 394 out.println(JavacServer.PROTOCOL_END);
ohrstrom@1504 395 out.flush();
ohrstrom@1504 396 } catch (IOException e) {
ohrstrom@1504 397 e.printStackTrace();
ohrstrom@1504 398 } finally {
ohrstrom@1504 399 try {
ohrstrom@1504 400 if (out != null) out.close();
ohrstrom@1504 401 if (!socket.isClosed()) {
ohrstrom@1504 402 socket.close();
ohrstrom@1504 403 }
ohrstrom@1504 404 socket = null;
ohrstrom@1504 405 } catch (Exception e) {
ohrstrom@1504 406 javacServer.log("ERROR "+e);
ohrstrom@1504 407 e.printStackTrace();
ohrstrom@1504 408 }
ohrstrom@1504 409 compilerPool.stopRequest();
ohrstrom@1504 410 long duration = System.currentTimeMillis()-start;
ohrstrom@1504 411 javacServer.addBuildTime(duration);
ohrstrom@1504 412 float classpersec = ((float)numClasses)*(((float)1000.0)/((float)duration));
ohrstrom@1504 413 javacServer.log(id+" <"+thisRequest+"> "+compiledPkgs+" duration " + duration+ " ms num_classes="+numClasses+
ohrstrom@1504 414 " classpersec="+classpersec+" subtasks="+subTasks.size());
ohrstrom@1504 415 javacServer.flushLog();
ohrstrom@1504 416 unuse();
ohrstrom@1504 417 compilerPool.returnCompilerThread(this);
ohrstrom@1504 418 }
ohrstrom@1504 419 }
ohrstrom@1504 420 }
ohrstrom@1504 421

mercurial