< prev index next >

test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java

Print this page


   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  */


  63         }
  64     }
  65 
  66     public void declareStillAlive() {
  67         synchronized (lock) {
  68             stillAlive = true;
  69             lock.notifyAll();
  70         }
  71     }
  72 
  73     public static void main(String[] args) {
  74 
  75         System.err.println("\nRegression test for bug 4308492\n");
  76 
  77         KeepAliveDuringCall obj = new KeepAliveDuringCall();
  78 
  79         try {
  80             UnicastRemoteObject.exportObject(obj);
  81             System.err.println("exported shutdown monitor");
  82 
  83             Registry localRegistry = TestLibrary.createRegistryOnUnusedPort();
  84             int registryPort = TestLibrary.getRegistryPort(localRegistry);
  85             System.err.println("created local registry");
  86 
  87             localRegistry.bind(BINDING, obj);
  88             System.err.println("bound shutdown monitor in local registry");
  89 
  90             System.err.println("starting remote ShutdownImpl VM...");
  91             (new JavaVM("ShutdownImpl",
  92                         "-Drmi.registry.port=" +
  93                         registryPort, "")).start();
  94 
  95             Shutdown s;
  96             synchronized (obj.lock) {
  97                 System.err.println(
  98                     "waiting for submission of object to shutdown...");
  99                 while ((s = obj.shutdown) == null) {
 100                     obj.lock.wait(TIMEOUT);
 101                 }
 102                 if (s == null) {
 103                     throw new RuntimeException(


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


  63         }
  64     }
  65 
  66     public void declareStillAlive() {
  67         synchronized (lock) {
  68             stillAlive = true;
  69             lock.notifyAll();
  70         }
  71     }
  72 
  73     public static void main(String[] args) {
  74 
  75         System.err.println("\nRegression test for bug 4308492\n");
  76 
  77         KeepAliveDuringCall obj = new KeepAliveDuringCall();
  78 
  79         try {
  80             UnicastRemoteObject.exportObject(obj);
  81             System.err.println("exported shutdown monitor");
  82 
  83             Registry localRegistry = TestLibrary.createRegistryOnEphemeralPort();
  84             int registryPort = TestLibrary.getRegistryPort(localRegistry);
  85             System.err.println("created local registry");
  86 
  87             localRegistry.bind(BINDING, obj);
  88             System.err.println("bound shutdown monitor in local registry");
  89 
  90             System.err.println("starting remote ShutdownImpl VM...");
  91             (new JavaVM("ShutdownImpl",
  92                         "-Drmi.registry.port=" +
  93                         registryPort, "")).start();
  94 
  95             Shutdown s;
  96             synchronized (obj.lock) {
  97                 System.err.println(
  98                     "waiting for submission of object to shutdown...");
  99                 while ((s = obj.shutdown) == null) {
 100                     obj.lock.wait(TIMEOUT);
 101                 }
 102                 if (s == null) {
 103                     throw new RuntimeException(


< prev index next >