8273188: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails with "FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed"

Reviewed-by: dholmes, alanb
This commit is contained in:
Naoto Sato 2021-09-09 19:41:56 +00:00
parent 4020a60cbb
commit 54dee132d1
8 changed files with 20 additions and 31 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2021, 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
@ -36,4 +36,4 @@ void convertUtf8ToModifiedUtf8(char* utf8_str, int utf8_len, char* mutf8_str, in
/**
* Convert UTF-8 to a platform string
*/
int convertUft8ToPlatformString(char* utf8_str, int utf8_len, char* platform_str, int platform_len);
int convertUtf8ToPlatformString(char* utf8_str, int utf8_len, char* platform_str, int platform_len);

View File

@ -831,7 +831,7 @@ appendClassPath( JPLISAgent* agent,
* converted it is then normalized (remove duplicate slashes, etc.).
* If the resulting path is an absolute path (starts with a slash for
* example) then the path will be added to the bootclasspath. Otherwise
* if it's not absolute then we get the canoncial path of the agent jar
* if it's not absolute then we get the canonical path of the agent jar
* file and then resolve the path in the context of the base path of
* the agent jar.
*/
@ -899,7 +899,7 @@ appendBootClassPath( JPLISAgent* agent,
*/
{
char platform[MAXPATHLEN];
int new_len = convertUft8ToPlatformString(path, len, platform, MAXPATHLEN);
int new_len = convertUtf8ToPlatformString(path, len, platform, MAXPATHLEN);
free(path);
if (new_len < 0) {
/* bogus value - exceeds maximum path size or unable to convert */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, 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
@ -1483,7 +1483,7 @@ appendToClassLoaderSearch(JNIEnv * jnienv, JPLISAgent * agent, jstring jarFile,
* JVMTI spec'ed to use modified UTF8. At this time this is not implemented
* the platform encoding is used.
*/
platformLen = convertUft8ToPlatformString((char*)utf8Chars, utf8Len, platformChars, MAXPATHLEN);
platformLen = convertUtf8ToPlatformString((char*)utf8Chars, utf8Len, platformChars, MAXPATHLEN);
if (platformLen < 0) {
createAndThrowInternalError(jnienv);
(*jnienv)->ReleaseStringUTFChars(jnienv, jarFile, utf8Chars);

View File

@ -60,6 +60,7 @@ utfInitialize(void)
{
const char* codeset;
#ifndef MACOSX
/* Set the locale from the environment */
(void)setlocale(LC_ALL, "");
@ -69,23 +70,13 @@ utfInitialize(void)
UTF_DEBUG(("NO codeset returned by nl_langinfo(CODESET)\n"));
return;
}
#else /* MACOSX */
/* On Mac, platform string (i.e., sun.jnu.encoding value) is always UTF-8 */
codeset = "UTF-8";
#endif
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"));
@ -161,7 +152,7 @@ utf8ToPlatform(char *utf8, int len, char *output, int outputMaxLen)
}
int
convertUft8ToPlatformString(char* utf8_str, int utf8_len, char* platform_str, int platform_len) {
convertUtf8ToPlatformString(char* utf8_str, int utf8_len, char* platform_str, int platform_len) {
if (iconvToPlatform == (iconv_t)-1) {
utfInitialize();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2021, 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
@ -31,7 +31,7 @@
* Convert UTF-8 to a platform string
*/
int
convertUft8ToPlatformString(char* utf8_str, int utf8_len, char* platform_str, int platform_len) {
convertUtf8ToPlatformString(char* utf8_str, int utf8_len, char* platform_str, int platform_len) {
LANGID langID;
LCID localeID;
TCHAR strCodePage[7]; // ANSI code page id

View File

@ -564,8 +564,6 @@ java/lang/invoke/RicochetTest.java 8251969 generic-
java/lang/instrument/RedefineBigClass.sh 8065756 generic-all
java/lang/instrument/RetransformBigClass.sh 8065756 generic-all
java/lang/instrument/BootClassPath/BootClassPathTest.sh 8273188 generic-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, 2018, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2004, 2021, 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
@ -22,7 +22,7 @@
#
# @test
# @bug 5055293
# @bug 5055293 8273188
# @summary Test non US-ASCII characters in the value of the Boot-Class-Path
# attribute.
#

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2021, 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
@ -94,7 +94,7 @@ public class Setup {
*/
f = new File(workDir + fileSeparator + "boot.dir");
try (FileOutputStream out = new FileOutputStream(f)) {
out.write(bootDir.getBytes(defaultEncoding));
out.write(bootDir.getBytes(filePathEncoding));
}
}
@ -102,7 +102,7 @@ public class Setup {
private static final String fileSeparator = System.getProperty("file.separator");
private static final String osName = System.getProperty("os.name");
private static final String defaultEncoding = Charset.defaultCharset().name();
private static final String filePathEncoding = System.getProperty("sun.jnu.encoding");
// language names taken from java.util.Locale.getDisplayLanguage for the respective language
private static final String arabic = "\u0627\u0644\u0639\u0631\u0628\u064a\u0629";
@ -174,7 +174,7 @@ public class Setup {
column = 1;
}
for (int i = 0; i < names.length; i++) {
if (names[i][0].equalsIgnoreCase(defaultEncoding)) {
if (names[i][0].equalsIgnoreCase(filePathEncoding)) {
return names[i][column];
}
}