70 } 71 72 public static void main(String[] args) throws Exception { 73 74 System.err.println("\nRegression test for bug 4285878\n"); 75 76 /* 77 * Set the duration of leases granted to a very small value, so that 78 * we can test if expirations are detected in a roughly comparable 79 * time. 80 */ 81 System.setProperty("java.rmi.dgc.leaseValue", 82 String.valueOf(LEASE_VALUE)); 83 84 LeaseCheckInterval obj = new LeaseCheckInterval(); 85 86 try { 87 UnicastRemoteObject.exportObject(obj); 88 System.err.println("exported remote object"); 89 90 Registry localRegistry = 91 LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); 92 System.err.println("created local registry"); 93 94 localRegistry.bind(BINDING, obj); 95 System.err.println("bound remote object in local registry"); 96 97 synchronized (obj.lock) { 98 System.err.println("starting remote client VM..."); 99 (new JavaVM("SelfTerminator")).start(); 100 101 System.err.println("waiting for unreferenced() callback..."); 102 obj.lock.wait(TIMEOUT); 103 104 if (obj.unreferencedInvoked) { 105 System.err.println("TEST PASSED: " + 106 "unreferenced() invoked in timely fashion"); 107 } else { 108 throw new RuntimeException( 109 "TEST FAILED: unreferenced() not invoked after " + 110 ((double) TIMEOUT / 1000.0) + " seconds"); 111 } 112 } 113 114 } catch (Exception e) { 115 if (e instanceof RuntimeException) { 116 throw (RuntimeException) e; 117 } else { 118 throw new RuntimeException( 119 "TEST FAILED: unexpected exception: " + e.toString()); | 70 } 71 72 public static void main(String[] args) throws Exception { 73 74 System.err.println("\nRegression test for bug 4285878\n"); 75 76 /* 77 * Set the duration of leases granted to a very small value, so that 78 * we can test if expirations are detected in a roughly comparable 79 * time. 80 */ 81 System.setProperty("java.rmi.dgc.leaseValue", 82 String.valueOf(LEASE_VALUE)); 83 84 LeaseCheckInterval obj = new LeaseCheckInterval(); 85 86 try { 87 UnicastRemoteObject.exportObject(obj); 88 System.err.println("exported remote object"); 89 90 int registryPort = TestLibrary.getUnusedRandomPort(); 91 Registry localRegistry = 92 LocateRegistry.createRegistry(registryPort); 93 System.err.println("created local registry"); 94 95 localRegistry.bind(BINDING, obj); 96 System.err.println("bound remote object in local registry"); 97 98 synchronized (obj.lock) { 99 System.err.println("starting remote client VM..."); 100 (new JavaVM("SelfTerminator", "-Drmi.registry.port=" + 101 registryPort, "")).start(); 102 103 System.err.println("waiting for unreferenced() callback..."); 104 obj.lock.wait(TIMEOUT); 105 106 if (obj.unreferencedInvoked) { 107 System.err.println("TEST PASSED: " + 108 "unreferenced() invoked in timely fashion"); 109 } else { 110 throw new RuntimeException( 111 "TEST FAILED: unreferenced() not invoked after " + 112 ((double) TIMEOUT / 1000.0) + " seconds"); 113 } 114 } 115 116 } catch (Exception e) { 117 if (e instanceof RuntimeException) { 118 throw (RuntimeException) e; 119 } else { 120 throw new RuntimeException( 121 "TEST FAILED: unexpected exception: " + e.toString()); |