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/Activatable/nonExistentActivatable/NonExistentActivatable.java
38918 views
1
/*
2
* Copyright (c) 1998, 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 4115296
26
* @summary synopsis: NoSuchObjectException not thrown for non-existent
27
* activatable objects
28
* @author Ann Wollrath
29
*
30
* @library ../../../testlibrary
31
* @build TestLibrary RMID ActivationLibrary
32
* ActivateMe NonExistentActivatable_Stub
33
* @run main/othervm/policy=security.policy/timeout=240 NonExistentActivatable
34
*/
35
36
import java.io.*;
37
import java.rmi.*;
38
import java.rmi.activation.*;
39
import java.rmi.server.*;
40
import java.rmi.registry.*;
41
import java.util.Properties;
42
43
public class NonExistentActivatable
44
extends Activatable
45
implements ActivateMe, Runnable
46
{
47
48
public NonExistentActivatable(ActivationID id, MarshalledObject obj)
49
throws ActivationException, RemoteException
50
{
51
super(id, 0);
52
}
53
54
public void ping()
55
{}
56
57
public void unregister() throws Exception {
58
super.unregister(super.getID());
59
}
60
61
/**
62
* Spawns a thread to deactivate the object.
63
*/
64
public void shutdown() throws Exception
65
{
66
(new Thread(this,"NonExistentActivatable")).start();
67
}
68
69
/**
70
* Thread to deactivate object. First attempts to make object
71
* inactive (via the inactive method). If that fails (the
72
* object may still have pending/executing calls), then
73
* unexport the object forcibly.
74
*/
75
public void run()
76
{
77
ActivationLibrary.deactivate(this, getID());
78
}
79
80
public static void main(String[] args) {
81
82
System.out.println("\nRegression test for bug 4115331\n");
83
84
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
85
86
RMID rmid = null;
87
88
try {
89
RMID.removeLog();
90
rmid = RMID.createRMID();
91
rmid.start();
92
93
/* Cause activation groups to have a security policy that will
94
* allow security managers to be downloaded and installed
95
*/
96
Properties p = new Properties();
97
// this test must always set policies/managers in its
98
// activation groups
99
p.put("java.security.policy",
100
TestParams.defaultGroupPolicy);
101
p.put("java.security.manager",
102
TestParams.defaultSecurityManager);
103
104
System.err.println("Create activation group in this VM");
105
ActivationGroupDesc groupDesc =
106
new ActivationGroupDesc(p, null);
107
ActivationSystem system = ActivationGroup.getSystem();
108
ActivationGroupID groupID = system.registerGroup(groupDesc);
109
ActivationGroup.createGroup(groupID, groupDesc, 0);
110
111
System.err.println("Creating descriptor");
112
ActivationDesc desc =
113
new ActivationDesc("NonExistentActivatable", null, null);
114
115
System.err.println("Registering descriptor");
116
ActivateMe obj = (ActivateMe) Activatable.register(desc);
117
118
System.err.println("Activate object via method call");
119
obj.ping();
120
121
System.err.println("Unregister object");
122
obj.unregister();
123
124
System.err.println("Make object inactive");
125
obj.shutdown();
126
127
System.err.println("Reactivate object");
128
try {
129
obj.ping();
130
} catch (NoSuchObjectException e) {
131
System.err.println("Test succeeded: " +
132
"NoSuchObjectException caught");
133
return;
134
} catch (Exception e) {
135
TestLibrary.bomb("Test failed: exception other than NoSuchObjectException",
136
e);
137
}
138
139
} catch (Exception e) {
140
TestLibrary.bomb("test failed", e);
141
} finally {
142
ActivationLibrary.rmidCleanup(rmid);
143
}
144
}
145
}
146
147