-
Bug
-
Resolution: Fixed
-
P3
-
9
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
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