src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java
author redestad
Thu, 13 Dec 2018 15:31:05 +0100
changeset 53018 8bf9268df0e2
parent 47216 71c04702a3d5
child 55693 9a97b1393e72
permissions -rw-r--r--
8215281: Use String.isEmpty() when applicable in java.base Reviewed-by: dfuchs, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 12559
diff changeset
     2
 * Copyright (c) 2002, 2012, 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;
53018
8bf9268df0e2 8215281: Use String.isEmpty() when applicable in java.base
redestad
parents: 47216
diff changeset
    71
                if (line.isEmpty())
2
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());
53018
8bf9268df0e2 8215281: Use String.isEmpty() when applicable in java.base
redestad
parents: 47216
diff changeset
    78
                if (value.isEmpty())
2
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
                    }
29978
2a735486f812 6991580: IPv6 Nameservers in resolv.conf throws NumberFormatException
michaelm
parents: 25859
diff changeset
    88
                    if ("nameserver".equals(keyword)) {
2a735486f812 6991580: IPv6 Nameservers in resolv.conf throws NumberFormatException
michaelm
parents: 25859
diff changeset
    89
                        if (val.indexOf(':') >= 0 &&
2a735486f812 6991580: IPv6 Nameservers in resolv.conf throws NumberFormatException
michaelm
parents: 25859
diff changeset
    90
                            val.indexOf('.') < 0 && // skip for IPv4 literals with port
2a735486f812 6991580: IPv6 Nameservers in resolv.conf throws NumberFormatException
michaelm
parents: 25859
diff changeset
    91
                            val.indexOf('[') < 0 &&
2a735486f812 6991580: IPv6 Nameservers in resolv.conf throws NumberFormatException
michaelm
parents: 25859
diff changeset
    92
                            val.indexOf(']') < 0 ) {
2a735486f812 6991580: IPv6 Nameservers in resolv.conf throws NumberFormatException
michaelm
parents: 25859
diff changeset
    93
                            // IPv6 literal, in non-BSD-style.
2a735486f812 6991580: IPv6 Nameservers in resolv.conf throws NumberFormatException
michaelm
parents: 25859
diff changeset
    94
                            val = "[" + val + "]";
2a735486f812 6991580: IPv6 Nameservers in resolv.conf throws NumberFormatException
michaelm
parents: 25859
diff changeset
    95
                        }
2a735486f812 6991580: IPv6 Nameservers in resolv.conf throws NumberFormatException
michaelm
parents: 25859
diff changeset
    96
                    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                    ll.add(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                    if (--maxvalues == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                if (--maxkeywords == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            // problem reading value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return ll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   114
    private LinkedList<String> searchlist;
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   115
    private LinkedList<String> nameservers;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    // Load DNS configuration from OS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    private void loadConfig() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        assert Thread.holdsLock(lock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        // check if cached settings have expired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (lastRefresh >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            long currTime = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            if ((currTime - lastRefresh) < TIMEOUT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        // get the name servers from /etc/resolv.conf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        nameservers =
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   133
            java.security.AccessController.doPrivileged(
29986
97167d851fc4 8078467: Update core libraries to use diamond with anonymous classes
darcy
parents: 29978
diff changeset
   134
                new java.security.PrivilegedAction<>() {
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   135
                    public LinkedList<String> run() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                        // typically MAXNS is 3 but we've picked 5 here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                        // to allow for additional servers if required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                        return resolvconf("nameserver", 1, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                    } /* run */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        // get the search list (or domain)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        searchlist = getSearchList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        // update the timestamp on the configuration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        lastRefresh = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    // obtain search list or local domain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   152
    private LinkedList<String> getSearchList() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   154
        LinkedList<String> sl;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        // first try the search keyword in /etc/resolv.conf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   158
        sl = java.security.AccessController.doPrivileged(
29986
97167d851fc4 8078467: Update core libraries to use diamond with anonymous classes
darcy
parents: 29978
diff changeset
   159
                 new java.security.PrivilegedAction<>() {
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   160
                    public LinkedList<String> run() {
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   161
                        LinkedList<String> ll;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                        // first try search keyword (max 6 domains)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                        ll = resolvconf("search", 6, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                        if (ll.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                            return ll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                    } /* run */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        if (sl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            return sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        // No search keyword so use local domain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        // LOCALDOMAIN has absolute priority on Solaris
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        String localDomain = localDomain0();
53018
8bf9268df0e2 8215281: Use String.isEmpty() when applicable in java.base
redestad
parents: 47216
diff changeset
   184
        if (localDomain != null && !localDomain.isEmpty()) {
29986
97167d851fc4 8078467: Update core libraries to use diamond with anonymous classes
darcy
parents: 29978
diff changeset
   185
            sl = new LinkedList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            sl.add(localDomain);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            return sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        // try domain keyword in /etc/resolv.conf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   192
        sl = java.security.AccessController.doPrivileged(
29986
97167d851fc4 8078467: Update core libraries to use diamond with anonymous classes
darcy
parents: 29978
diff changeset
   193
                 new java.security.PrivilegedAction<>() {
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   194
                    public LinkedList<String> run() {
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   195
                        LinkedList<String> ll;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                        ll = resolvconf("domain", 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                        if (ll.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                            return ll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                    } /* run */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        if (sl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            return sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        // 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
   210
        // hostName
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   212
        sl = new LinkedList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        String domain = fallbackDomain0();
53018
8bf9268df0e2 8215281: Use String.isEmpty() when applicable in java.base
redestad
parents: 47216
diff changeset
   214
        if (domain != null && !domain.isEmpty()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            sl.add(domain);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    // ----
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    ResolverConfigurationImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        opts = new OptionsImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   228
    @SuppressWarnings("unchecked")
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   229
    public List<String> searchlist() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        synchronized (lock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            loadConfig();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            // List is mutable so return a shallow copy
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   234
            return (List<String>)searchlist.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   238
    @SuppressWarnings("unchecked")
6112
b9d1b10c662c 6969683: Generify ResolverConfiguration codes
weijun
parents: 5506
diff changeset
   239
    public List<String> nameservers() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        synchronized (lock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            loadConfig();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            // List is mutable so return a shallow copy
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   244
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   245
          return (List<String>)nameservers.clone();
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   246
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 6112
diff changeset
   247
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public Options options() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        return opts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    // --- Native methods --
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    static native String localDomain0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    static native String fallbackDomain0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        java.security.AccessController.doPrivileged(
29986
97167d851fc4 8078467: Update core libraries to use diamond with anonymous classes
darcy
parents: 29978
diff changeset
   263
            new java.security.PrivilegedAction<>() {
12559
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 10596
diff changeset
   264
                public Void run() {
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 10596
diff changeset
   265
                    System.loadLibrary("net");
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 10596
diff changeset
   266
                    return null;
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 10596
diff changeset
   267
                }
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 10596
diff changeset
   268
            });
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
 * Implementation of {@link ResolverConfiguration.Options}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
class OptionsImpl extends ResolverConfiguration.Options {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
}