--- old/src/java.base/share/classes/sun/launcher/LauncherHelper.java 2019-12-20 15:39:30.534643265 +0100 +++ new/src/java.base/share/classes/sun/launcher/LauncherHelper.java 2019-12-20 15:39:30.278642584 +0100 @@ -45,10 +45,10 @@ import java.io.UnsupportedEncodingException; import java.lang.module.Configuration; import java.lang.module.ModuleDescriptor; -import java.lang.module.ModuleDescriptor.Requires; import java.lang.module.ModuleDescriptor.Exports; import java.lang.module.ModuleDescriptor.Opens; import java.lang.module.ModuleDescriptor.Provides; +import java.lang.module.ModuleDescriptor.Requires; import java.lang.module.ModuleFinder; import java.lang.module.ModuleReference; import java.lang.module.ResolvedModule; @@ -62,8 +62,8 @@ import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; -import java.text.Normalizer; import java.text.MessageFormat; +import java.text.Normalizer; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -325,89 +325,126 @@ ostream.println(INDENT + "Provider: " + c.getProvider()); ostream.println(INDENT + "Effective CPU Count: " + c.getEffectiveCpuCount()); - ostream.println(INDENT + "CPU Period: " + c.getCpuPeriod() + - (c.getCpuPeriod() == -1 ? "" : "us")); - ostream.println(INDENT + "CPU Quota: " + c.getCpuQuota() + - (c.getCpuQuota() == -1 ? "" : "us")); - ostream.println(INDENT + "CPU Shares: " + c.getCpuShares()); + ostream.println(formatCpuVal(c.getCpuPeriod(), INDENT + "CPU Period: ")); + ostream.println(formatCpuVal(c.getCpuQuota(), INDENT + "CPU Quota: ")); + ostream.println(formatCpuVal(c.getCpuShares(), INDENT + "CPU Shares: ")); int cpus[] = c.getCpuSetCpus(); - ostream.println(INDENT + "List of Processors, " - + cpus.length + " total: "); - - ostream.print(INDENT); - for (int i = 0; i < cpus.length; i++) { - ostream.print(cpus[i] + " "); - } - if (cpus.length > 0) { - ostream.println(""); + if (cpus != null) { + ostream.println(INDENT + "List of Processors, " + + cpus.length + " total: "); + + ostream.print(INDENT); + for (int i = 0; i < cpus.length; i++) { + ostream.print(cpus[i] + " "); + } + if (cpus.length > 0) { + ostream.println(""); + } + } else { + ostream.println(INDENT + "List of Processors: N/A"); } cpus = c.getEffectiveCpuSetCpus(); - ostream.println(INDENT + "List of Effective Processors, " - + cpus.length + " total: "); - - ostream.print(INDENT); - for (int i = 0; i < cpus.length; i++) { - ostream.print(cpus[i] + " "); - } - if (cpus.length > 0) { - ostream.println(""); + if (cpus != null) { + ostream.println(INDENT + "List of Effective Processors, " + + cpus.length + " total: "); + + ostream.print(INDENT); + for (int i = 0; i < cpus.length; i++) { + ostream.print(cpus[i] + " "); + } + if (cpus.length > 0) { + ostream.println(""); + } + } else { + ostream.println(INDENT + "List of Effective Processors: N/A"); } int mems[] = c.getCpuSetMems(); - ostream.println(INDENT + "List of Memory Nodes, " - + mems.length + " total: "); - - ostream.print(INDENT); - for (int i = 0; i < mems.length; i++) { - ostream.print(mems[i] + " "); - } - if (mems.length > 0) { - ostream.println(""); + if (mems != null) { + ostream.println(INDENT + "List of Memory Nodes, " + + mems.length + " total: "); + + ostream.print(INDENT); + for (int i = 0; i < mems.length; i++) { + ostream.print(mems[i] + " "); + } + if (mems.length > 0) { + ostream.println(""); + } + } else { + ostream.println(INDENT + "List of Memory Nodes: N/A"); } mems = c.getEffectiveCpuSetMems(); - ostream.println(INDENT + "List of Available Memory Nodes, " - + mems.length + " total: "); - - ostream.print(INDENT); - for (int i = 0; i < mems.length; i++) { - ostream.print(mems[i] + " "); - } - if (mems.length > 0) { - ostream.println(""); + if (mems != null) { + ostream.println(INDENT + "List of Available Memory Nodes, " + + mems.length + " total: "); + + ostream.print(INDENT); + for (int i = 0; i < mems.length; i++) { + ostream.print(mems[i] + " "); + } + if (mems.length > 0) { + ostream.println(""); + } + } else { + ostream.println(INDENT + "List of Available Memory Nodes: N/A"); } - ostream.println(INDENT + "CPUSet Memory Pressure Enabled: " - + c.isCpuSetMemoryPressureEnabled()); + ostream.println(formatBoolean(c.isCpuSetMemoryPressureEnabled(), + INDENT + "CPUSet Memory Pressure Enabled: ")); long limit = c.getMemoryLimit(); - ostream.println(INDENT + "Memory Limit: " + - ((limit >= 0) ? SizePrefix.scaleValue(limit) : "Unlimited")); + ostream.println(formatLimitString(limit, INDENT + "Memory Limit: ")); limit = c.getMemorySoftLimit(); - ostream.println(INDENT + "Memory Soft Limit: " + - ((limit >= 0) ? SizePrefix.scaleValue(limit) : "Unlimited")); + ostream.println(formatLimitString(limit, INDENT + "Memory Soft Limit: ")); limit = c.getMemoryAndSwapLimit(); - ostream.println(INDENT + "Memory & Swap Limit: " + - ((limit >= 0) ? SizePrefix.scaleValue(limit) : "Unlimited")); + ostream.println(formatLimitString(limit, INDENT + "Memory & Swap Limit: ")); limit = c.getKernelMemoryLimit(); - ostream.println(INDENT + "Kernel Memory Limit: " + - ((limit >= 0) ? SizePrefix.scaleValue(limit) : "Unlimited")); + ostream.println(formatLimitString(limit, INDENT + "Kernel Memory Limit: ")); limit = c.getTcpMemoryLimit(); - ostream.println(INDENT + "TCP Memory Limit: " + - ((limit >= 0) ? SizePrefix.scaleValue(limit) : "Unlimited")); + ostream.println(formatLimitString(limit, INDENT + "TCP Memory Limit: ")); - ostream.println(INDENT + "Out Of Memory Killer Enabled: " - + c.isMemoryOOMKillEnabled()); + ostream.println(formatBoolean(c.isMemoryOOMKillEnabled(), + INDENT + "Out Of Memory Killer Enabled: ")); ostream.println(""); } + private static String formatLimitString(long limit, String prefix) { + if (limit >= 0) { + return prefix + SizePrefix.scaleValue(limit); + } else if (limit == Metrics.LONG_RETVAL_NOT_SUPPORTED) { + return prefix + "N/A"; + } else { + return prefix + "Unlimited"; + } + } + + private static String formatCpuVal(long cpuVal, String prefix) { + if (cpuVal >= 0) { + return prefix + cpuVal + "us"; + } else if (cpuVal == Metrics.LONG_RETVAL_NOT_SUPPORTED) { + return prefix + "N/A"; + } else { + return prefix + cpuVal; + } + } + + private static String formatBoolean(Boolean value, String prefix) { + if (value == Metrics.BOOL_RETVAL_NOT_SUPPORTED) { + return prefix + "N/A"; + } else { + return prefix + value; + } + } + private enum SizePrefix { KILO(1024, "K"),