@@ -34,9 +34,6 @@ public final class DesignerStarter {
3434
3535 private static final int MIN_JAVAFX_VERSION_ON_MAC_OSX = 14 ;
3636
37- private static final int ERROR_EXIT = 1 ;
38- private static final int OK = 0 ;
39-
4037 private DesignerStarter () {
4138 }
4239
@@ -61,7 +58,7 @@ private static MainCliArgs readParameters(String[] argv) {
6158
6259 if (argsObj .help ) {
6360 System .out .println (getHelpText (jCommander ));
64- System .exit (OK );
61+ System .exit (ExitStatus . OK . getCode () );
6562 }
6663
6764 return argsObj ;
@@ -70,7 +67,7 @@ private static MainCliArgs readParameters(String[] argv) {
7067 System .out .println (e .getMessage ());
7168 System .out .println ();
7269 System .out .println (getHelpText (jCommander ));
73- System .exit (OK );
70+ System .exit (ExitStatus . OK . getCode () );
7471 throw new AssertionError ();
7572 }
7673
@@ -81,14 +78,13 @@ private static MainCliArgs readParameters(String[] argv) {
8178 * Starting from PMD 7.0.0 this method usage will be limited for development.
8279 * CLI support will be provided by pmd-cli
8380 */
84- @ Deprecated
8581 @ InternalApi
8682 public static void main (String [] args ) {
8783
8884 readParameters (args );
8985
90- final int ret = launchGui (args );
91- System .exit (ret );
86+ final ExitStatus ret = launchGui (args );
87+ System .exit (ret . getCode () );
9288 }
9389
9490 private static void setSystemProperties () {
@@ -148,7 +144,7 @@ private static String getHelpText(JCommander jCommander) {
148144 }
149145
150146 @ SuppressWarnings ("PMD.AvoidCatchingThrowable" )
151- public static int launchGui (String [] args ) {
147+ public static ExitStatus launchGui (String [] args ) {
152148 setSystemProperties ();
153149
154150 String message = null ;
@@ -161,16 +157,31 @@ public static int launchGui(String[] args) {
161157 if (message != null ) {
162158 System .err .println (message );
163159 JOptionPane .showMessageDialog (null , message );
164- return ERROR_EXIT ;
160+ return ExitStatus . ERROR ;
165161 }
166162
167163 try {
168164 Application .launch (Designer .class , args );
169165 } catch (Throwable unrecoverable ) {
170166 unrecoverable .printStackTrace ();
171- return ERROR_EXIT ;
167+ return ExitStatus . ERROR ;
172168 }
173169
174- return OK ;
170+ return ExitStatus .OK ;
171+ }
172+
173+ public enum ExitStatus {
174+ OK (0 ),
175+ ERROR (1 );
176+
177+ private final int code ;
178+
179+ ExitStatus (final int code ) {
180+ this .code = code ;
181+ }
182+
183+ public int getCode () {
184+ return code ;
185+ }
175186 }
176187}
0 commit comments