8303485: Replacing os.name for operating system customization

Reviewed-by: naoto, erikj, alanb
This commit is contained in:
Roger Riggs 2023-03-27 17:45:20 +00:00
parent 87b314a985
commit 6c3b10fb1d
13 changed files with 371 additions and 114 deletions

View file

@ -77,6 +77,7 @@ import java.util.jar.Manifest;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import jdk.internal.util.OperatingSystem;
import jdk.internal.misc.VM;
import jdk.internal.module.ModuleBootstrap;
import jdk.internal.module.Modules;
@ -168,7 +169,7 @@ public final class LauncherHelper {
printLocale();
break;
case "system":
if (System.getProperty("os.name").contains("Linux")) {
if (OperatingSystem.isLinux()) {
printSystemMetrics();
break;
}
@ -176,7 +177,7 @@ public final class LauncherHelper {
printVmSettings(initialHeapSize, maxHeapSize, stackSize);
printProperties();
printLocale();
if (System.getProperty("os.name").contains("Linux")) {
if (OperatingSystem.isLinux()) {
printSystemMetrics();
}
break;
@ -532,7 +533,7 @@ public final class LauncherHelper {
initOutput(printToStderr);
ostream.println(getLocalizedMessage("java.launcher.X.usage",
File.pathSeparator));
if (System.getProperty("os.name").contains("OS X")) {
if (OperatingSystem.isMacOS()) {
ostream.println(getLocalizedMessage("java.launcher.X.macosx.usage",
File.pathSeparator));
}
@ -745,7 +746,7 @@ public final class LauncherHelper {
Class<?> c = null;
try {
c = Class.forName(m, mainClass);
if (c == null && System.getProperty("os.name", "").contains("OS X")
if (c == null && OperatingSystem.isMacOS()
&& Normalizer.isNormalized(mainClass, Normalizer.Form.NFD)) {
String cn = Normalizer.normalize(mainClass, Normalizer.Form.NFC);
@ -789,7 +790,7 @@ public final class LauncherHelper {
try {
mainClass = Class.forName(cn, false, scl);
} catch (NoClassDefFoundError | ClassNotFoundException cnfe) {
if (System.getProperty("os.name", "").contains("OS X")
if (OperatingSystem.isMacOS()
&& Normalizer.isNormalized(cn, Normalizer.Form.NFD)) {
try {
// On Mac OS X since all names with diacritical marks are

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -30,7 +30,7 @@ import java.io.FileDescriptor;
import jdk.internal.access.SharedSecrets;
import jdk.internal.access.JavaIOFileDescriptorAccess;
import sun.security.action.GetPropertyAction;
import jdk.internal.util.OperatingSystem;
/**
@ -39,8 +39,7 @@ import sun.security.action.GetPropertyAction;
*/
public final class SdpSupport {
private static final String os = GetPropertyAction.privilegedGetProperty("os.name");
private static final boolean isSupported = os.equals("Linux");
private static final boolean isSupported = OperatingSystem.isLinux();
private static final JavaIOFileDescriptorAccess fdAccess =
SharedSecrets.getJavaIOFileDescriptorAccess();