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 */
23
24 /* @test
25 * @bug 4149366
26 * @summary The class loader used to load classes for parameter types sent in
27 * an RMI call to an activatable object should delegate to the class loader
28 * that loaded the class of the activatable object itself, to maximize the
29 * likelihood of type compatibility between downloaded parameter types and
30 * supertypes shared with the activatable object.
31 * @author Peter Jones (much code taken from Ann Wollrath's activation tests)
32 *
33 * @library ../../../testlibrary
34 * @modules java.rmi/sun.rmi.registry
35 * java.rmi/sun.rmi.server
36 * java.rmi/sun.rmi.transport
37 * java.rmi/sun.rmi.transport.tcp
38 * @build TestLibrary RMID ActivationLibrary
39 * Foo FooReceiverImpl FooReceiverImpl_Stub Bar
40 * @run main/othervm/policy=security.policy/timeout=240 DownloadParameterClass
41 */
42
43 import java.io.*;
44 import java.net.*;
45 import java.util.*;
46 import java.rmi.*;
47 import java.rmi.activation.*;
48 import java.rmi.server.*;
49 import java.rmi.registry.*;
50
51 public class DownloadParameterClass {
52
53 public interface FooReceiver extends Remote {
54
55 /*
56 * The interface can't actually declare that the method takes a
57 * Foo, because then Foo would have to be in the test's CLASSPATH,
58 * which might get propagated to the group VM's CLASSPATH, which
73 * install the subtype to be downloaded into the activatable object
74 * into the "codebase2" subdirectory.
75 */
76 URL codebase1 = null;
77 URL codebase2 = null;
78 try {
79 codebase1 = TestLibrary.installClassInCodebase("FooReceiverImpl", "codebase1");
80 TestLibrary.installClassInCodebase("FooReceiverImpl_Stub", "codebase1");
81 TestLibrary.installClassInCodebase("Foo", "codebase1");
82 codebase2 = TestLibrary.installClassInCodebase("Bar", "codebase2");
83 } catch (MalformedURLException e) {
84 TestLibrary.bomb("failed to install test classes", e);
85 }
86
87 TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
88
89 RMID rmid = null;
90
91 try {
92 RMID.removeLog();
93 rmid = RMID.createRMID();
94 rmid.start();
95
96 /* Cause activation groups to have a security policy that will
97 * allow security managers to be downloaded and installed
98 */
99 Properties p = new Properties();
100 // this test must always set policies/managers in its
101 // activation groups
102 p.put("java.security.policy",
103 TestParams.defaultGroupPolicy);
104 p.put("java.security.manager",
105 TestParams.defaultSecurityManager);
106
107 /*
108 * Create and register descriptors for activatable object in a
109 * group other than this VM's group, so that another VM will be
110 * spawned with the object is activated.
111 */
112 System.err.println("Creating descriptors");
113 ActivationGroupDesc groupDesc =
|
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 */
23
24 /* @test
25 * @bug 4149366
26 * @summary The class loader used to load classes for parameter types sent in
27 * an RMI call to an activatable object should delegate to the class loader
28 * that loaded the class of the activatable object itself, to maximize the
29 * likelihood of type compatibility between downloaded parameter types and
30 * supertypes shared with the activatable object.
31 * @author Peter Jones (much code taken from Ann Wollrath's activation tests)
32 *
33 * @library ../../../testlibrary
34 * @modules java.rmi/sun.rmi.registry
35 * java.rmi/sun.rmi.server
36 * java.rmi/sun.rmi.transport
37 * java.rmi/sun.rmi.transport.tcp
38 * java.base/sun.nio.ch
39 * @build TestLibrary RMID RMIDSelectorProvider ActivationLibrary
40 * Foo FooReceiverImpl FooReceiverImpl_Stub Bar
41 * @run main/othervm/policy=security.policy/timeout=240 DownloadParameterClass
42 */
43
44 import java.io.*;
45 import java.net.*;
46 import java.util.*;
47 import java.rmi.*;
48 import java.rmi.activation.*;
49 import java.rmi.server.*;
50 import java.rmi.registry.*;
51
52 public class DownloadParameterClass {
53
54 public interface FooReceiver extends Remote {
55
56 /*
57 * The interface can't actually declare that the method takes a
58 * Foo, because then Foo would have to be in the test's CLASSPATH,
59 * which might get propagated to the group VM's CLASSPATH, which
74 * install the subtype to be downloaded into the activatable object
75 * into the "codebase2" subdirectory.
76 */
77 URL codebase1 = null;
78 URL codebase2 = null;
79 try {
80 codebase1 = TestLibrary.installClassInCodebase("FooReceiverImpl", "codebase1");
81 TestLibrary.installClassInCodebase("FooReceiverImpl_Stub", "codebase1");
82 TestLibrary.installClassInCodebase("Foo", "codebase1");
83 codebase2 = TestLibrary.installClassInCodebase("Bar", "codebase2");
84 } catch (MalformedURLException e) {
85 TestLibrary.bomb("failed to install test classes", e);
86 }
87
88 TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
89
90 RMID rmid = null;
91
92 try {
93 RMID.removeLog();
94 rmid = RMID.createRMIDOnEphemeralPort();
95 rmid.start();
96
97 /* Cause activation groups to have a security policy that will
98 * allow security managers to be downloaded and installed
99 */
100 Properties p = new Properties();
101 // this test must always set policies/managers in its
102 // activation groups
103 p.put("java.security.policy",
104 TestParams.defaultGroupPolicy);
105 p.put("java.security.manager",
106 TestParams.defaultSecurityManager);
107
108 /*
109 * Create and register descriptors for activatable object in a
110 * group other than this VM's group, so that another VM will be
111 * spawned with the object is activated.
112 */
113 System.err.println("Creating descriptors");
114 ActivationGroupDesc groupDesc =
|