2605N/A/*
2605N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2605N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2605N/A *
2605N/A * This code is free software; you can redistribute it and/or modify it
2605N/A * under the terms of the GNU General Public License version 2 only, as
2605N/A * published by the Free Software Foundation.
2605N/A *
2605N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2605N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2605N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2605N/A * version 2 for more details (a copy is included in the LICENSE file that
2605N/A * accompanied this code).
2605N/A *
2605N/A * You should have received a copy of the GNU General Public License version
2605N/A * 2 along with this work; if not, write to the Free Software Foundation,
2605N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2605N/A *
2605N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2605N/A * or visit www.oracle.com if you need additional information or have any
2605N/A * questions.
2605N/A */
2605N/A
2605N/A/* @test
2605N/A * @bug 6964714
2613N/A * @run main/othervm IPv4Only
2605N/A * @summary Test the networkinterface listing with java.net.preferIPv4Stack=true.
2605N/A */
2605N/A
2605N/A
2605N/Aimport java.net.*;
2605N/Aimport java.util.*;
2605N/A
2605N/A
2605N/Apublic class IPv4Only {
2605N/A public static void main(String[] args) throws Exception {
2605N/A System.setProperty("java.net.preferIPv4Stack","true");
2605N/A
2605N/A Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
2605N/A while (nifs.hasMoreElements()) {
2605N/A NetworkInterface nif = nifs.nextElement();
2605N/A Enumeration<InetAddress> addrs = nif.getInetAddresses();
2605N/A while (addrs.hasMoreElements()) {
2605N/A InetAddress hostAddr = addrs.nextElement();
2605N/A if ( hostAddr instanceof Inet6Address ){
2605N/A throw new RuntimeException( "NetworkInterfaceV6List failed - found v6 address " + hostAddr.getHostAddress() );
2605N/A }
2605N/A }
2605N/A }
2605N/A }
2605N/A}