src/solaris/native/java/net/Inet6AddressImpl.c

Print this page

        

*** 122,150 **** static jclass ni_ia6cls; static jmethodID ni_ia4ctrID; static jmethodID ni_ia6ctrID; static jboolean preferIPv6Address; ! static void initializeInetClasses(JNIEnv *env) { jfieldID ni_preferIPv6AddressID; static int initialized = 0; if (!initialized) { ni_iacls = (*env)->FindClass(env, "java/net/InetAddress"); ni_iacls = (*env)->NewGlobalRef(env, ni_iacls); ni_ia4cls = (*env)->FindClass(env, "java/net/Inet4Address"); ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls); ni_ia6cls = (*env)->FindClass(env, "java/net/Inet6Address"); ni_ia6cls = (*env)->NewGlobalRef(env, ni_ia6cls); ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V"); ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "<init>", "()V"); ni_preferIPv6AddressID = (*env)->GetStaticFieldID(env, ni_iacls, "preferIPv6Address", "Z"); preferIPv6Address = (*env)->GetStaticBooleanField(env, ia_class, ia_preferIPv6AddressID); initialized = 1; } } #ifdef MACOSX /* also called from Inet4AddressImpl.c */ __private_extern__ jobjectArray --- 122,160 ---- static jclass ni_ia6cls; static jmethodID ni_ia4ctrID; static jmethodID ni_ia6ctrID; static jboolean preferIPv6Address; ! static jboolean initializeInetClasses(JNIEnv *env) { jfieldID ni_preferIPv6AddressID; static int initialized = 0; if (!initialized) { ni_iacls = (*env)->FindClass(env, "java/net/InetAddress"); + CHECK_NULL_RETURN(ni_iacls, JNI_FALSE); ni_iacls = (*env)->NewGlobalRef(env, ni_iacls); + CHECK_NULL_RETURN(ni_iacls, JNI_FALSE); ni_ia4cls = (*env)->FindClass(env, "java/net/Inet4Address"); + CHECK_NULL_RETURN(ni_ia4cls, JNI_FALSE); ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls); + CHECK_NULL_RETURN(ni_ia4cls, JNI_FALSE); ni_ia6cls = (*env)->FindClass(env, "java/net/Inet6Address"); + CHECK_NULL_RETURN(ni_ia6cls, JNI_FALSE); ni_ia6cls = (*env)->NewGlobalRef(env, ni_ia6cls); + CHECK_NULL_RETURN(ni_ia6cls, JNI_FALSE); ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V"); + CHECK_NULL_RETURN(ni_ia4ctrID, JNI_FALSE); ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "<init>", "()V"); + CHECK_NULL_RETURN(ni_ia6ctrID, JNI_FALSE); ni_preferIPv6AddressID = (*env)->GetStaticFieldID(env, ni_iacls, "preferIPv6Address", "Z"); + CHECK_NULL_RETURN(ni_preferIPv6AddressID, JNI_FALSE); preferIPv6Address = (*env)->GetStaticBooleanField(env, ia_class, ia_preferIPv6AddressID); initialized = 1; } + return JNI_TRUE; } #ifdef MACOSX /* also called from Inet4AddressImpl.c */ __private_extern__ jobjectArray
*** 158,168 **** int addrs4 = 0, addrs6 = 0, numV4Loopbacks = 0, numV6Loopbacks = 0; jboolean includeLoopback = JNI_FALSE; jobject name; // Make sure static variables we need are set. ! initializeInetClasses(env); /* If the requested name matches this host's hostname, return IP addresses * from all attached interfaces. (#2844683 et al) This prevents undesired * PPP dialup, but may return addresses that don't actually correspond to * the name (if the name actually matches something in DNS etc. --- 168,179 ---- int addrs4 = 0, addrs6 = 0, numV4Loopbacks = 0, numV6Loopbacks = 0; jboolean includeLoopback = JNI_FALSE; jobject name; // Make sure static variables we need are set. ! if (!initializeInetClasses(env)) ! return NULL; /* If the requested name matches this host's hostname, return IP addresses * from all attached interfaces. (#2844683 et al) This prevents undesired * PPP dialup, but may return addresses that don't actually correspond to * the name (if the name actually matches something in DNS etc.
*** 284,294 **** int error=0; #ifdef AF_INET6 struct addrinfo hints, *res, *resNew = NULL; #endif /* AF_INET6 */ ! initializeInetClasses(env); if (IS_NULL(host)) { JNU_ThrowNullPointerException(env, "host is null"); return 0; } --- 295,306 ---- int error=0; #ifdef AF_INET6 struct addrinfo hints, *res, *resNew = NULL; #endif /* AF_INET6 */ ! if (!initializeInetClasses(env)) ! return NULL; if (IS_NULL(host)) { JNU_ThrowNullPointerException(env, "host is null"); return 0; }