changeset 56771:3fc5905f2bec

8232724: Remove indirection with calling JNU_NewStringPlatform Reviewed-by: dholmes, clanger
author aivanov
date Wed, 30 Oct 2019 14:08:07 +0000
parents 75099fcf7962
children 506bd2e1f840
files src/hotspot/share/classfile/javaClasses.cpp src/hotspot/share/include/jvm.h src/java.base/share/native/libjava/jni_util.c src/java.base/share/native/libjava/jni_util.h
diffstat 4 files changed, 11 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/javaClasses.cpp	Wed Oct 30 09:42:59 2019 -0400
+++ b/src/hotspot/share/classfile/javaClasses.cpp	Wed Oct 30 14:08:07 2019 +0000
@@ -387,14 +387,20 @@
 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");
     }
   }
 
--- a/src/hotspot/share/include/jvm.h	Wed Oct 30 09:42:59 2019 -0400
+++ b/src/hotspot/share/include/jvm.h	Wed Oct 30 14:08:07 2019 +0000
@@ -1073,13 +1073,6 @@
     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 | \
--- a/src/java.base/share/native/libjava/jni_util.c	Wed Oct 30 09:42:59 2019 -0400
+++ b/src/java.base/share/native/libjava/jni_util.c	Wed Oct 30 14:08:07 2019 +0000
@@ -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 @@
     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)
 {
--- a/src/java.base/share/native/libjava/jni_util.h	Wed Oct 30 09:42:59 2019 -0400
+++ b/src/java.base/share/native/libjava/jni_util.h	Wed Oct 30 14:08:07 2019 +0000
@@ -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 @@
 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);