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

Print this page




 572             return; // Avoid compiler issues
 573         }
 574 
 575         /*
 576          * getMethod (above) will choose the correct method, based
 577          * on its name and parameter type, however, we still have to
 578          * ensure that the method is static and returns a void.
 579          */
 580         int mod = mainMethod.getModifiers();
 581         if (!Modifier.isStatic(mod)) {
 582             abort(null, "java.launcher.cls.error2", "static",
 583                   mainMethod.getDeclaringClass().getName());
 584         }
 585         if (mainMethod.getReturnType() != java.lang.Void.TYPE) {
 586             abort(null, "java.launcher.cls.error3",
 587                   mainMethod.getDeclaringClass().getName());
 588         }
 589     }
 590 
 591     private static final String encprop = "sun.jnu.encoding";

 592     private static String encoding = null;
 593     private static boolean isCharsetSupported = false;
 594 
 595     /*
 596      * converts a c or a byte array to a platform specific string,
 597      * previously implemented as a native method in the launcher.
 598      */
 599     static String makePlatformString(boolean printToStderr, byte[] inArray) {
 600         initOutput(printToStderr);
 601         if (encoding == null) {






 602             encoding = System.getProperty(encprop);




 603             isCharsetSupported = Charset.isSupported(encoding);
 604         }
 605         try {
 606             String out = isCharsetSupported
 607                     ? new String(inArray, encoding)
 608                     : new String(inArray);
 609             return out;
 610         } catch (UnsupportedEncodingException uee) {
 611             abort(uee, null);
 612         }
 613         return null; // keep the compiler happy
 614     }
 615 
 616     static String[] expandArgs(String[] argArray) {
 617         List<StdArg> aList = new ArrayList<>();
 618         for (String x : argArray) {
 619             aList.add(new StdArg(x));
 620         }
 621         return expandArgs(aList);
 622     }




 572             return; // Avoid compiler issues
 573         }
 574 
 575         /*
 576          * getMethod (above) will choose the correct method, based
 577          * on its name and parameter type, however, we still have to
 578          * ensure that the method is static and returns a void.
 579          */
 580         int mod = mainMethod.getModifiers();
 581         if (!Modifier.isStatic(mod)) {
 582             abort(null, "java.launcher.cls.error2", "static",
 583                   mainMethod.getDeclaringClass().getName());
 584         }
 585         if (mainMethod.getReturnType() != java.lang.Void.TYPE) {
 586             abort(null, "java.launcher.cls.error3",
 587                   mainMethod.getDeclaringClass().getName());
 588         }
 589     }
 590 
 591     private static final String encprop = "sun.jnu.encoding";
 592     private static final String encprop_unicode = "file.encoding.unicode";
 593     private static String encoding = null;
 594     private static boolean isCharsetSupported = false;
 595 
 596     /*
 597      * converts a c or a byte array to a platform specific string,
 598      * previously implemented as a native method in the launcher.
 599      */
 600     static String makePlatformString(boolean printToStderr, byte[] inArray) {
 601         initOutput(printToStderr);
 602         if (encoding == null) {
 603             if (Boolean.getBoolean("windows.UnicodeConsole")) {
 604                 encoding = System.getProperty(encprop_unicode);
 605                 if (encoding == null || !Charset.isSupported(encoding)) {
 606                     encoding = Charset.defaultUnicodeCharset().name();
 607                 }
 608                 if (!Charset.isSupported(encoding)) {
 609                     encoding = System.getProperty(encprop);
 610                 }
 611             } else {
 612                 encoding = System.getProperty(encprop);
 613             }
 614             isCharsetSupported = Charset.isSupported(encoding);
 615         }
 616         try {
 617             String out = isCharsetSupported
 618                     ? new String(inArray, encoding)
 619                     : new String(inArray);
 620             return out;
 621         } catch (UnsupportedEncodingException uee) {
 622             abort(uee, null);
 623         }
 624         return null; // keep the compiler happy
 625     }
 626 
 627     static String[] expandArgs(String[] argArray) {
 628         List<StdArg> aList = new ArrayList<>();
 629         for (String x : argArray) {
 630             aList.add(new StdArg(x));
 631         }
 632         return expandArgs(aList);
 633     }