8259045: Exception message from saproc.dll is garbled on Windows with Japanese locale
Reviewed-by: erikj, cjplummer, iklam
This commit is contained in:
parent
28e1f4d9ee
commit
67c2211481
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
# Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
#
|
#
|
||||||
# This code is free software; you can redistribute it and/or modify it
|
# This code is free software; you can redistribute it and/or modify it
|
||||||
@ -35,7 +35,7 @@ else ifeq ($(call isTargetOs, macosx), true)
|
|||||||
-mstack-alignment=16 -fPIC
|
-mstack-alignment=16 -fPIC
|
||||||
LIBSA_EXTRA_SRC := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent
|
LIBSA_EXTRA_SRC := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent
|
||||||
else ifeq ($(call isTargetOs, windows), true)
|
else ifeq ($(call isTargetOs, windows), true)
|
||||||
SA_CFLAGS := -D_WINDOWS -D_DEBUG -D_CONSOLE -D_MBCS -EHsc
|
SA_CFLAGS := -D_WINDOWS -D_DEBUG -D_CONSOLE -EHsc
|
||||||
ifeq ($(call isTargetCpu, x86_64), true)
|
ifeq ($(call isTargetCpu, x86_64), true)
|
||||||
SA_CXXFLAGS := -DWIN64
|
SA_CXXFLAGS := -DWIN64
|
||||||
else
|
else
|
||||||
@ -65,12 +65,13 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBSA, \
|
|||||||
CFLAGS := $(CFLAGS_JDKLIB) $(SA_CFLAGS), \
|
CFLAGS := $(CFLAGS_JDKLIB) $(SA_CFLAGS), \
|
||||||
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(SA_CFLAGS) $(SA_CXXFLAGS), \
|
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(SA_CFLAGS) $(SA_CXXFLAGS), \
|
||||||
EXTRA_SRC := $(LIBSA_EXTRA_SRC), \
|
EXTRA_SRC := $(LIBSA_EXTRA_SRC), \
|
||||||
LDFLAGS := $(LDFLAGS_JDKLIB), \
|
LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \
|
||||||
LIBS := $(LIBCXX), \
|
LIBS := $(LIBCXX), \
|
||||||
|
LIBS_unix := -ljava, \
|
||||||
LIBS_linux := $(LIBDL), \
|
LIBS_linux := $(LIBDL), \
|
||||||
LIBS_macosx := -framework Foundation -framework JavaNativeFoundation \
|
LIBS_macosx := -framework Foundation -framework JavaNativeFoundation \
|
||||||
-framework JavaRuntimeSupport -framework Security -framework CoreFoundation, \
|
-framework JavaRuntimeSupport -framework Security -framework CoreFoundation, \
|
||||||
LIBS_windows := dbgeng.lib, \
|
LIBS_windows := dbgeng.lib $(WIN_JAVA_LIB), \
|
||||||
))
|
))
|
||||||
|
|
||||||
TARGETS += $(BUILD_LIBSA)
|
TARGETS += $(BUILD_LIBSA)
|
||||||
|
@ -70,42 +70,8 @@
|
|||||||
#define JVM_MAXPATHLEN MAXPATHLEN
|
#define JVM_MAXPATHLEN MAXPATHLEN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "jni_util.h"
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
|
||||||
static int getLastErrorString(char *buf, size_t len)
|
|
||||||
{
|
|
||||||
long errval;
|
|
||||||
|
|
||||||
if ((errval = GetLastError()) != 0)
|
|
||||||
{
|
|
||||||
/* DOS error */
|
|
||||||
size_t n = (size_t)FormatMessage(
|
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
NULL,
|
|
||||||
errval,
|
|
||||||
0,
|
|
||||||
buf,
|
|
||||||
(DWORD)len,
|
|
||||||
NULL);
|
|
||||||
if (n > 3) {
|
|
||||||
/* Drop final '.', CR, LF */
|
|
||||||
if (buf[n - 1] == '\n') n--;
|
|
||||||
if (buf[n - 1] == '\r') n--;
|
|
||||||
if (buf[n - 1] == '.') n--;
|
|
||||||
buf[n] = '\0';
|
|
||||||
}
|
|
||||||
return (int)n;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errno != 0)
|
|
||||||
{
|
|
||||||
/* C runtime error that has no corresponding DOS error code */
|
|
||||||
strerror_s(buf, len, errno);
|
|
||||||
return strlen(buf);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* _WINDOWS */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: sun_jvm_hotspot_asm_Disassembler
|
* Class: sun_jvm_hotspot_asm_Disassembler
|
||||||
@ -157,13 +123,13 @@ JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_asm_Disassembler_load_1library(JNIE
|
|||||||
/* Couldn't find entry point. error_message should contain some
|
/* Couldn't find entry point. error_message should contain some
|
||||||
* platform dependent error message.
|
* platform dependent error message.
|
||||||
*/
|
*/
|
||||||
jclass eclass = (*env)->FindClass(env, "sun/jvm/hotspot/debugger/DebuggerException");
|
jstring s = JNU_NewStringPlatform(env, error_message);
|
||||||
if ((*env)->ExceptionOccurred(env)) {
|
if (s != NULL) {
|
||||||
/* Can't throw exception, probably OOM, so silently return 0 */
|
jobject x = JNU_NewObjectByName(env, "sun/jvm/hotspot/debugger/DebuggerException", "(Ljava/lang/String;)V", s);
|
||||||
return (jlong) 0;
|
if (x != NULL) {
|
||||||
|
(*env)->Throw(env, x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(*env)->ThrowNew(env, eclass, error_message);
|
|
||||||
}
|
}
|
||||||
return (jlong)func;
|
return (jlong)func;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user