From 265a0f5547d0ddb220391aef679c122768f02a00 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Thu, 20 Jun 2024 17:01:17 +0000 Subject: [PATCH] 8334490: Normalize string with locale invariant `toLowerCase()` Reviewed-by: jlu, dfuchs, lancea, rriggs --- test/lib/jdk/test/lib/Platform.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/lib/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java index e2451fc8366..4a4b164cd17 100644 --- a/test/lib/jdk/test/lib/Platform.java +++ b/test/lib/jdk/test/lib/Platform.java @@ -35,6 +35,7 @@ import java.security.PrivilegedAction; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static java.util.Locale.ROOT; public class Platform { public static final String vmName = privilegedGetProperty("java.vm.name"); @@ -134,7 +135,7 @@ public class Platform { } private static boolean isOs(String osname) { - return osName.toLowerCase().startsWith(osname.toLowerCase()); + return osName.toLowerCase(ROOT).startsWith(osname.toLowerCase(ROOT)); } public static String getOsName() { @@ -175,15 +176,15 @@ public class Platform { } public static boolean isDebugBuild() { - return (jdkDebug.toLowerCase().contains("debug")); + return (jdkDebug.toLowerCase(ROOT).contains("debug")); } public static boolean isSlowDebugBuild() { - return (jdkDebug.toLowerCase().equals("slowdebug")); + return (jdkDebug.toLowerCase(ROOT).equals("slowdebug")); } public static boolean isFastDebugBuild() { - return (jdkDebug.toLowerCase().equals("fastdebug")); + return (jdkDebug.toLowerCase(ROOT).equals("fastdebug")); } public static String getVMVersion() { @@ -350,8 +351,8 @@ public class Platform { } public static boolean isOracleLinux7() { - if (System.getProperty("os.name").toLowerCase().contains("linux") && - System.getProperty("os.version").toLowerCase().contains("el")) { + if (System.getProperty("os.name").toLowerCase(ROOT).contains("linux") && + System.getProperty("os.version").toLowerCase(ROOT).contains("el")) { Pattern p = Pattern.compile("el(\\d+)"); Matcher m = p.matcher(System.getProperty("os.version")); if (m.find()) {