/** * Launch the appropriate UI. * * @throws java.lang.Exception */ public void launch() throws Exception { // Sanity-check the loaded BCEL classes if (!CheckBcel.check()) { System.exit(1); } int launchProperty = getLaunchProperty(); if (GraphicsEnvironment.isHeadless() || launchProperty == TEXTUI) { FindBugs2.main(args); } else if (launchProperty == SHOW_HELP) { ShowHelp.main(args); } else if (launchProperty == SHOW_VERSION) { Version.main(new String[] { "-release" }); } else { Class<?> launchClass = Class.forName("edu.umd.cs.findbugs.gui2.Driver"); Method mainMethod = launchClass.getMethod("main", args.getClass()); mainMethod.invoke(null, (Object) args); } }
/** * Run findbugs on the provided directory. If findbugs fails, the first found bug is printed out as xml. */ private static void runFindbugs(File classDir) throws Exception { ClassLoader classLoader = HollowCodeGenerationCompileUtil.class.getClassLoader(); FindBugs2.main(new String[]{"-auxclasspath", System.getProperty(PROPERTY_CLASSPATH), "-output", classLoader.getResource("").getFile() + FILENAME_FINDBUGS, classDir.getAbsolutePath()}); BufferedReader reader = new BufferedReader(new InputStreamReader(classLoader.getResourceAsStream(FILENAME_FINDBUGS))); String line = ""; String foundBug = null; while ((line = reader.readLine()) != null) { // poor man's xml parser if (line.contains("<BugInstance")) { foundBug = line; } else if (foundBug != null) { foundBug += "\n" + line; } if (line.contains("</BugInstance>")) { throw new Exception("Findbugs found an error:\n" + foundBug); } } }
/** * Launch the appropriate UI. * * @throws java.lang.Exception */ public void launch() throws Exception { // Sanity-check the loaded BCEL classes if (!CheckBcel.check()) { System.exit(1); } int launchProperty = getLaunchProperty(); if (GraphicsEnvironment.isHeadless() || launchProperty == TEXTUI) { FindBugs2.main(args); } else if (launchProperty == SHOW_HELP) { ShowHelp.main(args); } else if (launchProperty == SHOW_VERSION) { Version.main(new String[] { "-release" }); } else { Class<?> launchClass = Class.forName("edu.umd.cs.findbugs.gui2.Driver"); Method mainMethod = launchClass.getMethod("main", args.getClass()); mainMethod.invoke(null, (Object) args); } }