Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/com/sun/jdi/EvalInterfaceStatic.java
41149 views
1
/*
2
* Copyright (c) 2014, 2018, 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
/*
25
* @test
26
* @bug 8031195
27
* @summary JDB allows evaluation of calls to static interface methods
28
* @comment converted from test/jdk/com/sun/jdi/EvalInterfaceStatic.sh
29
*
30
* @library /test/lib
31
* @build EvalInterfaceStatic
32
* @run main/othervm EvalInterfaceStatic
33
*/
34
35
import lib.jdb.JdbCommand;
36
import lib.jdb.JdbTest;
37
38
/*
39
* The test exercises the ability to invoke static methods on interfaces.
40
* Static interface methods are a new feature added in JDK8.
41
*
42
* The test makes sure that it is possible to invoke an interface
43
* static method and that the static methods are not inherited by extending
44
* interfaces.
45
*/
46
interface EvalStaticInterfaces {
47
static String staticMethod1() {
48
return "base:staticMethod1";
49
}
50
51
static String staticMethod2() {
52
return "base:staticMethod2";
53
}
54
55
public static void main(String[] args) {
56
// prove that these work
57
System.out.println("base staticMethod1(): " + EvalStaticInterfaces.staticMethod1());
58
System.out.println("base staticMethod2(): " + EvalStaticInterfaces.staticMethod2());
59
System.out.println("overridden staticMethod2(): " + ExtendedEvalStaticInterfaces.staticMethod2());
60
System.out.println("base staticMethod3(): " + ExtendedEvalStaticInterfaces.staticMethod3());
61
62
gus();
63
}
64
65
static void gus() {
66
int x = 0; // @1 breakpoint
67
}
68
}
69
70
interface ExtendedEvalStaticInterfaces extends EvalStaticInterfaces {
71
static String staticMethod2() {
72
return "extended:staticMethod2";
73
}
74
75
static String staticMethod3() {
76
return "extended:staticMethod3";
77
}
78
}
79
80
81
public class EvalInterfaceStatic extends JdbTest {
82
public static void main(String argv[]) {
83
new EvalInterfaceStatic().run();
84
}
85
86
private EvalInterfaceStatic() {
87
super(DEBUGGEE_CLASS);
88
}
89
90
private static final String DEBUGGEE_CLASS = EvalStaticInterfaces.class.getName();
91
92
@Override
93
protected void runCases() {
94
setBreakpointsFromTestSource("EvalInterfaceStatic.java", 1);
95
// Run to breakpoint #1
96
jdb.command(JdbCommand.run());
97
98
evalShouldContain("EvalStaticInterfaces.staticMethod1()", "base:staticMethod1");
99
100
evalShouldContain("EvalStaticInterfaces.staticMethod2()", "base:staticMethod2");
101
102
evalShouldNotContain("ExtendedEvalStaticInterfaces.staticMethod1()", "base:staticMethod1");
103
104
evalShouldContain("ExtendedEvalStaticInterfaces.staticMethod2()", "extended:staticMethod2");
105
106
evalShouldContain("ExtendedEvalStaticInterfaces.staticMethod3()", "extended:staticMethod3");
107
108
jdb.contToExit(1);
109
}
110
111
}
112
113