public void run() {
List< String > args = new ArrayList< String >();
int res = -1;
try {
String line = null;
try {
line = in.readLine();
} catch (IOException e) {
System.err.println(e.getLocalizedMessage());
System.exit(0);
line = null;
}
// fm.cwd=null;
String cwd = null;
while (line != null) {
if (line.startsWith("PWD:")) {
cwd = line.substring(4);
} else if (line.equals("END")) {
break;
} else if (!"-XDstdout".equals(line)) {
args.add(line);
}
try {
line = in.readLine();
} catch (IOException e) {
System.err.println(e.getLocalizedMessage());
System.exit(0);
line = null;
}
}
Iterable< File > path = cwd == null ? null : Arrays.< File >asList(new File(cwd));
// try { in.close(); } catch (IOException e) {}
long msec = System.currentTimeMillis();
try {
synchronized (tool) {
for (StandardLocation location : StandardLocation.values())
fm.setLocation(location, path);
res = compile(out, fm, args);
// FIXME res = tool.run((InputStream)null, null, out, args.toArray(new String[args.size()]));
}
} catch (Throwable ex) {
logger.log(java.util.logging.Level.SEVERE, args.toString(), ex);
PrintWriter p = new PrintWriter(out, true);
ex.printStackTrace(p);
p.flush();
}
if (res >= 3) {
logger.severe(String.format("problem: %s", args));
} else {
logger.info(String.format("success: %s", args));
}
// res = compile(args.toArray(new String[args.size()]), out);
msec -= System.currentTimeMillis();
logger.info(String.format("Real time: %sms", -msec));
} finally {
if (!isSocket) {
try { in.close(); } catch (IOException e) {}
}
try {
out.write(String.format("EXIT: %s%n", res).getBytes());
} catch (IOException ex) {
logger.log(java.util.logging.Level.SEVERE, args.toString(), ex);
}
try {
out.flush();
out.close();
} catch (IOException ex) {
logger.log(java.util.logging.Level.SEVERE, args.toString(), ex);
}
logger.info(String.format("EXIT: %s", res));
}
}
|