< prev index next >

src/hotspot/share/prims/whitebox.cpp

Print this page

@@ -1214,11 +1214,11 @@
   env->ReleaseStringUTFChars(name, flag_name);
   return (result == JVMFlag::SUCCESS);
 }
 
 template <typename T>
-static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::Error (*TAtPut)(JVMFlag* flag, T*, JVMFlag::Flags)) {
+static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T value, JVMFlag::Error (*TAtPut)(JVMFlag* flag, T, JVMFlag::Flags)) {
   if (name == NULL) {
     return false;
   }
   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
   const char* flag_name = env->GetStringUTFChars(name, NULL);

@@ -1361,46 +1361,46 @@
   return NULL;
 WB_END
 
 WB_ENTRY(void, WB_SetBooleanVMFlag(JNIEnv* env, jobject o, jstring name, jboolean value))
   bool result = value == JNI_TRUE ? true : false;
-  SetVMFlag <bool> (thread, env, name, &result, &JVMFlag::boolAtPut);
+  SetVMFlag <bool> (thread, env, name, result, &JVMFlag::boolAtPut);
 WB_END
 
 WB_ENTRY(void, WB_SetIntVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
   int result = value;
-  SetVMFlag <int> (thread, env, name, &result, &JVMFlag::intAtPut);
+  SetVMFlag <int> (thread, env, name, result, &JVMFlag::intAtPut);
 WB_END
 
 WB_ENTRY(void, WB_SetUintVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
   uint result = value;
-  SetVMFlag <uint> (thread, env, name, &result, &JVMFlag::uintAtPut);
+  SetVMFlag <uint> (thread, env, name, result, &JVMFlag::uintAtPut);
 WB_END
 
 WB_ENTRY(void, WB_SetIntxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
   intx result = value;
-  SetVMFlag <intx> (thread, env, name, &result, &JVMFlag::intxAtPut);
+  SetVMFlag <intx> (thread, env, name, result, &JVMFlag::intxAtPut);
 WB_END
 
 WB_ENTRY(void, WB_SetUintxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
   uintx result = value;
-  SetVMFlag <uintx> (thread, env, name, &result, &JVMFlag::uintxAtPut);
+  SetVMFlag <uintx> (thread, env, name, result, &JVMFlag::uintxAtPut);
 WB_END
 
 WB_ENTRY(void, WB_SetUint64VMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
   uint64_t result = value;
-  SetVMFlag <uint64_t> (thread, env, name, &result, &JVMFlag::uint64_tAtPut);
+  SetVMFlag <uint64_t> (thread, env, name, result, &JVMFlag::uint64_tAtPut);
 WB_END
 
 WB_ENTRY(void, WB_SetSizeTVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
   size_t result = value;
-  SetVMFlag <size_t> (thread, env, name, &result, &JVMFlag::size_tAtPut);
+  SetVMFlag <size_t> (thread, env, name, result, &JVMFlag::size_tAtPut);
 WB_END
 
 WB_ENTRY(void, WB_SetDoubleVMFlag(JNIEnv* env, jobject o, jstring name, jdouble value))
   double result = value;
-  SetVMFlag <double> (thread, env, name, &result, &JVMFlag::doubleAtPut);
+  SetVMFlag <double> (thread, env, name, result, &JVMFlag::doubleAtPut);
 WB_END
 
 WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring value))
   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
   const char* ccstrValue;

@@ -1410,14 +1410,22 @@
   else {
     ccstrValue = env->GetStringUTFChars(value, NULL);
     CHECK_JNI_EXCEPTION(env);
   }
   ccstr ccstrResult = ccstrValue;
-  bool needFree;
+  bool needFree = false;
   {
-    ThreadInVMfromNative ttvfn(thread); // back to VM
-    needFree = SetVMFlag <ccstr> (thread, env, name, &ccstrResult, &JVMFlag::ccstrAtPut);
+    if (name != NULL) {
+      const char* flag_name = env->GetStringUTFChars(name, NULL);
+      CHECK_JNI_EXCEPTION(env);
+      JVMFlag* flag = JVMFlag::find_flag(flag_name);
+      JVMFlag::Error result = JVMFlag::ccstrAtPut(flag, &ccstrResult, JVMFlag::INTERNAL);
+      env->ReleaseStringUTFChars(name, flag_name);
+      if (result == JVMFlag::SUCCESS) {
+        needFree = true;
+      }
+    }
   }
   if (value != NULL) {
     env->ReleaseStringUTFChars(value, ccstrValue);
   }
   if (needFree) {
< prev index next >