public static void finish() { if (!makeThunk) { Record.finish(); if (monitor) monitorThread.finish(); setExecStatus("done", false); outputMap.printEasy(getFile("output.map")); StopWatch.getStats().printEasy(getFile("time.map")); if (create) stderr.println(virtualExecDir); if (LogInfo.getNumErrors() > 0 || LogInfo.getNumWarnings() > 0) stderr.printf("%d errors, %d warnings\n", LogInfo.getNumErrors(), LogInfo.getNumWarnings()); if (startMainTrack) end_track(); } System.exit(exitCode); }
// This should be all we need to put in a main function. // args are the commandline arguments // First object is the Runnable object to call run on. // All of them are objects whose options args is to supposed to populate. public static void run(String[] args, Object... objects) { init(args, objects); if (makeThunk) { setExecStatus("thunk", true); printOutputMap(Execution.getFile("output.map")); List<String> cmd = new ArrayList(); cmd.add("java"); if (thunkJavaOpts != null) cmd.add(thunkJavaOpts); cmd.add("-cp " + StrUtils.join(jarFiles, ":") + ":" + System.getProperty("java.class.path")); cmd.addAll( ListUtils.newList( objects[0].getClass().getName(), "++" + virtualExecDir, // Load these options // Next time when we run, just run in the same path that we used to create the thunk "-execDir", virtualExecDir, "-overwriteExecDir")); IOUtils.printLinesHard( Execution.getFile("job.map"), ListUtils.newList( "workingDir\t" + SysInfoUtils.getcwd(), // Run from current directory "command\t" + StrUtils.join(cmd, "\t"), "priority\t" + thunkPriority)); } else { if (dontCatchExceptions) { ((Runnable) objects[0]).run(); } else { try { ((Runnable) objects[0]).run(); } catch (Throwable t) { raiseException(t); } } } finish(); }