Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/com/sun/management/DiagnosticCommandMBean/DcmdMBeanTestCheckJni.java
41155 views
1
/*
2
* Copyright (c) 2021, Red Hat, Inc.
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
/*
25
* @test
26
* @bug 8258836
27
* @summary JNI local refs exceed capacity getDiagnosticCommandInfo
28
* @library /test/lib
29
* @run main/othervm DcmdMBeanTestCheckJni
30
*/
31
32
import java.lang.management.ManagementFactory;
33
import javax.management.MBeanServer;
34
import javax.management.ObjectName;
35
import javax.management.MBeanServerConnection;
36
import javax.management.remote.JMXConnectorFactory;
37
import javax.management.remote.JMXConnector;
38
import javax.management.remote.JMXConnectorServerFactory;
39
import javax.management.remote.JMXServiceURL;
40
import javax.management.remote.JMXConnectorServer;
41
42
import jdk.test.lib.process.OutputAnalyzer;
43
import jdk.test.lib.process.ProcessTools;
44
45
public class DcmdMBeanTestCheckJni {
46
47
public static void main(String[] args) throws Exception {
48
OutputAnalyzer out = ProcessTools.executeTestJvm(
49
"-Xcheck:jni",
50
DcmdMBeanRunner.class.getName());
51
out.shouldNotMatch("WARNING: JNI local refs: \\d+, exceeds capacity: \\d+\\s+" +
52
"at com.sun.management.internal.DiagnosticCommandImpl.getDiagnosticCommandInfo")
53
.shouldContain("DcmdMBeanRunner COMPLETE")
54
.shouldHaveExitValue(0);
55
}
56
57
}
58
59
class DcmdMBeanRunner {
60
61
private static final String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
62
"com.sun.management:type=DiagnosticCommand";
63
64
public static void main(String[] args) throws Exception {
65
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
66
JMXServiceURL url = new JMXServiceURL("rmi", null, 0);
67
JMXConnectorServer cs = null;
68
JMXConnector cc = null;
69
try {
70
cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
71
cs.start();
72
JMXServiceURL addr = cs.getAddress();
73
cc = JMXConnectorFactory.connect(addr);
74
MBeanServerConnection mbsc = cc.getMBeanServerConnection();
75
ObjectName name = new ObjectName(HOTSPOT_DIAGNOSTIC_MXBEAN_NAME);
76
System.out.println("DiagnosticCommand MBean: " + name);
77
System.out.println("DcmdMBeanRunner COMPLETE");
78
} finally {
79
try {
80
cc.close();
81
cs.stop();
82
} catch (Exception e) { /* ignored */ }
83
}
84
}
85
}
86
87