Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/jvmti/GetClassMethods/OverpassMethods.java
41153 views
1
/*
2
* Copyright (c) 2020, 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. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
/**
27
* @test
28
* @bug 8216324
29
* @summary GetClassMethods is confused by the presence of default methods in super interfaces
30
* @requires vm.jvmti
31
* @library /test/lib
32
* @compile OverpassMethods.java
33
* @run main/othervm/native -agentlib:OverpassMethods OverpassMethods
34
* @run main/othervm/native -agentlib:OverpassMethods=maintain_original_method_order OverpassMethods
35
*/
36
37
import java.lang.reflect.Method;
38
import java.util.Arrays;
39
40
public class OverpassMethods {
41
42
static {
43
try {
44
System.loadLibrary("OverpassMethods");
45
} catch (UnsatisfiedLinkError ex) {
46
System.err.println("Could not load OverpassMethods library");
47
System.err.println("java.library.path:" + System.getProperty("java.library.path"));
48
throw ex;
49
}
50
}
51
52
static private void log(Object msg) {
53
System.out.println(String.valueOf(msg));
54
}
55
56
static private native Method[] getJVMTIDeclaredMethods(Class<?> klass);
57
58
public interface Parent {
59
default String def() { return "Parent.def"; }
60
String method0();
61
String method1();
62
}
63
64
public interface Child extends Parent {
65
String method2();
66
}
67
68
public static class Impl implements Child {
69
public String method0() { return "Impl.method0"; }
70
public String method1() { return "Impl.method1"; }
71
public String method2() { return "Impl.method2"; }
72
}
73
74
public static void main(String[] args) {
75
new Impl(); // To get classes initialized
76
77
Method[] reflectMethods = Child.class.getDeclaredMethods();
78
Method[] jvmtiMethods = getJVMTIDeclaredMethods(Child.class);
79
80
if (jvmtiMethods == null) {
81
throw new RuntimeException("getJVMTIDeclaredMethods failed");
82
}
83
84
log("Reflection getDeclaredMethods returned: " + Arrays.toString(reflectMethods));
85
log("JVMTI GetClassMethods returned: " + Arrays.toString(jvmtiMethods));
86
87
if (reflectMethods.length != jvmtiMethods.length) {
88
throw new RuntimeException("OverpassMethods failed: Unexpected method count from JVMTI GetClassMethods!");
89
}
90
if (!reflectMethods[0].equals(jvmtiMethods[0])) {
91
throw new RuntimeException("OverpassMethods failed: Unexpected method from JVMTI GetClassMethods!");
92
}
93
log("Test passed: Got expected output from JVMTI GetClassMethods!");
94
}
95
}
96
97