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/elucidateNoSuchMethod/ElucidateNoSuchMethod.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 4128620
26
* @summary synopsis: NoSuchMethodError should be elucidated
27
* @author Laird Dornin
28
*
29
* @library ../../../testlibrary
30
* @build TestLibrary RMID ActivateMe ElucidateNoSuchMethod_Stub
31
* @run main/othervm/policy=security.policy/timeout=240 ElucidateNoSuchMethod
32
*/
33
34
import java.io.*;
35
import java.rmi.*;
36
import java.rmi.activation.*;
37
import java.rmi.server.*;
38
import java.rmi.registry.*;
39
import java.util.Properties;
40
41
public class ElucidateNoSuchMethod
42
extends Activatable
43
implements ActivateMe, Runnable
44
{
45
46
/**
47
* provide a constructor that alllows this object to be made
48
* activatable, or at least registered.
49
*/
50
ElucidateNoSuchMethod(ActivationID id, int port)
51
throws RemoteException
52
{
53
super(id, port);
54
}
55
56
/**
57
* dont provide an activation constructor so that we get a no such
58
* method error.
59
*/
60
61
public void ping() {}
62
63
/**
64
* Spawns a thread to deactivate the object.
65
*/
66
public void shutdown() throws Exception {
67
(new Thread(this,"ElucidateNoSuchMethod")).start();
68
}
69
70
/**
71
* Thread to deactivate object. First attempts to make object
72
* inactive (via the inactive method). If that fails (the
73
* object may still have pending/executing calls), then
74
* unexport the object forcibly.
75
*/
76
public void run() {
77
ActivationLibrary.deactivate(this, getID());
78
}
79
80
public static void main(String[] args) {
81
82
System.out.println("\nRegression test for 4128620 \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("ElucidateNoSuchMethod", 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
120
try {
121
obj.ping();
122
} catch (ActivateFailedException afe) {
123
ActivationException a = (ActivationException) afe.detail;
124
125
if (((a.detail instanceof NoSuchMethodException) ||
126
(a.detail instanceof NoSuchMethodError)) &&
127
(a.getMessage().indexOf
128
("must provide an activation constructor") > -1)) {
129
System.err.println("\ntest passed for 4128620\n");
130
} else {
131
TestLibrary.bomb("test failed", afe);
132
}
133
}
134
135
} catch (Exception e) {
136
TestLibrary.bomb("test failed", e);
137
} finally {
138
ActivationLibrary.rmidCleanup(rmid);
139
}
140
}
141
}
142
143