test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java

Print this page

        

*** 1,7 **** /* ! * 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. --- 1,7 ---- /* ! * Copyright (c) 2000, 2012, 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.
*** 26,61 **** * @summary synopsis: unexporting doesn't guarantee that DGC will * let go of remote object * * @author Ann Wollrath * * @build UnexportLeak * @build UnexportLeak_Stub * @build Ping * @run main/othervm UnexportLeak */ import java.lang.ref.*; import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; public class UnexportLeak implements Ping { - - private static int PORT = 2006; - public void ping() { } public static void main(String[] args) { try { System.err.println("\nRegression test for bug 4331349\n"); ! LocateRegistry.createRegistry(PORT); Remote obj = new UnexportLeak(); WeakReference wr = new WeakReference(obj); UnicastRemoteObject.exportObject(obj); ! LocateRegistry.getRegistry(PORT).rebind("UnexportLeak", obj); UnicastRemoteObject.unexportObject(obj, true); obj = null; flushRefs(); if (wr.get() != null) { System.err.println("FAILED: unexported object not collected"); --- 26,61 ---- * @summary synopsis: unexporting doesn't guarantee that DGC will * let go of remote object * * @author Ann Wollrath * + * @library ../../../testlibrary * @build UnexportLeak * @build UnexportLeak_Stub + * @build TestLibrary * @build Ping * @run main/othervm UnexportLeak */ import java.lang.ref.*; import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; public class UnexportLeak implements Ping { public void ping() { } public static void main(String[] args) { try { System.err.println("\nRegression test for bug 4331349\n"); ! Registry registry = TestLibrary.createRegistryOnUnusedPort(); ! int registryPort = TestLibrary.getRegistryPort(registry); Remote obj = new UnexportLeak(); WeakReference wr = new WeakReference(obj); UnicastRemoteObject.exportObject(obj); ! LocateRegistry.getRegistry(registryPort).rebind("UnexportLeak", obj); UnicastRemoteObject.unexportObject(obj, true); obj = null; flushRefs(); if (wr.get() != null) { System.err.println("FAILED: unexported object not collected");