diff --git a/make/modules/jdk.jdwp.agent/Lib.gmk b/make/modules/jdk.jdwp.agent/Lib.gmk
index b49284c020e..aef358c14bd 100644
--- a/make/modules/jdk.jdwp.agent/Lib.gmk
+++ b/make/modules/jdk.jdwp.agent/Lib.gmk
@@ -64,7 +64,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJDWP, \
     LIBS_linux := $(LIBDL), \
     LIBS_macosx := -liconv, \
     LIBS_aix := -liconv, \
-    LIBS_windows := $(WIN_JAVA_LIB), \
 ))
 
 $(BUILD_LIBJDWP): $(call FindLib, java.base, java)
diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/transport.c b/src/jdk.jdwp.agent/share/native/libjdwp/transport.c
index 757fec4d88b..3f3c0942303 100644
--- a/src/jdk.jdwp.agent/share/native/libjdwp/transport.c
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/transport.c
@@ -77,10 +77,10 @@ printLastError(jdwpTransportEnv *t, jdwpTransportError err)
 
         /* Convert this string to UTF8 */
         len = (int)strlen(msg);
-        maxlen = len+len/2+2; /* Should allow for plenty of room */
-        utf8msg = (jbyte*)jvmtiAllocate(maxlen+1);
+        maxlen = len * 4 + 1;
+        utf8msg = (jbyte*)jvmtiAllocate(maxlen);
         if (utf8msg != NULL) {
-           (void)utf8FromPlatform(msg, len, utf8msg, maxlen+1);
+           (void)utf8FromPlatform(msg, len, utf8msg, maxlen);
         }
     }
     if (rv == JDWPTRANSPORT_ERROR_NONE) {
diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/util.c b/src/jdk.jdwp.agent/share/native/libjdwp/util.c
index 5f7962b92af..2f73f33cbbc 100644
--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.c
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.c
@@ -26,6 +26,7 @@
 #include <ctype.h>
 
 #include "util.h"
+#include "utf_util.h"
 #include "transport.h"
 #include "eventHandler.h"
 #include "threadControl.h"
@@ -1652,13 +1653,26 @@ setAgentPropertyValue(JNIEnv *env, char *propertyName, char* propertyValue)
     /* Create jstrings for property name and value */
     nameString = JNI_FUNC_PTR(env,NewStringUTF)(env, propertyName);
     if (nameString != NULL) {
-        valueString = JNU_NewStringPlatform(env, propertyValue);
-        if (valueString != NULL) {
-            /* invoke Properties.setProperty */
-            JNI_FUNC_PTR(env,CallObjectMethod)
-                (env, gdata->agent_properties,
-                 gdata->setProperty,
-                 nameString, valueString);
+        /* convert the value to UTF8 */
+        int len;
+        char *utf8value;
+        int utf8maxSize;
+
+        len = (int)strlen(propertyValue);
+        utf8maxSize = len * 4 + 1;
+        utf8value = (char *)jvmtiAllocate(utf8maxSize);
+        if (utf8value != NULL) {
+            utf8FromPlatform(propertyValue, len, (jbyte *)utf8value, utf8maxSize);
+            valueString = JNI_FUNC_PTR(env, NewStringUTF)(env, utf8value);
+            jvmtiDeallocate(utf8value);
+
+            if (valueString != NULL) {
+                /* invoke Properties.setProperty */
+                JNI_FUNC_PTR(env,CallObjectMethod)
+                    (env, gdata->agent_properties,
+                     gdata->setProperty,
+                     nameString, valueString);
+            }
         }
     }
     if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {