Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java
38889 views
1
/*
2
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. 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 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 4720528
26
* @summary synopsis: (spec) ActivationSystem.activeGroup spec should be
27
* relaxed (duplicate call to activeGroup with same instantiator and
28
* incarnation should not throw ActivationException; it should succeed)
29
* @author Ann Wollrath
30
*
31
* @library ../../../testlibrary
32
* @build TestLibrary RMID ActivationLibrary
33
* @run main/othervm/policy=security.policy/timeout=480 IdempotentActiveGroup
34
*/
35
36
import java.rmi.MarshalledObject;
37
import java.rmi.NoSuchObjectException;
38
import java.rmi.RemoteException;
39
import java.rmi.activation.ActivationDesc;
40
import java.rmi.activation.ActivationException;
41
import java.rmi.activation.ActivationGroup;
42
import java.rmi.activation.ActivationGroupDesc;
43
import java.rmi.activation.ActivationGroupID;
44
import java.rmi.activation.ActivationID;
45
import java.rmi.activation.ActivationInstantiator;
46
import java.rmi.activation.ActivationSystem;
47
import java.rmi.server.UnicastRemoteObject;
48
49
public class IdempotentActiveGroup {
50
51
public static void main(String[] args) {
52
53
System.err.println("\nRegression test for bug 4720528\n");
54
55
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
56
RMID rmid = null;
57
ActivationInstantiator inst1 = null;
58
ActivationInstantiator inst2 = null;
59
60
try {
61
RMID.removeLog();
62
rmid = RMID.createRMID();
63
rmid.start();
64
65
System.err.println("Create group descriptor");
66
ActivationGroupDesc groupDesc =
67
new ActivationGroupDesc(null, null);
68
ActivationSystem system = ActivationGroup.getSystem();
69
System.err.println("Register group descriptor");
70
ActivationGroupID groupID = system.registerGroup(groupDesc);
71
inst1 = new FakeInstantiator();
72
inst2 = new FakeInstantiator();
73
74
System.err.println("Invoke activeGroup with inst1");
75
system.activeGroup(groupID, inst1, 0);
76
77
try {
78
System.err.println("Invoke activeGroup with inst2");
79
system.activeGroup(groupID, inst2, 0);
80
throw new RuntimeException(
81
"TEST FAILED: activeGroup with unequal groups succeeded!");
82
} catch (ActivationException expected) {
83
System.err.println("Caught expected ActivationException");
84
System.err.println("Test 1 (of 2) passed");
85
}
86
87
try {
88
System.err.println("Invoke activeGroup with inst1");
89
system.activeGroup(groupID, inst1, 0);
90
System.err.println("activeGroup call succeeded");
91
System.err.println("Test 2 (of 2) passed");
92
} catch (ActivationException unexpected) {
93
throw new RuntimeException(
94
"TEST FAILED: activeGroup with equal groups failed!",
95
unexpected);
96
}
97
98
} catch (Exception e) {
99
TestLibrary.bomb("test failed", e);
100
} finally {
101
try {
102
if (inst1 != null) {
103
UnicastRemoteObject.unexportObject(inst1, true);
104
}
105
if (inst2 != null) {
106
UnicastRemoteObject.unexportObject(inst2, true);
107
}
108
} catch (NoSuchObjectException unexpected) {
109
throw new AssertionError(unexpected);
110
}
111
ActivationLibrary.rmidCleanup(rmid);
112
}
113
}
114
115
private static class FakeInstantiator
116
extends UnicastRemoteObject
117
implements ActivationInstantiator
118
{
119
FakeInstantiator() throws RemoteException {}
120
121
public MarshalledObject newInstance(ActivationID id,
122
ActivationDesc desc)
123
{
124
throw new AssertionError();
125
}
126
}
127
}
128
129