changeset 84:6d0f710dc36f

Do not fail with -h
author shade
date Thu, 26 Oct 2017 12:16:11 +0200
parents 659166b70dd9
children 71b2baff8548
files src/main/java/org/openjdk/gcbench/GCBench.java
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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<Test> 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 {
+    }
 }