jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java
changeset 41966 bac52fa6e617
parent 40261 86a49ba76f52
child 42338 a60f280f803c
child 42178 cb5cb430e207
equal deleted inserted replaced
41965:015dea372cb3 41966:bac52fa6e617
     1 /*
     1 /*
     2  * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   137      * stackSize: in bytes, as set by the launcher, a zero-value indicates
   137      * stackSize: in bytes, as set by the launcher, a zero-value indicates
   138      *    this code determine this value, using a suitable method or omit the
   138      *    this code determine this value, using a suitable method or omit the
   139      *    line entirely.
   139      *    line entirely.
   140      */
   140      */
   141     static void showSettings(boolean printToStderr, String optionFlag,
   141     static void showSettings(boolean printToStderr, String optionFlag,
   142             long initialHeapSize, long maxHeapSize, long stackSize,
   142             long initialHeapSize, long maxHeapSize, long stackSize) {
   143             boolean isServer) {
       
   144 
   143 
   145         initOutput(printToStderr);
   144         initOutput(printToStderr);
   146         String opts[] = optionFlag.split(":");
   145         String opts[] = optionFlag.split(":");
   147         String optStr = (opts.length > 1 && opts[1] != null)
   146         String optStr = (opts.length > 1 && opts[1] != null)
   148                 ? opts[1].trim()
   147                 ? opts[1].trim()
   149                 : "all";
   148                 : "all";
   150         switch (optStr) {
   149         switch (optStr) {
   151             case "vm":
   150             case "vm":
   152                 printVmSettings(initialHeapSize, maxHeapSize,
   151                 printVmSettings(initialHeapSize, maxHeapSize, stackSize);
   153                                 stackSize, isServer);
       
   154                 break;
   152                 break;
   155             case "properties":
   153             case "properties":
   156                 printProperties();
   154                 printProperties();
   157                 break;
   155                 break;
   158             case "locale":
   156             case "locale":
   159                 printLocale();
   157                 printLocale();
   160                 break;
   158                 break;
   161             default:
   159             default:
   162                 printVmSettings(initialHeapSize, maxHeapSize, stackSize,
   160                 printVmSettings(initialHeapSize, maxHeapSize, stackSize);
   163                                 isServer);
       
   164                 printProperties();
   161                 printProperties();
   165                 printLocale();
   162                 printLocale();
   166                 break;
   163                 break;
   167         }
   164         }
   168     }
   165     }
   170     /*
   167     /*
   171      * prints the main vm settings subopt/section
   168      * prints the main vm settings subopt/section
   172      */
   169      */
   173     private static void printVmSettings(
   170     private static void printVmSettings(
   174             long initialHeapSize, long maxHeapSize,
   171             long initialHeapSize, long maxHeapSize,
   175             long stackSize, boolean isServer) {
   172             long stackSize) {
   176 
   173 
   177         ostream.println(VM_SETTINGS);
   174         ostream.println(VM_SETTINGS);
   178         if (stackSize != 0L) {
   175         if (stackSize != 0L) {
   179             ostream.println(INDENT + "Stack Size: " +
   176             ostream.println(INDENT + "Stack Size: " +
   180                     SizePrefix.scaleValue(stackSize));
   177                     SizePrefix.scaleValue(stackSize));
   188                     SizePrefix.scaleValue(maxHeapSize));
   185                     SizePrefix.scaleValue(maxHeapSize));
   189         } else {
   186         } else {
   190             ostream.println(INDENT + "Max. Heap Size (Estimated): "
   187             ostream.println(INDENT + "Max. Heap Size (Estimated): "
   191                     + SizePrefix.scaleValue(Runtime.getRuntime().maxMemory()));
   188                     + SizePrefix.scaleValue(Runtime.getRuntime().maxMemory()));
   192         }
   189         }
   193         ostream.println(INDENT + "Ergonomics Machine Class: "
       
   194                 + ((isServer) ? "server" : "client"));
       
   195         ostream.println(INDENT + "Using VM: "
   190         ostream.println(INDENT + "Using VM: "
   196                 + System.getProperty("java.vm.name"));
   191                 + System.getProperty("java.vm.name"));
   197         ostream.println();
   192         ostream.println();
   198     }
   193     }
   199 
   194 
   374      * initHelpSystem must be called before using this method.
   369      * initHelpSystem must be called before using this method.
   375      */
   370      */
   376     static void appendVmSynonymMessage(String vm1, String vm2) {
   371     static void appendVmSynonymMessage(String vm1, String vm2) {
   377         outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.hotspot",
   372         outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.hotspot",
   378                 vm1, vm2));
   373                 vm1, vm2));
   379     }
       
   380 
       
   381     /**
       
   382      * Appends the vm Ergo message to the header, already created.
       
   383      * initHelpSystem must be called before using this method.
       
   384      */
       
   385     static void appendVmErgoMessage(boolean isServerClass, String vm) {
       
   386         outBuf = outBuf.append(getLocalizedMessage("java.launcher.ergo.message1",
       
   387                 vm));
       
   388         outBuf = (isServerClass) ? outBuf.append(",\n")
       
   389                 .append(getLocalizedMessage("java.launcher.ergo.message2"))
       
   390                 .append("\n\n") : outBuf.append(".\n\n");
       
   391     }
   374     }
   392 
   375 
   393     /**
   376     /**
   394      * Appends the last invariant part to the previously created messages,
   377      * Appends the last invariant part to the previously created messages,
   395      * and finishes up the printing to the desired output stream.
   378      * and finishes up the printing to the desired output stream.