< prev index next >

src/java.base/share/classes/sun/launcher/LauncherHelper.java

Print this page




 804                 sc = sc.getSuperclass()) {
 805             if (sc.getName().equals(JAVAFX_APPLICATION_CLASS_NAME)) {
 806                 return true;
 807             }
 808         }
 809         return false;
 810     }
 811 
 812     // Check the existence and signature of main and abort if incorrect
 813     static void validateMainClass(Class<?> mainClass) {
 814         Method mainMethod = null;
 815         try {
 816             mainMethod = mainClass.getMethod("main", String[].class);
 817         } catch (NoSuchMethodException nsme) {
 818             // invalid main or not FX application, abort with an error
 819             abort(null, "java.launcher.cls.error4", mainClass.getName(),
 820                   JAVAFX_APPLICATION_CLASS_NAME);
 821         } catch (Throwable e) {
 822             if (mainClass.getModule().isNamed()) {
 823                 abort(e, "java.launcher.module.error5",
 824                       mainClass.getName(), mainClass.getModule().getName(),
 825                       e.getClass().getName(), e.getLocalizedMessage());
 826             } else {
 827                 abort(e, "java.launcher.cls.error7", mainClass.getName(),
 828                       e.getClass().getName(), e.getLocalizedMessage());
 829             }
 830         }
 831 
 832         /*
 833          * getMethod (above) will choose the correct method, based
 834          * on its name and parameter type, however, we still have to
 835          * ensure that the method is static and returns a void.
 836          */
 837         int mod = mainMethod.getModifiers();
 838         if (!Modifier.isStatic(mod)) {
 839             abort(null, "java.launcher.cls.error2", "static",
 840                   mainMethod.getDeclaringClass().getName());
 841         }
 842         if (mainMethod.getReturnType() != java.lang.Void.TYPE) {
 843             abort(null, "java.launcher.cls.error3",
 844                   mainMethod.getDeclaringClass().getName());




 804                 sc = sc.getSuperclass()) {
 805             if (sc.getName().equals(JAVAFX_APPLICATION_CLASS_NAME)) {
 806                 return true;
 807             }
 808         }
 809         return false;
 810     }
 811 
 812     // Check the existence and signature of main and abort if incorrect
 813     static void validateMainClass(Class<?> mainClass) {
 814         Method mainMethod = null;
 815         try {
 816             mainMethod = mainClass.getMethod("main", String[].class);
 817         } catch (NoSuchMethodException nsme) {
 818             // invalid main or not FX application, abort with an error
 819             abort(null, "java.launcher.cls.error4", mainClass.getName(),
 820                   JAVAFX_APPLICATION_CLASS_NAME);
 821         } catch (Throwable e) {
 822             if (mainClass.getModule().isNamed()) {
 823                 abort(e, "java.launcher.module.error5",
 824                       mainClass.getName(), mainClass.getModule(),
 825                       e.getClass().getName(), e.getLocalizedMessage());
 826             } else {
 827                 abort(e, "java.launcher.cls.error7", mainClass.getName(),
 828                       e.getClass().getName(), e.getLocalizedMessage());
 829             }
 830         }
 831 
 832         /*
 833          * getMethod (above) will choose the correct method, based
 834          * on its name and parameter type, however, we still have to
 835          * ensure that the method is static and returns a void.
 836          */
 837         int mod = mainMethod.getModifiers();
 838         if (!Modifier.isStatic(mod)) {
 839             abort(null, "java.launcher.cls.error2", "static",
 840                   mainMethod.getDeclaringClass().getName());
 841         }
 842         if (mainMethod.getReturnType() != java.lang.Void.TYPE) {
 843             abort(null, "java.launcher.cls.error3",
 844                   mainMethod.getDeclaringClass().getName());


< prev index next >