8321373: Build should use LC_ALL=C.UTF-8

Reviewed-by: redestad, erikj
This commit is contained in:
Magnus Ihse Bursie 2024-02-05 14:06:16 +00:00
parent 51671c0b92
commit d395ac2879
4 changed files with 26 additions and 6 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2024, 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
@ -123,6 +123,22 @@ AC_DEFUN_ONCE([BASIC_SETUP_BUILD_ENV],
]
)
AC_SUBST(BUILD_ENV)
if test "x$LOCALE" != x; then
# Check if we actually have C.UTF-8; if so, use it
if $LOCALE -a | $GREP -q -E "^C\.(utf8|UTF-8)$"; then
LOCALE_USED=C.UTF-8
else
AC_MSG_WARN([C.UTF-8 locale not found, using C locale])
LOCALE_USED=C
fi
else
AC_MSG_WARN([locale command not not found, using C locale])
LOCALE_USED=C
fi
export LC_ALL=$LOCALE_USED
AC_SUBST(LOCALE_USED)
])
###############################################################################

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2024, 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
@ -54,6 +54,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS],
UTIL_REQUIRE_SPECIAL(SED, [AC_PROG_SED])
# Tools only needed on some platforms
UTIL_LOOKUP_PROGS(LOCALE, locale)
UTIL_LOOKUP_PROGS(PATHTOOL, cygpath wslpath)
UTIL_LOOKUP_PROGS(CMD, cmd.exe, $PATH:/cygdrive/c/windows/system32:/mnt/c/windows/system32:/c/windows/system32)
])

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2024, 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
@ -56,8 +56,8 @@ COMMA := ,
# What make to use for main processing, after bootstrapping top-level Makefile.
MAKE := @MAKE@
# Make sure all shell commands are executed with the C locale
export LC_ALL := C
# Make sure all shell commands are executed with a proper locale
export LC_ALL := @LOCALE_USED@
# Make sure we override any local CLASSPATH variable
export CLASSPATH := @CLASSPATH@

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2024, 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
@ -35,6 +35,7 @@ import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.net.InetAddress;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.time.LocalDateTime;
import java.time.ZoneId;
@ -132,6 +133,8 @@ public class HelloClasslist {
String oldDate = String.format("%s%n",
DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.ROOT)
.format(new Date()));
StandardCharsets.US_ASCII.encode("");
StandardCharsets.UTF_8.encode("");
// A selection of trivial and common reflection operations
var instance = HelloClasslist.class.getConstructor().newInstance();