8232724: Remove indirection with calling JNU_NewStringPlatform

Reviewed-by: dholmes, clanger
This commit is contained in:
Alexey Ivanov 2019-10-30 14:08:07 +00:00
parent c786ef3418
commit c7acea028c
4 changed files with 11 additions and 22 deletions

View File

@ -387,14 +387,20 @@ Handle java_lang_String::create_from_symbol(Symbol* symbol, TRAPS) {
Handle java_lang_String::create_from_platform_dependent_str(const char* str, TRAPS) {
assert(str != NULL, "bad arguments");
typedef jstring (*to_java_string_fn_t)(JNIEnv*, const char *);
typedef jstring (JNICALL *to_java_string_fn_t)(JNIEnv*, const char *);
static to_java_string_fn_t _to_java_string_fn = NULL;
if (_to_java_string_fn == NULL) {
void *lib_handle = os::native_java_library();
_to_java_string_fn = CAST_TO_FN_PTR(to_java_string_fn_t, os::dll_lookup(lib_handle, "NewStringPlatform"));
_to_java_string_fn = CAST_TO_FN_PTR(to_java_string_fn_t, os::dll_lookup(lib_handle, "JNU_NewStringPlatform"));
#if defined(_WIN32) && !defined(_WIN64)
if (_to_java_string_fn == NULL) {
fatal("NewStringPlatform missing");
// On 32 bit Windows, also try __stdcall decorated name
_to_java_string_fn = CAST_TO_FN_PTR(to_java_string_fn_t, os::dll_lookup(lib_handle, "_JNU_NewStringPlatform@8"));
}
#endif
if (_to_java_string_fn == NULL) {
fatal("JNU_NewStringPlatform missing");
}
}

View File

@ -1073,13 +1073,6 @@ typedef struct {
method_size_info main; /* used everywhere else */
} class_size_info;
/*
* Functions defined in libjava.so to perform string conversions.
*
*/
typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str);
#define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \
JVM_ACC_FINAL | \
JVM_ACC_SUPER | \

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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
@ -791,13 +791,6 @@ InitializeEncoding(JNIEnv *env, const char *encname)
CHECK_NULL(String_value_ID);
}
// This alias is used for compatibility with 32 bit Windows
JNIEXPORT jstring
NewStringPlatform(JNIEnv *env, const char *str)
{
return JNU_NewStringPlatform(env, str);
}
JNIEXPORT jstring JNICALL
JNU_NewStringPlatform(JNIEnv *env, const char *str)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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
@ -93,9 +93,6 @@ JNIEXPORT void JNICALL
JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail);
/* Convert between Java strings and i18n C strings */
JNIEXPORT jstring
NewStringPlatform(JNIEnv *env, const char *str);
JNIEXPORT const char *
GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);