< prev index next >

src/java.base/share/classes/java/net/InetAddress.java

Print this page

 314             preferIPv6Address = PREFER_IPV4_VALUE;
 315         } else if (str.equalsIgnoreCase("system")) {
 316             preferIPv6Address = PREFER_SYSTEM_VALUE;
 317         } else {
 318             preferIPv6Address = PREFER_IPV4_VALUE;
 319         }
 320         jdk.internal.loader.BootLoader.loadLibrary("net");
 321         SharedSecrets.setJavaNetInetAddressAccess(
 322                 new JavaNetInetAddressAccess() {
 323                     public String getOriginalHostName(InetAddress ia) {
 324                         return ia.holder.getOriginalHostName();
 325                     }
 326 
 327                     public InetAddress getByName(String hostName,
 328                                                  InetAddress hostAddress)
 329                         throws UnknownHostException
 330                     {
 331                         return InetAddress.getByName(hostName, hostAddress);
 332                     }
 333 















 334                     public int addressValue(Inet4Address inet4Address) {
 335                         return inet4Address.addressValue();
 336                     }
 337 
 338                     public byte[] addressBytes(Inet6Address inet6Address) {
 339                         return inet6Address.addressBytes();
 340                     }
 341                 }
 342         );
 343         init();
 344     }
 345 
 346     /**
 347      * Constructor for the Socket.accept() method.
 348      * This creates an empty InetAddress, which is filled in by
 349      * the accept() method.  This InetAddress, however, is not
 350      * put in the address cache, since it is not created by name.
 351      */
 352     InetAddress() {
 353         holder = new InetAddressHolder();

 314             preferIPv6Address = PREFER_IPV4_VALUE;
 315         } else if (str.equalsIgnoreCase("system")) {
 316             preferIPv6Address = PREFER_SYSTEM_VALUE;
 317         } else {
 318             preferIPv6Address = PREFER_IPV4_VALUE;
 319         }
 320         jdk.internal.loader.BootLoader.loadLibrary("net");
 321         SharedSecrets.setJavaNetInetAddressAccess(
 322                 new JavaNetInetAddressAccess() {
 323                     public String getOriginalHostName(InetAddress ia) {
 324                         return ia.holder.getOriginalHostName();
 325                     }
 326 
 327                     public InetAddress getByName(String hostName,
 328                                                  InetAddress hostAddress)
 329                         throws UnknownHostException
 330                     {
 331                         return InetAddress.getByName(hostName, hostAddress);
 332                     }
 333 
 334                     public Inet4Address getByAddress(int address) {
 335                         return new Inet4Address(null, address);
 336                     }
 337 
 338                     public InetAddress getByAddress(byte[] addr,
 339                                                     int scope_id) {
 340                         assert addr.length == Inet6Address.INADDRSZ;
 341                         if (IPAddressUtil.isIPv4MappedAddress(addr)) {
 342                             assert scope_id == 0;
 343                             return getByAddress(IPAddressUtil.intFromIPv4MappedAddress(addr));
 344                         } else {
 345                             return new Inet6Address(addr, scope_id);
 346                         }
 347                     }
 348 
 349                     public int addressValue(Inet4Address inet4Address) {
 350                         return inet4Address.addressValue();
 351                     }
 352 
 353                     public byte[] addressBytes(Inet6Address inet6Address) {
 354                         return inet6Address.addressBytes();
 355                     }
 356                 }
 357         );
 358         init();
 359     }
 360 
 361     /**
 362      * Constructor for the Socket.accept() method.
 363      * This creates an empty InetAddress, which is filled in by
 364      * the accept() method.  This InetAddress, however, is not
 365      * put in the address cache, since it is not created by name.
 366      */
 367     InetAddress() {
 368         holder = new InetAddressHolder();
< prev index next >