public static void main(String... args) throws Exception { jtreg = (System.getProperty("test.src") != null); File tmpDir; if (jtreg) { // use standard jtreg scratch directory: the current directory tmpDir = new File(System.getProperty("user.dir")); } else { tmpDir = new File( System.getProperty("java.io.tmpdir"), MessageInfo.class.getName() + (new SimpleDateFormat("yyMMddHHmmss")).format(new Date())); } Example.setTempDir(tmpDir); Example.Compiler.factory = new ArgTypeCompilerFactory(); MessageInfo mi = new MessageInfo(); try { if (mi.run(args)) return; } finally { /* VERY IMPORTANT NOTE. In jtreg mode, tmpDir is set to the * jtreg scratch directory, which is the current directory. * In case someone is faking jtreg mode, make sure to only * clean tmpDir when it is reasonable to do so. */ if (tmpDir.isDirectory() && tmpDir.getName().startsWith(MessageInfo.class.getName())) { if (clean(tmpDir)) tmpDir.delete(); } } if (jtreg) throw new Exception(mi.errors + " errors occurred"); else System.exit(1); }