< prev index next >

test/jdk/java/rmi/Naming/LookupIPv6.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 28,47 **** * @library ../testlibrary * @modules java.rmi/sun.rmi.registry * java.rmi/sun.rmi.server * java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport.tcp ! * @build TestLibrary * @run main/othervm -Djava.net.preferIPv6Addresses=true LookupIPv6 */ import java.net.InetAddress; import java.net.Inet6Address; import java.net.MalformedURLException; import java.rmi.Naming; ! import java.rmi.registry.LocateRegistry; ! import java.rmi.registry.Registry; public class LookupIPv6 { public static void main(String[] args) throws Exception { // use loopback IPv6 address to avoid lengthy socket connection delays String[] urls = { --- 28,47 ---- * @library ../testlibrary * @modules java.rmi/sun.rmi.registry * java.rmi/sun.rmi.server * java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport.tcp ! * @build RegistryVM * @run main/othervm -Djava.net.preferIPv6Addresses=true LookupIPv6 */ + import java.io.Serializable; import java.net.InetAddress; import java.net.Inet6Address; import java.net.MalformedURLException; import java.rmi.Naming; ! import java.rmi.Remote; public class LookupIPv6 { public static void main(String[] args) throws Exception { // use loopback IPv6 address to avoid lengthy socket connection delays String[] urls = {
*** 65,85 **** * be a no-op in some cases. On supporting platforms, the first * element of the array returned by InetAddress.getAllByName should be * an Inet6Address since this test is run with * -Djava.net.preferIPv6Addresses=true. */ - int port = TestLibrary.getUnusedRandomPort(); InetAddress localAddr = InetAddress.getAllByName(null)[0]; if (localAddr instanceof Inet6Address) { System.out.println("IPv6 detected"); ! Registry reg; try { ! reg = LocateRegistry.createRegistry(port); ! } catch (Exception ex) { ! reg = LocateRegistry.getRegistry(); } - reg.rebind("foo", reg); - Naming.lookup(String.format("rmi://[%s]:%d/foo", - localAddr.getHostAddress(), port)); } } } --- 65,87 ---- * be a no-op in some cases. On supporting platforms, the first * element of the array returned by InetAddress.getAllByName should be * an Inet6Address since this test is run with * -Djava.net.preferIPv6Addresses=true. */ InetAddress localAddr = InetAddress.getAllByName(null)[0]; if (localAddr instanceof Inet6Address) { System.out.println("IPv6 detected"); ! RegistryVM rvm = RegistryVM.createRegistryVM(); try { ! rvm.start(); ! String name = String.format("rmi://[%s]:%d/foo", ! localAddr.getHostAddress(), rvm.getPort()); ! Naming.rebind(name, new R()); ! Naming.lookup(name); ! } finally { ! rvm.cleanup(); } } } + + private static class R implements Remote, Serializable { } }
< prev index next >