jdk/src/solaris/classes/sun/net/dns/ResolverConfigurationImpl.java
author chegar
Fri, 16 Sep 2011 12:09:04 -0700
changeset 10596 39b3a979e600
parent 6112 b9d1b10c662c
child 12559 9456ceada8b1
permissions -rw-r--r--
7090158: Networking Libraries don't build with javac -Werror Summary: Minor changes to networking java files to remove warnings Reviewed-by: chegar, weijun, hawtin Contributed-by: kurchi.subhra.hazra@oracle.com, sasha_bu@hotmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
     2
 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.net.dns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.LinkedList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.StringTokenizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.BufferedReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.FileReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * An implementation of ResolverConfiguration for Solaris
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * and Linux.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public class ResolverConfigurationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    extends ResolverConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    // Lock helds whilst loading configuration or checking
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private static Object lock = new Object();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    // Time of last refresh.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private static long lastRefresh = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    // Cache timeout (300 seconds) - should be converted into property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    // or configured as preference in the future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private static final int TIMEOUT = 300000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    // Resolver options
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private final Options opts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    // Parse /etc/resolv.conf to get the values for a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    // keyword.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    //
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
    59
    private LinkedList<String> resolvconf(String keyword,
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
    60
                                          int maxperkeyword,
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
    61
                                          int maxkeywords)
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
    62
    {
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
    63
        LinkedList<String> ll = new LinkedList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            BufferedReader in =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                new BufferedReader(new FileReader("/etc/resolv.conf"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            String line;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            while ((line = in.readLine()) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                int maxvalues = maxperkeyword;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                if (line.length() == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                   continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                if (line.charAt(0) == '#' || line.charAt(0) == ';')
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                if (!line.startsWith(keyword))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                String value = line.substring(keyword.length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                if (value.length() == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                if (value.charAt(0) != ' ' && value.charAt(0) != '\t')
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                StringTokenizer st = new StringTokenizer(value, " \t");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                while (st.hasMoreTokens()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                    String val = st.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                    if (val.charAt(0) == '#' || val.charAt(0) == ';') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                    ll.add(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                    if (--maxvalues == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                if (--maxkeywords == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            // problem reading value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        return ll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   105
    private LinkedList<String> searchlist;
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   106
    private LinkedList<String> nameservers;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    // Load DNS configuration from OS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    private void loadConfig() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        assert Thread.holdsLock(lock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        // check if cached settings have expired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        if (lastRefresh >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            long currTime = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            if ((currTime - lastRefresh) < TIMEOUT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        // get the name servers from /etc/resolv.conf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        nameservers =
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   124
            java.security.AccessController.doPrivileged(
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   125
                new java.security.PrivilegedAction<LinkedList<String>>() {
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   126
                    public LinkedList<String> run() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                        // typically MAXNS is 3 but we've picked 5 here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                        // to allow for additional servers if required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                        return resolvconf("nameserver", 1, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                    } /* run */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        // get the search list (or domain)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        searchlist = getSearchList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        // update the timestamp on the configuration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        lastRefresh = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    // obtain search list or local domain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   143
    private LinkedList<String> getSearchList() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   145
        LinkedList<String> sl;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        // first try the search keyword in /etc/resolv.conf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   149
        sl = java.security.AccessController.doPrivileged(
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   150
                 new java.security.PrivilegedAction<LinkedList<String>>() {
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   151
                    public LinkedList<String> run() {
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   152
                        LinkedList<String> ll;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                        // first try search keyword (max 6 domains)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                        ll = resolvconf("search", 6, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                        if (ll.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                            return ll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                    } /* run */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        if (sl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            return sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        // No search keyword so use local domain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        // LOCALDOMAIN has absolute priority on Solaris
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        String localDomain = localDomain0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        if (localDomain != null && localDomain.length() > 0) {
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   176
            sl = new LinkedList<String>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            sl.add(localDomain);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            return sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        // try domain keyword in /etc/resolv.conf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   183
        sl = java.security.AccessController.doPrivileged(
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   184
                 new java.security.PrivilegedAction<LinkedList<String>>() {
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   185
                    public LinkedList<String> run() {
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   186
                        LinkedList<String> ll;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                        ll = resolvconf("domain", 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                        if (ll.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                            return ll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    } /* run */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if (sl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            return sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        // no local domain so try fallback (RPC) domain or
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   201
        // hostName
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   203
        sl = new LinkedList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        String domain = fallbackDomain0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        if (domain != null && domain.length() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            sl.add(domain);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        return sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    // ----
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    ResolverConfigurationImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        opts = new OptionsImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   219
    @SuppressWarnings("unchecked")
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   220
    public List<String> searchlist() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        synchronized (lock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            loadConfig();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            // List is mutable so return a shallow copy
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   225
            return (List<String>)searchlist.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   229
    @SuppressWarnings("unchecked")
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   230
    public List<String> nameservers() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        synchronized (lock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            loadConfig();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            // List is mutable so return a shallow copy
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   235
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   236
          return (List<String>)nameservers.clone();
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   237
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   238
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public Options options() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        return opts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    // --- Native methods --
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    static native String localDomain0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    static native String fallbackDomain0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            new sun.security.action.LoadLibraryAction("net"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
 * Implementation of {@link ResolverConfiguration.Options}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
class OptionsImpl extends ResolverConfiguration.Options {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
}