diff --git a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/ActivateMe.java b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/ActivateMe.java index 9700c997107..c0230a97226 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/ActivateMe.java +++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/ActivateMe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -28,7 +28,5 @@ import java.rmi.Remote; import java.rmi.RemoteException; interface ActivateMe extends Remote { public void ping() throws RemoteException; - public void unregister() throws Exception; public void shutdown() throws Exception; - public void justGoAway() throws RemoteException; } diff --git a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/CallbackInterface.java b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/CallbackInterface.java deleted file mode 100644 index 05512a1de68..00000000000 --- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/CallbackInterface.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2000, 2008, 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.rmi.Remote; -import java.rmi.RemoteException; -public interface CallbackInterface extends Remote { - public void inc() throws RemoteException; - public int getNumDeactivated() throws RemoteException; -} diff --git a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/Callback_Stub.java b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/Callback_Stub.java deleted file mode 100644 index ecf0190e922..00000000000 --- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/Callback_Stub.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2000, 2008, 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// Stub class generated by rmic, do not edit. -// Contents subject to change without notice. - -public final class Callback_Stub - extends java.rmi.server.RemoteStub - implements CallbackInterface, java.rmi.Remote -{ - private static final java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("int getNumDeactivated()"), - new java.rmi.server.Operation("void inc()") - }; - - private static final long interfaceHash = -1008194523112388035L; - - private static final long serialVersionUID = 2; - - private static boolean useNewInvoke; - private static java.lang.reflect.Method $method_getNumDeactivated_0; - private static java.lang.reflect.Method $method_inc_1; - - static { - try { - java.rmi.server.RemoteRef.class.getMethod("invoke", - new java.lang.Class[] { - java.rmi.Remote.class, - java.lang.reflect.Method.class, - java.lang.Object[].class, - long.class - }); - useNewInvoke = true; - $method_getNumDeactivated_0 = CallbackInterface.class.getMethod("getNumDeactivated", new java.lang.Class[] {}); - $method_inc_1 = CallbackInterface.class.getMethod("inc", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - useNewInvoke = false; - } - } - - // constructors - public Callback_Stub() { - super(); - } - public Callback_Stub(java.rmi.server.RemoteRef ref) { - super(ref); - } - - // methods from remote interfaces - - // implementation of getNumDeactivated() - public int getNumDeactivated() - throws java.rmi.RemoteException - { - try { - if (useNewInvoke) { - Object $result = ref.invoke(this, $method_getNumDeactivated_0, null, -761062487639949912L); - return ((java.lang.Integer) $result).intValue(); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - ref.invoke(call); - int $result; - try { - java.io.ObjectInput in = call.getInputStream(); - $result = in.readInt(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } finally { - ref.done(call); - } - return $result; - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } - } - - // implementation of inc() - public void inc() - throws java.rmi.RemoteException - { - try { - if (useNewInvoke) { - ref.invoke(this, $method_inc_1, null, 4394985085384332959L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); - ref.invoke(call); - ref.done(call); - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } - } -} diff --git a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java index 59fee9da723..bc5976b74fe 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java +++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -28,42 +28,22 @@ * @author Ann Wollrath * * @library ../../../testlibrary - * @build TestLibrary RMID ActivationLibrary - * ActivateMe CallbackInterface UnregisterGroup_Stub Callback_Stub - * @run main/othervm/policy=security.policy/timeout=480 UnregisterGroup + * @build TestLibrary RMID ActivationLibrary ActivateMe + * @run main/othervm/policy=security.policy UnregisterGroup */ import java.io.*; import java.rmi.*; import java.rmi.activation.*; import java.rmi.server.*; -import java.rmi.registry.*; import java.util.Properties; -class Callback extends UnicastRemoteObject implements CallbackInterface { - public int num_deactivated = 0; - - public Callback() throws RemoteException { super(); } - - public synchronized void inc() throws RemoteException { - num_deactivated++; - } - - public synchronized int getNumDeactivated() throws RemoteException { - return num_deactivated; - } -} - -public class UnregisterGroup - extends Activatable - implements ActivateMe, Runnable +public class UnregisterGroup extends Activatable implements ActivateMe { - private static Exception exception = null; - private static String error = null; - private static boolean done = false; - private static ActivateMe lastResortExitObj = null; + private static volatile Exception exception = null; + private static volatile String error = null; + private static volatile boolean done = false; private static final int NUM_OBJECTS = 10; - private static int registryPort = -1; public UnregisterGroup(ActivationID id, MarshalledObject mobj) throws Exception @@ -71,69 +51,25 @@ public class UnregisterGroup super(id, 0); } - public void ping() - {} - - public void unregister() throws Exception { - super.unregister(super.getID()); - } + /** + * Does nothing, but serves to activate this object. + */ + public void ping() { } /** - * Spawns a thread to deactivate the object. + * Deactivates the object. We need to unexport forcibly because + * this call is in-progress on this object, which is the same object + * that we are trying to deactivate. */ public void shutdown() throws Exception { - (new Thread(this,"UnregisterGroup")).start(); - } - - /** - * To support exiting of group VM as a last resort - */ - public void justGoAway() { - System.exit(0); - } - - /** - * Thread to deactivate object. Get the callback object from the registry, - * call inc() on it, and finally call deactivate(). The call to - * deactivate() causes this JVM to be destroyed, so anything following - * might not be executed. - */ - public void run() { - String regPortStr = System.getProperty("unregisterGroup.port"); - int regPort = -1; - - if (regPortStr != null) { - regPort = Integer.parseInt(regPortStr); - } - - try { - CallbackInterface cobj = - (CallbackInterface)Naming.lookup("//:" + regPort + "/Callback"); - cobj.inc(); - System.err.println("cobj.inc called and returned ok"); - } catch (Exception e) { - System.err.println("cobj.inc exception"); - e.printStackTrace(); - } - + Activatable.unexportObject(this, true); ActivationLibrary.deactivate(this, getID()); - System.err.println("\tActivationLibrary.deactivate returned"); } public static void main(String[] args) throws RemoteException { - System.err.println("\nRegression test for bug 4134233\n"); TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); RMID rmid = null; - // Create registry and export callback object so they're - // available to the objects that are activated below. - // TODO: see if we can use RMID's registry instead of - // creating one here. - Registry registry = TestLibrary.createRegistryOnUnusedPort(); - registryPort = TestLibrary.getRegistryPort(registry); - Callback robj = new Callback(); - registry.rebind("Callback", robj); - try { RMID.removeLog(); rmid = RMID.createRMID(); @@ -145,11 +81,8 @@ public class UnregisterGroup final Properties p = new Properties(); // this test must always set policies/managers in its // activation groups - p.put("java.security.policy", - TestParams.defaultGroupPolicy); - p.put("java.security.manager", - TestParams.defaultSecurityManager); - p.put("unregisterGroup.port", Integer.toString(registryPort)); + p.put("java.security.policy", TestParams.defaultGroupPolicy); + p.put("java.security.manager", TestParams.defaultSecurityManager); Thread t = new Thread() { public void run () { @@ -173,7 +106,6 @@ public class UnregisterGroup System.err.println("Activating object: " + i); obj[i].ping(); } - lastResortExitObj = obj[0]; System.err.println("Unregistering group"); system.unregisterGroup(groupID); @@ -187,7 +119,6 @@ public class UnregisterGroup "group unregistered"); } - /* * Deactivate objects so group VM will exit. */ @@ -196,7 +127,7 @@ public class UnregisterGroup obj[i].shutdown(); obj[i] = null; } - lastResortExitObj = null; + System.err.println("Successfully deactivated all objects."); } catch (Exception e) { exception = e; @@ -207,7 +138,11 @@ public class UnregisterGroup }; t.start(); - t.join(120000); + + // Default jtreg timeout is two minutes. + // Timeout ourselves after one minute so that + // we can clean up. + t.join(60000); if (exception != null) { TestLibrary.bomb("test failed", exception); @@ -221,31 +156,6 @@ public class UnregisterGroup } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - if (lastResortExitObj != null) { - try { - lastResortExitObj.justGoAway(); - } catch (Exception munch) { - } - } - - // Wait for the object deactivation to take place first - try { - //get the callback object - int maxwait=30; - int nd = robj.getNumDeactivated(); - while ((nd < NUM_OBJECTS) && (maxwait> 0)) { - System.err.println("num_deactivated="+nd); - try { - Thread.sleep(1000); - } catch (InterruptedException ie) {} - maxwait--; - nd = robj.getNumDeactivated(); - } - } catch (Exception ce) { - System.err.println("E:"+ce); - ce.printStackTrace(); - } - ActivationLibrary.rmidCleanup(rmid); } } diff --git a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup_Stub.java b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup_Stub.java deleted file mode 100644 index 4bd96719855..00000000000 --- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup_Stub.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 1998, 2008, 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// Stub class generated by rmic, do not edit. -// Contents subject to change without notice. - -public final class UnregisterGroup_Stub - extends java.rmi.server.RemoteStub - implements ActivateMe, java.rmi.Remote -{ - private static final java.rmi.server.Operation[] operations = { - new java.rmi.server.Operation("void justGoAway()"), - new java.rmi.server.Operation("void ping()"), - new java.rmi.server.Operation("void shutdown()"), - new java.rmi.server.Operation("void unregister()") - }; - - private static final long interfaceHash = -4733924075192691630L; - - private static final long serialVersionUID = 2; - - private static boolean useNewInvoke; - private static java.lang.reflect.Method $method_justGoAway_0; - private static java.lang.reflect.Method $method_ping_1; - private static java.lang.reflect.Method $method_shutdown_2; - private static java.lang.reflect.Method $method_unregister_3; - - static { - try { - java.rmi.server.RemoteRef.class.getMethod("invoke", - new java.lang.Class[] { - java.rmi.Remote.class, - java.lang.reflect.Method.class, - java.lang.Object[].class, - long.class - }); - useNewInvoke = true; - $method_justGoAway_0 = ActivateMe.class.getMethod("justGoAway", new java.lang.Class[] {}); - $method_ping_1 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {}); - $method_shutdown_2 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {}); - $method_unregister_3 = ActivateMe.class.getMethod("unregister", new java.lang.Class[] {}); - } catch (java.lang.NoSuchMethodException e) { - useNewInvoke = false; - } - } - - // constructors - public UnregisterGroup_Stub() { - super(); - } - public UnregisterGroup_Stub(java.rmi.server.RemoteRef ref) { - super(ref); - } - - // methods from remote interfaces - - // implementation of justGoAway() - public void justGoAway() - throws java.rmi.RemoteException - { - try { - if (useNewInvoke) { - ref.invoke(this, $method_justGoAway_0, null, -5382478058620783904L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); - ref.invoke(call); - ref.done(call); - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } - } - - // implementation of ping() - public void ping() - throws java.rmi.RemoteException - { - try { - if (useNewInvoke) { - ref.invoke(this, $method_ping_1, null, 5866401369815527589L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); - ref.invoke(call); - ref.done(call); - } - } catch (java.lang.RuntimeException e) { - throw e; - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.Exception e) { - throw new java.rmi.UnexpectedException("undeclared checked exception", e); - } - } - - // implementation of shutdown() - public void shutdown() - throws java.lang.Exception - { - if (useNewInvoke) { - ref.invoke(this, $method_shutdown_2, null, -7207851917985848402L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash); - ref.invoke(call); - ref.done(call); - } - } - - // implementation of unregister() - public void unregister() - throws java.lang.Exception - { - if (useNewInvoke) { - ref.invoke(this, $method_unregister_3, null, -5366864281862648102L); - } else { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash); - ref.invoke(call); - ref.done(call); - } - } -} diff --git a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/rmid.security.policy b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/rmid.security.policy index fa1bc1e9f83..0e43c5d37ab 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/rmid.security.policy +++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/rmid.security.policy @@ -1,5 +1,4 @@ grant { permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.manager=default"; permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*"; - permission com.sun.rmi.rmid.ExecOptionPermission "-DunregisterGroup.port=*"; };