sjavac Main class should be more API/test friendly

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 9
    • Affects Version/s: 9
    • Component/s: tools

      sjavac.Main.main continues non-trivial work and two calls of System.exit().

      It is better practice to structure such code into a method (often called run) which does the same work but instead of calling System.exit, simply returns an exit code and/or throws exceptions instead. In other words, code is better structured as

      void main(String... args) {
          Main m = new Main();
          try {
              int rc = m.run(args);
              System.exit(rc);
          } catch (Exception e) {
              System.exit(ERROR);
          }
      }

      This makes it much easier to write test programns which can call the run method without having to worry about it calling System.exit

            Assignee:
            Andreas Lundblad (Inactive)
            Reporter:
            Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: