src/solaris/native/java/net/Inet4AddressImpl.c
Print this page
*** 158,167 ****
--- 158,178 ----
(char *)hostname);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
}
+ #ifdef MACOSX
+ /* If we're looking up the local machine, bypass DNS lookups and get
+ * address from getifaddrs.
+ */
+ ret = lookupIfLocalhost(env, hostname, JNI_FALSE);
+ if (ret != NULL) {
+ JNU_ReleaseStringPlatformChars(env, host, hostname);
+ return ret;
+ }
+ #endif
+
error = getaddrinfo(hostname, NULL, &hints, &res);
if (error) {
/* report error */
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
*** 368,377 ****
--- 379,392 ----
static jclass ni_iacls;
static jclass ni_ia4cls;
static jmethodID ni_ia4ctrID;
static int initialized = 0;
+ #ifdef MACOSX
+ extern jobjectArray lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6);
+ #endif
+
/*
* Find an internet address for a given hostname. Note that this
* code only works for addresses of type INET. The translation
* of %d.%d.%d.%d to an address (int) occurs in java now, so the
* String "host" shouldn't *ever* be a %d.%d.%d.%d string