4565N/A * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1472N/A * or visit www.oracle.com if you need additional information or have any 1879N/A * @summary A remote object's unreferenced() method should be invoked with the 1879N/A * context class loader set to the same context class loader that would be set 1879N/A * when remote calls for that object are being executed: the object's class's 2062N/A * class loader, or the context class loader set when the remote object was 1879N/A * exported, if it is a child of the remote object's class loader. 3932N/A * @summary Unreferenced.unreferenced(...) threads should run in the nonSystem group. 1879N/A * To complete the fix for, 4182104, RMI unreferenced threads should also 0N/A * run in the nonSystem so that they do not need permissions to modify the 0N/A * system thread group. 0N/A * @author Laird Dornin 0N/A * @library ../../../testlibrary 0N/A * @build TestLibrary UnreferencedContext_Stub 0N/A // turn on security to ensure that the action below will not 0N/A // require extra permissions 0N/A // exercise functionality prohibited by 4214123 0N/A * Set the interval that RMI will request for GC latency (before RMI 0N/A * gets initialized and this property is read) to an unrealistically 0N/A * small value, so that this test shouldn't have to wait too long. 0N/A * This little trick is necessary to make sure that the RMI server 0N/A * threads for objects created on the default port get created 0N/A * before we set our special context class loader, so that they 0N/A * don't *accidentally* inherit it when making the unreferenced() 0N/A * Now create special context class loader before exporting the 0N/A * remote object for real, so that it should be set when the 0N/A * object's unreferenced() method is called. 0N/A "created and set intended context class loader: " +
0N/A "waiting for unreferenced() callback...");
0N/A * This incantation seems sufficient to work around the 0N/A * ramifications of 4164696, so that this test will actually 0N/A * prove something useful about 1.2Beta4 or 1.2FCS before 0N/A * 4171278 was fixed. 0N/A for (
int i =
0; i <
10; i++) {
0N/A "invoked with context class loader: " +
0N/A "TEST PASSED: unreferenced() invoked" +
0N/A " with intended context class loader");
0N/A "TEST FAILED: unreferenced() invoked" +
0N/A " with incorrect context class loader");
0N/A "TEST FAILED: unreferenced() not invoked after " +
0N/A ((
double)
TIMEOUT /
1000.0) +
" seconds or unreferenced failed to create a thread");
0N/A * When all is said and done, try to unexport the remote object 0N/A * so that the VM has a chance to exit.