< prev index next >

test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java

Print this page


   1 /*
   2  * Copyright (c) 1998, 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  */


  64         }
  65     }
  66 
  67     public static void main(String[] args) {
  68 
  69         System.err.println("\nRegression test for bug 4164696\n");
  70 
  71         /*
  72          * Set the interval that RMI will request for GC latency (before RMI
  73          * gets initialized and this property is read) to an unrealistically
  74          * small value, so that this test shouldn't have to wait too long.
  75          */
  76         System.setProperty("sun.rmi.dgc.client.gcInterval",
  77             String.valueOf(GC_INTERVAL));
  78 
  79         FiniteGCLatency obj = new FiniteGCLatency();
  80 
  81         try {
  82             UnicastRemoteObject.exportObject(obj);
  83             System.err.println("exported remote object");
  84             Registry registry1 = TestLibrary.createRegistryOnUnusedPort();
  85             int port = TestLibrary.getRegistryPort(registry1);
  86             System.err.println("created registry");
  87 
  88             Registry registry = LocateRegistry.getRegistry("", port);
  89             registry.bind(BINDING, obj);
  90             System.err.println("bound remote object in registry");
  91 
  92             synchronized (obj.lock) {
  93                 registry.unbind(BINDING);
  94                 System.err.println("unbound remote object from registry; " +
  95                     "waiting for unreferenced() callback...");
  96                 obj.lock.wait(TIMEOUT);
  97 
  98                 if (obj.unreferencedInvoked) {
  99                     System.err.println("TEST PASSED: unreferenced() invoked");
 100                 } else {
 101                     throw new RuntimeException(
 102                         "TEST FAILED: unrefereced() not invoked after " +
 103                         ((double) TIMEOUT / 1000.0) + " seconds");
 104                 }


   1 /*
   2  * Copyright (c) 1998, 2016, 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  */


  64         }
  65     }
  66 
  67     public static void main(String[] args) {
  68 
  69         System.err.println("\nRegression test for bug 4164696\n");
  70 
  71         /*
  72          * Set the interval that RMI will request for GC latency (before RMI
  73          * gets initialized and this property is read) to an unrealistically
  74          * small value, so that this test shouldn't have to wait too long.
  75          */
  76         System.setProperty("sun.rmi.dgc.client.gcInterval",
  77             String.valueOf(GC_INTERVAL));
  78 
  79         FiniteGCLatency obj = new FiniteGCLatency();
  80 
  81         try {
  82             UnicastRemoteObject.exportObject(obj);
  83             System.err.println("exported remote object");
  84             Registry registry1 = TestLibrary.createRegistryOnEphemeralPort();
  85             int port = TestLibrary.getRegistryPort(registry1);
  86             System.err.println("created registry");
  87 
  88             Registry registry = LocateRegistry.getRegistry("", port);
  89             registry.bind(BINDING, obj);
  90             System.err.println("bound remote object in registry");
  91 
  92             synchronized (obj.lock) {
  93                 registry.unbind(BINDING);
  94                 System.err.println("unbound remote object from registry; " +
  95                     "waiting for unreferenced() callback...");
  96                 obj.lock.wait(TIMEOUT);
  97 
  98                 if (obj.unreferencedInvoked) {
  99                     System.err.println("TEST PASSED: unreferenced() invoked");
 100                 } else {
 101                     throw new RuntimeException(
 102                         "TEST FAILED: unrefereced() not invoked after " +
 103                         ((double) TIMEOUT / 1000.0) + " seconds");
 104                 }


< prev index next >