src/solaris/native/java/net/Inet4AddressImpl.c
Print this page
*** 53,73 ****
static jclass ni_iacls;
static jclass ni_ia4cls;
static jmethodID ni_ia4ctrID;
! static void initializeInetClasses(JNIEnv *env)
{
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_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V");
initialized = 1;
}
}
#if defined(_ALLBSD_SOURCE) && !defined(HAS_GLIBC_GETHOSTBY_R)
extern jobjectArray lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6);
--- 53,79 ----
static jclass ni_iacls;
static jclass ni_ia4cls;
static jmethodID ni_ia4ctrID;
! static jboolean initializeInetClasses(JNIEnv *env)
{
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_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V");
+ CHECK_NULL_RETURN(ni_ia4ctrID, JNI_FALSE);
initialized = 1;
}
+ return JNI_TRUE;
}
#if defined(_ALLBSD_SOURCE) && !defined(HAS_GLIBC_GETHOSTBY_R)
extern jobjectArray lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6);
*** 139,149 ****
int retLen = 0;
int error=0;
struct addrinfo hints, *res, *resNew = NULL;
! initializeInetClasses(env);
if (IS_NULL(host)) {
JNU_ThrowNullPointerException(env, "host is null");
return 0;
}
--- 145,156 ----
int retLen = 0;
int error=0;
struct addrinfo hints, *res, *resNew = NULL;
! if (!initializeInetClasses(env))
! return NULL;
if (IS_NULL(host)) {
JNU_ThrowNullPointerException(env, "host is null");
return 0;
}
*** 398,408 ****
jobjectArray ret = 0;
int retLen = 0;
int error = 0;
struct addrinfo hints, *res, *resNew = NULL;
! initializeInetClasses(env);
if (IS_NULL(host)) {
JNU_ThrowNullPointerException(env, "host is null");
return 0;
}
--- 405,416 ----
jobjectArray ret = 0;
int retLen = 0;
int error = 0;
struct addrinfo hints, *res, *resNew = NULL;
! if (!initializeInetClasses(env))
! return NULL;
if (IS_NULL(host)) {
JNU_ThrowNullPointerException(env, "host is null");
return 0;
}