src/share/native/java/net/net_util.c

Print this page

        

*** 95,128 **** struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; #endif jbyte *caddr = (jbyte *)&(him6->sin6_addr); if (NET_IsIPv4Mapped(caddr)) { int address; ! static jclass inet4Cls = 0; ! if (inet4Cls == 0) { ! jclass c = (*env)->FindClass(env, "java/net/Inet4Address"); ! CHECK_NULL_RETURN(c, NULL); ! inet4Cls = (*env)->NewGlobalRef(env, c); ! CHECK_NULL_RETURN(inet4Cls, NULL); ! (*env)->DeleteLocalRef(env, c); ! } ! iaObj = (*env)->NewObject(env, inet4Cls, ia4_ctrID); CHECK_NULL_RETURN(iaObj, NULL); address = NET_IPv4MappedToIPv4(caddr); (*env)->SetIntField(env, iaObj, ia_addressID, address); (*env)->SetIntField(env, iaObj, ia_familyID, IPv4); } else { - static jclass inet6Cls = 0; jint scope; ! if (inet6Cls == 0) { ! jclass c = (*env)->FindClass(env, "java/net/Inet6Address"); ! CHECK_NULL_RETURN(c, NULL); ! inet6Cls = (*env)->NewGlobalRef(env, c); ! CHECK_NULL_RETURN(inet6Cls, NULL); ! (*env)->DeleteLocalRef(env, c); ! } ! iaObj = (*env)->NewObject(env, inet6Cls, ia6_ctrID); CHECK_NULL_RETURN(iaObj, NULL); ipaddress = (*env)->NewByteArray(env, 16); CHECK_NULL_RETURN(ipaddress, NULL); (*env)->SetByteArrayRegion(env, ipaddress, 0, 16, (jbyte *)&(him6->sin6_addr)); --- 95,112 ---- struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; #endif jbyte *caddr = (jbyte *)&(him6->sin6_addr); if (NET_IsIPv4Mapped(caddr)) { int address; ! iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); CHECK_NULL_RETURN(iaObj, NULL); address = NET_IPv4MappedToIPv4(caddr); (*env)->SetIntField(env, iaObj, ia_addressID, address); (*env)->SetIntField(env, iaObj, ia_familyID, IPv4); } else { jint scope; ! iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); CHECK_NULL_RETURN(iaObj, NULL); ipaddress = (*env)->NewByteArray(env, 16); CHECK_NULL_RETURN(ipaddress, NULL); (*env)->SetByteArrayRegion(env, ipaddress, 0, 16, (jbyte *)&(him6->sin6_addr));
*** 138,157 **** *port = ntohs(him6->sin6_port); } else #endif /* AF_INET6 */ { struct sockaddr_in *him4 = (struct sockaddr_in *)him; ! static jclass inet4Cls = 0; ! ! if (inet4Cls == 0) { ! jclass c = (*env)->FindClass(env, "java/net/Inet4Address"); ! CHECK_NULL_RETURN(c, NULL); ! inet4Cls = (*env)->NewGlobalRef(env, c); ! CHECK_NULL_RETURN(inet4Cls, NULL); ! (*env)->DeleteLocalRef(env, c); ! } ! iaObj = (*env)->NewObject(env, inet4Cls, ia4_ctrID); CHECK_NULL_RETURN(iaObj, NULL); (*env)->SetIntField(env, iaObj, ia_familyID, IPv4); (*env)->SetIntField(env, iaObj, ia_addressID, ntohl(him4->sin_addr.s_addr)); *port = ntohs(him4->sin_port); --- 122,132 ---- *port = ntohs(him6->sin6_port); } else #endif /* AF_INET6 */ { struct sockaddr_in *him4 = (struct sockaddr_in *)him; ! iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); CHECK_NULL_RETURN(iaObj, NULL); (*env)->SetIntField(env, iaObj, ia_familyID, IPv4); (*env)->SetIntField(env, iaObj, ia_addressID, ntohl(him4->sin_addr.s_addr)); *port = ntohs(him4->sin_port);