6698625: InetAddress.getLocalHost() failed in returning chinese local host name
Summary: Remove unnecessary and incorrect NewStringUTF
Reviewed-by: michaelm
--- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c Tue Jun 10 11:03:23 2008 +0800
+++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c Thu Jun 12 17:25:37 2008 +0100
@@ -138,7 +138,6 @@
Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jstring host) {
const char *hostname;
- jobject name;
jobjectArray ret = 0;
struct hostent res, *hp = 0;
char buf[HENT_BUF_SIZE];
@@ -210,12 +209,6 @@
addrp++;
}
- name = (*env)->NewStringUTF(env, hostname);
-
- if (IS_NULL(name)) {
- goto cleanupAndReturn;
- }
-
ret = (*env)->NewObjectArray(env, i, ni_iacls, NULL);
if (IS_NULL(ret)) {
/* we may have memory to free at the end of this */
@@ -231,7 +224,7 @@
}
(*env)->SetIntField(env, iaObj, ni_iaaddressID,
ntohl((*addrp)->s_addr));
- (*env)->SetObjectField(env, iaObj, ni_iahostID, name);
+ (*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, i, iaObj);
addrp++;
i++;
--- a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c Tue Jun 10 11:03:23 2008 +0800
+++ b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c Thu Jun 12 17:25:37 2008 +0100
@@ -142,7 +142,6 @@
jstring host) {
const char *hostname;
jobjectArray ret = 0;
- jobject name;
int retLen = 0;
jclass byteArrayCls;
jboolean preferIPv6Address;
@@ -310,11 +309,6 @@
inet6Index = inetCount;
}
- name = (*env)->NewStringUTF(env, hostname);
- if (IS_NULL(name)) {
- ret = NULL;
- goto cleanupAndReturn;
- }
while (iterator != NULL) {
if (iterator->ai_family == AF_INET) {
jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID);
@@ -324,7 +318,7 @@
}
(*env)->SetIntField(env, iaObj, ni_iaaddressID,
ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
- (*env)->SetObjectField(env, iaObj, ni_iahostID, name);
+ (*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inetIndex, iaObj);
inetIndex++;
} else if (iterator->ai_family == AF_INET6) {
@@ -355,7 +349,7 @@
(*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
}
(*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
- (*env)->SetObjectField(env, iaObj, ni_iahostID, name);
+ (*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inet6Index, iaObj);
inet6Index++;
}
--- a/jdk/src/windows/native/java/net/Inet4AddressImpl.c Tue Jun 10 11:03:23 2008 +0800
+++ b/jdk/src/windows/native/java/net/Inet4AddressImpl.c Thu Jun 12 17:25:37 2008 +0100
@@ -137,7 +137,6 @@
Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jstring host) {
const char *hostname;
- jobject name;
struct hostent *hp;
unsigned int addr[4];
@@ -229,10 +228,6 @@
addrp++;
}
- name = (*env)->NewStringUTF(env, hostname);
- if (IS_NULL(name)) {
- goto cleanupAndReturn;
- }
ret = (*env)->NewObjectArray(env, i, ni_iacls, NULL);
if (IS_NULL(ret)) {
@@ -249,7 +244,7 @@
}
(*env)->SetIntField(env, iaObj, ni_iaaddressID,
ntohl((*addrp)->s_addr));
- (*env)->SetObjectField(env, iaObj, ni_iahostID, name);
+ (*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, i, iaObj);
addrp++;
i++;
--- a/jdk/src/windows/native/java/net/Inet6AddressImpl.c Tue Jun 10 11:03:23 2008 +0800
+++ b/jdk/src/windows/native/java/net/Inet6AddressImpl.c Thu Jun 12 17:25:37 2008 +0100
@@ -86,7 +86,6 @@
Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jstring host) {
const char *hostname;
- jobject name;
jobjectArray ret = 0;
int retLen = 0;
jboolean preferIPv6Address;
@@ -237,12 +236,6 @@
inet6Index = inetCount;
}
- name = (*env)->NewStringUTF(env, hostname);
- if (IS_NULL(name)) {
- ret = NULL;
- goto cleanupAndReturn;
- }
-
while (iterator != NULL) {
if (iterator->ai_family == AF_INET) {
jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID);
@@ -252,7 +245,7 @@
}
(*env)->SetIntField(env, iaObj, ni_iaaddressID,
ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
- (*env)->SetObjectField(env, iaObj, ni_iahostID, name);
+ (*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inetIndex, iaObj);
inetIndex ++;
} else if (iterator->ai_family == AF_INET6) {
@@ -276,7 +269,7 @@
(*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
}
(*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
- (*env)->SetObjectField(env, iaObj, ni_iahostID, name);
+ (*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inet6Index, iaObj);
inet6Index ++;
}