src/hotspot/share/classfile/javaClasses.cpp
changeset 58555 7252d89e3a4e
parent 58493 55a8d95c7787
child 58664 e3618c902d17
--- a/src/hotspot/share/classfile/javaClasses.cpp	Fri Oct 11 17:49:25 2019 +0800
+++ b/src/hotspot/share/classfile/javaClasses.cpp	Fri Oct 11 08:49:42 2019 -0400
@@ -384,13 +384,17 @@
   }
 
   jstring js = NULL;
-  { JavaThread* thread = (JavaThread*)THREAD;
-    assert(thread->is_Java_thread(), "must be java thread");
+  {
+    assert(THREAD->is_Java_thread(), "must be java thread");
+    JavaThread* thread = (JavaThread*)THREAD;
     HandleMark hm(thread);
     ThreadToNativeFromVM ttn(thread);
     js = (_to_java_string_fn)(thread->jni_environment(), str);
   }
-  return Handle(THREAD, JNIHandles::resolve(js));
+
+  Handle native_platform_string(THREAD, JNIHandles::resolve(js));
+  JNIHandles::destroy_local(js);  // destroy local JNIHandle.
+  return native_platform_string;
 }
 
 // Converts a Java String to a native C string that can be used for