1 /* 2 * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 * @bug 4472769 26 * @summary Stubs and skeletons used to implement the RMI registry 27 * implementation and the bootstrap stubs must always follow certain 28 * "well known" protocols so that they otherwise need not be in sync-- 29 * in other words, a registry stub from any arbitrary J2SE vendor and 30 * version must be able to communicate with a registry skeleton from 31 * any other arbitrary J2SE vendor and version. In addition to 32 * (unfortunately) using the old "-v1.1" stub/skeleton invocation 33 * protocol, with its unevolvable operation number scheme, they must 34 * always use the same value for the -v1.1 stub/skeleton 35 * "interface hash": 4905912898345647071L. 36 * 37 * @author Peter Jones 38 * @build InterfaceHash 39 * @build ReferenceRegistryStub 40 * @run main/othervm InterfaceHash 41 */ 42 43 import java.lang.reflect.Constructor; 44 import java.lang.reflect.Method; 45 import java.rmi.Remote; 46 import java.rmi.registry.Registry; 47 import java.rmi.registry.LocateRegistry; 48 import java.rmi.server.ObjID; 49 import java.rmi.server.Operation; 50 import java.rmi.server.RemoteCall; 51 import java.rmi.server.RemoteObject; 52 import java.rmi.server.RemoteRef; 53 import java.util.Arrays; 54 55 import sun.rmi.server.UnicastRef; 56 import sun.rmi.transport.LiveRef; 57 import sun.rmi.transport.tcp.TCPEndpoint; 58 59 public class InterfaceHash { 60 61 private static final int PORT = 2020; 62 private static final String NAME = "WMM"; 63 64 public static void main(String[] args) throws Exception { 65 System.err.println("\nRegression test for bug 4472769"); 66 67 System.err.println( 68 "\n=== verifying that J2SE registry's skeleton uses" + 69 "\ncorrect interface hash and operation numbers:"); 70 71 Registry testImpl = LocateRegistry.createRegistry(PORT); 72 System.err.println("created test registry on port " + PORT); 73 74 RemoteRef ref = new UnicastRef( 75 new LiveRef(new ObjID(ObjID.REGISTRY_ID), 76 new TCPEndpoint("", PORT), false)); 77 Registry referenceStub = new ReferenceRegistryStub(ref); 78 System.err.println("created reference registry stub: " + 79 referenceStub); 80 81 referenceStub.bind(NAME, referenceStub); | 1 /* 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 * @bug 4472769 26 * @summary Stubs and skeletons used to implement the RMI registry 27 * implementation and the bootstrap stubs must always follow certain 28 * "well known" protocols so that they otherwise need not be in sync-- 29 * in other words, a registry stub from any arbitrary J2SE vendor and 30 * version must be able to communicate with a registry skeleton from 31 * any other arbitrary J2SE vendor and version. In addition to 32 * (unfortunately) using the old "-v1.1" stub/skeleton invocation 33 * protocol, with its unevolvable operation number scheme, they must 34 * always use the same value for the -v1.1 stub/skeleton 35 * "interface hash": 4905912898345647071L. 36 * 37 * @author Peter Jones 38 * @library ../../testlibrary 39 * @build InterfaceHash 40 * @build ReferenceRegistryStub 41 * @build TestLibrary 42 * @run main/othervm InterfaceHash 43 */ 44 45 import java.lang.reflect.Constructor; 46 import java.lang.reflect.Method; 47 import java.rmi.Remote; 48 import java.rmi.registry.Registry; 49 import java.rmi.registry.LocateRegistry; 50 import java.rmi.server.ObjID; 51 import java.rmi.server.Operation; 52 import java.rmi.server.RemoteCall; 53 import java.rmi.server.RemoteObject; 54 import java.rmi.server.RemoteRef; 55 import java.util.Arrays; 56 57 import sun.rmi.server.UnicastRef; 58 import sun.rmi.transport.LiveRef; 59 import sun.rmi.transport.tcp.TCPEndpoint; 60 61 public class InterfaceHash { 62 63 private static final int PORT = TestLibrary.getUnusedRandomPort(); 64 private static final String NAME = "WMM"; 65 66 public static void main(String[] args) throws Exception { 67 System.err.println("\nRegression test for bug 4472769"); 68 69 System.err.println( 70 "\n=== verifying that J2SE registry's skeleton uses" + 71 "\ncorrect interface hash and operation numbers:"); 72 73 Registry testImpl = LocateRegistry.createRegistry(PORT); 74 System.err.println("created test registry on port " + PORT); 75 76 RemoteRef ref = new UnicastRef( 77 new LiveRef(new ObjID(ObjID.REGISTRY_ID), 78 new TCPEndpoint("", PORT), false)); 79 Registry referenceStub = new ReferenceRegistryStub(ref); 80 System.err.println("created reference registry stub: " + 81 referenceStub); 82 83 referenceStub.bind(NAME, referenceStub); |