Index: trunk/modules/rmi/src/main/java/java/rmi/registry/LocateRegistry.java =================================================================== --- trunk/modules/rmi/src/main/java/java/rmi/registry/LocateRegistry.java (revision 433136) +++ trunk/modules/rmi/src/main/java/java/rmi/registry/LocateRegistry.java (working copy) @@ -54,6 +54,9 @@ RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException { + if (port < 0) { + throw new IllegalArgumentException("Port value out of range: " + port); + } return new RegistryImpl(port, csf, ssf); } Index: trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/registry/LocateRegistryTest.java =================================================================== --- trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/registry/LocateRegistryTest.java (revision 0) +++ trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/registry/LocateRegistryTest.java (revision 0) @@ -0,0 +1,37 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.rmi.registry; + +import java.rmi.registry.LocateRegistry; + +import junit.framework.TestCase; + +public class LocateRegistryTest extends TestCase { + + /** + * Test for method createRegistry(int port) + */ + public void test_createRegistryI() throws Exception { + try { + LocateRegistry.createRegistry(-1); + fail("IllegalArgumentException expected"); + } catch (IllegalArgumentException e) { + //expected + } + } +}