if (hostname == null) { throw new UnknownHostException("null"); } if (resolver == null) { throw new UnknownHostException(hostname); }
    public ProtocolAddress[] getByName(final String hostname)            throws UnknownHostException {        final PrivilegedExceptionAction action = new PrivilegedExceptionAction() {            public Object run() throws UnknownHostException {                ProtocolAddress[] protocolAddresses;                protocolAddresses = getFromHostsFile(hostname);                if (protocolAddresses != null) {                    return protocolAddresses;                }                Lookup.setDefaultResolver(resolver);                final Lookup lookup;                try {                    lookup = new Lookup(hostname);                } catch (TextParseException e) {                    throw new UnknownHostException(hostname);                }                lookup.run();                if (lookup.getResult() == Lookup.SUCCESSFUL) {                    final Record[] records = lookup.getAnswers();                    final int recordCount = records.length;                    protocolAddresses = new ProtocolAddress[recordCount];                    for (int i = 0; i < recordCount; i++) {                        final Record record = records[i];                        protocolAddresses[i] = new IPv4Address(record.rdataToString());                    }                } else {                    throw new UnknownHostException(lookup.getErrorString());                }                return protocolAddresses;                            }        };        try {            return (ProtocolAddress[])AccessController.doPrivileged(action);        } catch (PrivilegedActionException ex) {            if (ex.getException() instanceof UnknownHostException) {                throw (UnknownHostException)ex.getException();            } else {                throw (UnknownHostException)new UnknownHostException().initCause(ex.getException());            }        }    }