Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/native/java/net/net_util.c
          +++ new/src/share/native/java/net/net_util.c
↓ open down ↓ 89 lines elided ↑ open up ↑
  90   90      if (him->sa_family == AF_INET6) {
  91   91          jbyteArray ipaddress;
  92   92  #ifdef WIN32
  93   93          struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
  94   94  #else
  95   95          struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
  96   96  #endif
  97   97          jbyte *caddr = (jbyte *)&(him6->sin6_addr);
  98   98          if (NET_IsIPv4Mapped(caddr)) {
  99   99              int address;
 100      -            static jclass inet4Cls = 0;
 101      -            if (inet4Cls == 0) {
 102      -                jclass c = (*env)->FindClass(env, "java/net/Inet4Address");
 103      -                CHECK_NULL_RETURN(c, NULL);
 104      -                inet4Cls = (*env)->NewGlobalRef(env, c);
 105      -                CHECK_NULL_RETURN(inet4Cls, NULL);
 106      -                (*env)->DeleteLocalRef(env, c);
 107      -            }
 108      -            iaObj = (*env)->NewObject(env, inet4Cls, ia4_ctrID);
      100 +            iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
 109  101              CHECK_NULL_RETURN(iaObj, NULL);
 110  102              address = NET_IPv4MappedToIPv4(caddr);
 111  103              (*env)->SetIntField(env, iaObj, ia_addressID, address);
 112  104              (*env)->SetIntField(env, iaObj, ia_familyID, IPv4);
 113  105          } else {
 114      -            static jclass inet6Cls = 0;
 115  106              jint scope;
 116      -            if (inet6Cls == 0) {
 117      -                jclass c = (*env)->FindClass(env, "java/net/Inet6Address");
 118      -                CHECK_NULL_RETURN(c, NULL);
 119      -                inet6Cls = (*env)->NewGlobalRef(env, c);
 120      -                CHECK_NULL_RETURN(inet6Cls, NULL);
 121      -                (*env)->DeleteLocalRef(env, c);
 122      -            }
 123      -            iaObj = (*env)->NewObject(env, inet6Cls, ia6_ctrID);
      107 +            iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
 124  108              CHECK_NULL_RETURN(iaObj, NULL);
 125  109              ipaddress = (*env)->NewByteArray(env, 16);
 126  110              CHECK_NULL_RETURN(ipaddress, NULL);
 127  111              (*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
 128  112                                         (jbyte *)&(him6->sin6_addr));
 129  113  
 130  114              (*env)->SetObjectField(env, iaObj, ia6_ipaddressID, ipaddress);
 131  115  
 132  116              (*env)->SetIntField(env, iaObj, ia_familyID, IPv6);
 133  117              scope = getScopeID(him);
 134  118              (*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
 135  119              if (scope > 0)
 136  120                  (*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
 137  121          }
 138  122          *port = ntohs(him6->sin6_port);
 139  123      } else
 140  124  #endif /* AF_INET6 */
 141  125          {
 142  126              struct sockaddr_in *him4 = (struct sockaddr_in *)him;
 143      -            static jclass inet4Cls = 0;
 144      -
 145      -            if (inet4Cls == 0) {
 146      -                jclass c = (*env)->FindClass(env, "java/net/Inet4Address");
 147      -                CHECK_NULL_RETURN(c, NULL);
 148      -                inet4Cls = (*env)->NewGlobalRef(env, c);
 149      -                CHECK_NULL_RETURN(inet4Cls, NULL);
 150      -                (*env)->DeleteLocalRef(env, c);
 151      -            }
 152      -            iaObj = (*env)->NewObject(env, inet4Cls, ia4_ctrID);
      127 +            iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
 153  128              CHECK_NULL_RETURN(iaObj, NULL);
 154  129              (*env)->SetIntField(env, iaObj, ia_familyID, IPv4);
 155  130              (*env)->SetIntField(env, iaObj, ia_addressID,
 156  131                                  ntohl(him4->sin_addr.s_addr));
 157  132              *port = ntohs(him4->sin_port);
 158  133          }
 159  134      return iaObj;
 160  135  }
 161  136  
 162  137  JNIEXPORT jint JNICALL
↓ open down ↓ 83 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX