< prev index next >

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

Print this page




 567     private static Class<?> loadMainClass(int mode, String what) {
 568         // get the class name
 569         String cn;
 570         switch (mode) {
 571             case LM_CLASS:
 572                 cn = what;
 573                 break;
 574             case LM_JAR:
 575                 cn = getMainClassFromJar(what);
 576                 break;
 577             default:
 578                 // should never happen
 579                 throw new InternalError("" + mode + ": Unknown launch mode");
 580         }
 581 
 582         // load the main class
 583         cn = cn.replace('/', '.');
 584         Class<?> mainClass = null;
 585         ClassLoader scl = ClassLoader.getSystemClassLoader();
 586         try {
 587             mainClass = scl.loadClass(cn);
 588         } catch (NoClassDefFoundError | ClassNotFoundException cnfe) {
 589             if (System.getProperty("os.name", "").contains("OS X")
 590                     && Normalizer.isNormalized(cn, Normalizer.Form.NFD)) {
 591                 try {
 592                     // On Mac OS X since all names with diacretic symbols are given as decomposed it
 593                     // is possible that main class name comes incorrectly from the command line
 594                     // and we have to re-compose it
 595                     mainClass = scl.loadClass(Normalizer.normalize(cn, Normalizer.Form.NFC));


 596                 } catch (NoClassDefFoundError | ClassNotFoundException cnfe1) {
 597                     abort(cnfe, "java.launcher.cls.error1", cn);
 598                 }
 599             } else {
 600                 abort(cnfe, "java.launcher.cls.error1", cn);
 601             }
 602         }
 603 
 604         // record the main class
 605         appClass = mainClass;
 606 
 607         /*
 608          * Check if FXHelper can launch it using the FX launcher. In an FX app,
 609          * the main class may or may not have a main method, so do this before
 610          * validating the main class.
 611          */
 612         if (JAVAFX_FXHELPER_CLASS_NAME_SUFFIX.equals(mainClass.getName()) ||
 613             doesExtendFXApplication(mainClass)) {
 614             // Will abort() if there are problems with FX runtime
 615             FXHelper.setFXLaunchParameters(what, mode);




 567     private static Class<?> loadMainClass(int mode, String what) {
 568         // get the class name
 569         String cn;
 570         switch (mode) {
 571             case LM_CLASS:
 572                 cn = what;
 573                 break;
 574             case LM_JAR:
 575                 cn = getMainClassFromJar(what);
 576                 break;
 577             default:
 578                 // should never happen
 579                 throw new InternalError("" + mode + ": Unknown launch mode");
 580         }
 581 
 582         // load the main class
 583         cn = cn.replace('/', '.');
 584         Class<?> mainClass = null;
 585         ClassLoader scl = ClassLoader.getSystemClassLoader();
 586         try {
 587             mainClass = Class.forName(cn, false, scl);
 588         } catch (NoClassDefFoundError | ClassNotFoundException cnfe) {
 589             if (System.getProperty("os.name", "").contains("OS X")
 590                     && Normalizer.isNormalized(cn, Normalizer.Form.NFD)) {
 591                 try {
 592                     // On Mac OS X since all names with diacretic symbols are
 593                     // given as decomposed it is possible that main class name
 594                     // comes incorrectly from the command line and we have
 595                     // to re-compose it
 596                     String ncn = Normalizer.normalize(cn, Normalizer.Form.NFC);
 597                     mainClass = Class.forName(ncn, false, scl);
 598                 } catch (NoClassDefFoundError | ClassNotFoundException cnfe1) {
 599                     abort(cnfe, "java.launcher.cls.error1", cn);
 600                 }
 601             } else {
 602                 abort(cnfe, "java.launcher.cls.error1", cn);
 603             }
 604         }
 605 
 606         // record the main class
 607         appClass = mainClass;
 608 
 609         /*
 610          * Check if FXHelper can launch it using the FX launcher. In an FX app,
 611          * the main class may or may not have a main method, so do this before
 612          * validating the main class.
 613          */
 614         if (JAVAFX_FXHELPER_CLASS_NAME_SUFFIX.equals(mainClass.getName()) ||
 615             doesExtendFXApplication(mainClass)) {
 616             // Will abort() if there are problems with FX runtime
 617             FXHelper.setFXLaunchParameters(what, mode);


< prev index next >