2
|
1 |
/*
|
|
2 |
* Copyright 2000-2001 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
/* @test
|
|
25 |
* @bug 4289544
|
|
26 |
* @summary ActivationGroupImpl.newInstance does not set context classloader for impl
|
|
27 |
*
|
|
28 |
* @author Laird Dornin; code borrowed from Ann Wollrath
|
|
29 |
*
|
|
30 |
* @library ../../../testlibrary
|
|
31 |
* @build TestLibrary RMID JavaVM StreamPipe
|
|
32 |
* @build MyRMI
|
|
33 |
* @build CheckImplClassLoader ActivatableImpl
|
|
34 |
* @build ActivatableImpl ActivatableImpl_Stub
|
|
35 |
* @run main/othervm/policy=security.policy/timeout=150 CheckImplClassLoader
|
|
36 |
*/
|
|
37 |
|
|
38 |
import java.io.*;
|
|
39 |
import java.rmi.*;
|
|
40 |
import java.rmi.server.*;
|
|
41 |
import java.rmi.activation.*;
|
|
42 |
import java.net.URL;
|
|
43 |
|
|
44 |
/**
|
|
45 |
* sun.rmi.server.ActivationGroupImpl.newInstance() needs to set the
|
|
46 |
* context class loader when it constructs the implementation class of
|
|
47 |
* an Activatable object. It needs to set the ccl to be the class
|
|
48 |
* loader of the implementation class.
|
|
49 |
*
|
|
50 |
* Test creates an Activatable object whose impl is loaded outside of
|
|
51 |
* CLASSPATH. The impls constructor checks to make sure that the
|
|
52 |
* correct context class loader has been set when the constructor is
|
|
53 |
* invoked.
|
|
54 |
*/
|
|
55 |
public class CheckImplClassLoader {
|
|
56 |
|
|
57 |
private static Object dummy = new Object();
|
|
58 |
private static MyRMI myRMI = null;
|
|
59 |
private static ActivationGroup group = null;
|
|
60 |
|
|
61 |
public static void main(String args[]) {
|
|
62 |
/*
|
|
63 |
* The following line is required with the JDK 1.2 VM because
|
|
64 |
* of gc hocus pocus that may no longer be needed with an
|
|
65 |
* exact vm (hotspot).
|
|
66 |
*/
|
|
67 |
Object dummy1 = new Object();
|
|
68 |
RMID rmid = null;
|
|
69 |
|
|
70 |
System.err.println("\nRegression test for bug/rfe 4289544\n");
|
|
71 |
|
|
72 |
try {
|
|
73 |
|
|
74 |
URL implcb = TestLibrary.installClassInCodebase("ActivatableImpl",
|
|
75 |
"implcb");
|
|
76 |
TestLibrary.installClassInCodebase("ActivatableImpl_Stub",
|
|
77 |
"implcb");
|
|
78 |
TestLibrary.suggestSecurityManager(
|
|
79 |
TestParams.defaultSecurityManager);
|
|
80 |
|
|
81 |
RMID.removeLog();
|
|
82 |
rmid = RMID.createRMID();
|
|
83 |
rmid.start();
|
|
84 |
|
|
85 |
System.err.println("Create activation group in this VM");
|
|
86 |
ActivationGroupDesc groupDesc =
|
|
87 |
new ActivationGroupDesc(null, null);
|
|
88 |
ActivationSystem system = ActivationGroup.getSystem();
|
|
89 |
ActivationGroupID groupID = system.registerGroup(groupDesc);
|
|
90 |
group = ActivationGroup.createGroup(groupID, groupDesc, 0);
|
|
91 |
|
|
92 |
ActivationDesc desc = new ActivationDesc("ActivatableImpl",
|
|
93 |
implcb.toString(), null);
|
|
94 |
myRMI = (MyRMI) Activatable.register(desc);
|
|
95 |
|
|
96 |
System.err.println("Checking that impl has correct " +
|
|
97 |
"context class loader");
|
|
98 |
if (!myRMI.classLoaderOk()) {
|
|
99 |
TestLibrary.bomb("incorrect context class loader for " +
|
|
100 |
"activation constructor");
|
|
101 |
}
|
|
102 |
|
|
103 |
System.err.println("Deactivate object via method call");
|
|
104 |
myRMI.shutdown();
|
|
105 |
|
|
106 |
System.err.println("\nsuccess: CheckImplClassLoader test passed ");
|
|
107 |
|
|
108 |
} catch (Exception e) {
|
|
109 |
TestLibrary.bomb("\nfailure: unexpected exception ", e);
|
|
110 |
} finally {
|
|
111 |
try {
|
|
112 |
Thread.sleep(4000);
|
|
113 |
} catch (InterruptedException e) {
|
|
114 |
}
|
|
115 |
|
|
116 |
myRMI = null;
|
|
117 |
System.err.println("rmid shut down");
|
|
118 |
ActivationLibrary.rmidCleanup(rmid);
|
|
119 |
TestLibrary.unexport(group);
|
|
120 |
}
|
|
121 |
}
|
|
122 |
}
|