< prev index next > src/java.base/share/classes/java/net/Inet6AddressImpl.java
Print this page
* questions.
*/
package java.net;
import java.io.IOException;
+ import java.net.spi.InetAddressResolver.LookupPolicy;
- import static java.net.InetAddress.IPv6;
- import static java.net.InetAddress.PREFER_IPV6_VALUE;
- import static java.net.InetAddress.PREFER_SYSTEM_VALUE;
+ import static java.net.InetAddress.PLATFORM_LOOKUP_POLICY;
/*
* Package private implementation of InetAddressImpl for dual
* IPv4/IPv6 stack.
* <p>
*/
final class Inet6AddressImpl implements InetAddressImpl {
public native String getLocalHostName() throws UnknownHostException;
- public native InetAddress[] lookupAllHostAddr(String hostname)
- throws UnknownHostException;
+ public InetAddress[] lookupAllHostAddr(String hostname, LookupPolicy lookupPolicy)
+ throws UnknownHostException {
+ return lookupAllHostAddr(hostname, lookupPolicy.characteristics());
+ }
+
+ private native InetAddress[] lookupAllHostAddr(String hostname, int characteristics)
+ throws UnknownHostException;
public native String getHostByAddr(byte[] addr) throws UnknownHostException;
private native boolean isReachable0(byte[] addr, int scope, int timeout,
byte[] inf, int ttl, int if_scope)
return isReachable0(addr.getAddress(), scope, timeout, ifaddr, ttl, netif_scope);
}
public synchronized InetAddress anyLocalAddress() {
if (anyLocalAddress == null) {
- if (InetAddress.preferIPv6Address == PREFER_IPV6_VALUE ||
- InetAddress.preferIPv6Address == PREFER_SYSTEM_VALUE) {
+ int flags = PLATFORM_LOOKUP_POLICY.characteristics();
+ if (InetAddress.ipv6AddressesFirst(flags) ||
+ InetAddress.systemAddressesOrder(flags)) {
anyLocalAddress = new Inet6Address();
anyLocalAddress.holder().hostName = "::";
} else {
anyLocalAddress = (new Inet4AddressImpl()).anyLocalAddress();
}
return anyLocalAddress;
}
public synchronized InetAddress loopbackAddress() {
if (loopbackAddress == null) {
- boolean preferIPv6Address =
- InetAddress.preferIPv6Address == PREFER_IPV6_VALUE ||
- InetAddress.preferIPv6Address == PREFER_SYSTEM_VALUE;
+ int flags = PLATFORM_LOOKUP_POLICY.characteristics();
+ boolean preferIPv6Address = InetAddress.ipv6AddressesFirst(flags) ||
+ InetAddress.systemAddressesOrder(flags);
for (int i = 0; i < 2; i++) {
InetAddress address;
// Order the candidate addresses by preference.
if (i == (preferIPv6Address ? 0 : 1)) {
< prev index next >