8072130: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails on Mac OSX

Reviewed-by: sherman
This commit is contained in:
Brent Christian 2018-09-24 10:41:41 -07:00
parent 73e93bdd5d
commit 3910193204
5 changed files with 36 additions and 10 deletions

View File

@ -348,8 +348,14 @@ static int ParseLocale(JNIEnv* env, int cat, char ** std_language, char ** std_s
* file to correctly read UTF-8 files using the default encoding (see
* 8011194).
*/
if (strcmp(p,"US-ASCII") == 0 && getenv("LANG") == NULL &&
getenv("LC_ALL") == NULL && getenv("LC_CTYPE") == NULL) {
const char* env_lang = getenv("LANG");
const char* env_lc_all = getenv("LC_ALL");
const char* env_lc_ctype = getenv("LC_CTYPE");
if (strcmp(p,"US-ASCII") == 0 &&
(env_lang == NULL || strlen(env_lang) == 0) &&
(env_lc_all == NULL || strlen(env_lc_all) == 0) &&
(env_lc_ctype == NULL || strlen(env_lc_ctype) == 0)) {
*std_encoding = "UTF-8";
}
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2018, 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
@ -63,7 +63,7 @@ utfError(char *file, int line, char *message)
static void
utfInitialize(void)
{
char *codeset;
const char* codeset;
/* Set the locale from the environment */
(void)setlocale(LC_ALL, "");
@ -77,6 +77,20 @@ utfInitialize(void)
UTF_DEBUG(("Codeset = %s\n", codeset));
#ifdef MACOSX
/* On Mac, if US-ASCII, but with no env hints, use UTF-8 */
const char* env_lang = getenv("LANG");
const char* env_lc_all = getenv("LC_ALL");
const char* env_lc_ctype = getenv("LC_CTYPE");
if (strcmp(codeset,"US-ASCII") == 0 &&
(env_lang == NULL || strlen(env_lang) == 0) &&
(env_lc_all == NULL || strlen(env_lc_all) == 0) &&
(env_lc_ctype == NULL || strlen(env_lc_ctype) == 0)) {
codeset = "UTF-8";
}
#endif
/* If we don't need this, skip it */
if (strcmp(codeset, "UTF-8") == 0 || strcmp(codeset, "utf8") == 0 ) {
UTF_DEBUG(("NO iconv() being used because it is not needed\n"));
@ -146,6 +160,7 @@ iconvConvert(iconv_t ic, char *bytes, int len, char *output, int outputMaxLen)
}
/* Failed to do the conversion */
UTF_DEBUG(("iconv() failed to do the conversion\n"));
return -1;
}

View File

@ -517,8 +517,6 @@ java/lang/StringCoding/CheckEncodings.sh 7008363 generic-
java/lang/instrument/RedefineBigClass.sh 8065756 generic-all
java/lang/instrument/RetransformBigClass.sh 8065756 generic-all
java/lang/instrument/BootClassPath/BootClassPathTest.sh 8072130 macosx-all
java/lang/management/MemoryMXBean/Pending.java 8158837 generic-all
java/lang/management/MemoryMXBean/PendingAllGC.sh 8158837 generic-all

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004, 2018, 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
@ -90,6 +90,6 @@ echo "Cleanup..."
"$JAVAC" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d "${TESTCLASSES}" \
"${TESTSRC}"/Cleanup.java
"$JAVA" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" Cleanup "${BOOTDIR}"
"$JAVA" ${TESTVMOPTS} -classpath "${TESTCLASSES}" Cleanup "${BOOTDIR}"
exit $result

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2018, 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
@ -27,7 +27,7 @@
* Used by BootClassPath.sh.
*
* Given a "work directory" this class creates a sub-directory with a
* name that uses locale specific characters. It the creates a jar
* name that uses locale specific characters. It then creates a jar
* manifest file in the work directory with a Boot-Class-Path that
* encodes the created sub-directory. Finally it creates a file
* "boot.dir" in the work directory with the name of the sub-directory.
@ -51,6 +51,13 @@ public class Setup {
String bootDir = workDir + fileSeparator + bootClassPath;
/*
* Environment variable settings ("null" if unset)
*/
System.out.println("Env vars:");
System.out.println(" LANG=" + System.getenv("LANG"));
System.out.println(" LC_ALL=" + System.getenv("LC_ALL"));
System.out.println(" LC_CTYPE=" + System.getenv("LC_CTYPE"));
/*
* Create sub-directory