# HG changeset patch # User shade # Date 1509012971 -7200 # Node ID 6d0f710dc36f7347bcd438190d772bcdfafdcdd9 # Parent 659166b70dd9a56bb1756480600c40b2211d2378 Do not fail with -h diff -r 659166b70dd9 -r 6d0f710dc36f src/main/java/org/openjdk/gcbench/GCBench.java --- a/src/main/java/org/openjdk/gcbench/GCBench.java Thu Oct 26 12:11:17 2017 +0200 +++ b/src/main/java/org/openjdk/gcbench/GCBench.java Thu Oct 26 12:16:11 2017 +0200 @@ -25,11 +25,15 @@ private List tests; public static void main(String... args) throws RunnerException, IOException { - GCBench bench = new GCBench(args); - bench.run(); + try { + GCBench bench = new GCBench(args); + bench.run(); + } catch (HelpPrintException e) { + // do nothing + } } - public GCBench(String[] args) throws RunnerException, IOException { + public GCBench(String[] args) throws RunnerException, IOException, HelpPrintException { pw = new PrintWriter(System.out, true); pw.println("GC Benchmarks Suite"); @@ -86,7 +90,7 @@ OptionSet set = parser.parse(args); if (set.has("h")) { parser.printHelpOn(System.out); - return; + throw new HelpPrintException(); } final int MIN_THREADS = set.valueOf(optMinThreads); @@ -379,6 +383,7 @@ public void run() throws RunnerException { pw.println(" Available tests: "); + pw.println(tests); for (Test test : tests) { pw.printf(" %-20s %n", test.label()); } @@ -401,4 +406,6 @@ } } + private class HelpPrintException extends Throwable { + } }