Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javap/T6729471.java
32285 views
1
/*
2
* Copyright (c) 2009, 2010, 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
/*
26
* @test
27
* @bug 6729471
28
* @summary javap does not output inner interfaces of an interface
29
*/
30
31
import java.io.*;
32
import java.net.*;
33
import java.util.*;
34
35
public class T6729471
36
{
37
public static void main(String... args) {
38
new T6729471().run();
39
}
40
41
void run() {
42
File testClasses = new File(System.getProperty("test.classes"));
43
44
// simple class
45
verify("java.util.Map",
46
"public abstract boolean containsKey(java.lang.Object)");
47
48
// inner class
49
verify("java.util.Map.Entry",
50
"public abstract K getKey()");
51
52
// file name
53
verify(new File(testClasses, "T6729471.class").getPath(),
54
"public static void main(java.lang.String...)");
55
56
// file url
57
verify(new File(testClasses, "T6729471.class").toURI().toString(),
58
"public static void main(java.lang.String...)");
59
60
// jar url: rt.jar
61
File java_home = new File(System.getProperty("java.home"));
62
if (java_home.getName().equals("jre"))
63
java_home = java_home.getParentFile();
64
File rt_jar = new File(new File(new File(java_home, "jre"), "lib"), "rt.jar");
65
try {
66
verify("jar:" + rt_jar.toURL() + "!/java/util/Map.class",
67
"public abstract boolean containsKey(java.lang.Object)");
68
} catch (MalformedURLException e) {
69
error(e.toString());
70
}
71
72
// jar url: ct.sym, if it exists
73
File ct_sym = new File(new File(java_home, "lib"), "ct.sym");
74
if (ct_sym.exists()) {
75
try {
76
verify("jar:" + ct_sym.toURL() + "!/META-INF/sym/rt.jar/java/util/Map.class",
77
"public abstract boolean containsKey(java.lang.Object)");
78
} catch (MalformedURLException e) {
79
error(e.toString());
80
}
81
} else
82
System.err.println("warning: ct.sym not found");
83
84
if (errors > 0)
85
throw new Error(errors + " found.");
86
}
87
88
void verify(String className, String... expects) {
89
String output = javap(className);
90
for (String expect: expects) {
91
if (output.indexOf(expect)< 0)
92
error(expect + " not found");
93
}
94
}
95
96
void error(String msg) {
97
System.err.println(msg);
98
errors++;
99
}
100
101
int errors;
102
103
String javap(String className) {
104
String testClasses = System.getProperty("test.classes", ".");
105
StringWriter sw = new StringWriter();
106
PrintWriter out = new PrintWriter(sw);
107
String[] args = { "-classpath", testClasses, className };
108
int rc = com.sun.tools.javap.Main.run(args, out);
109
out.close();
110
String output = sw.toString();
111
System.out.println("class " + className);
112
System.out.println(output);
113
if (rc != 0)
114
throw new Error("javap failed. rc=" + rc);
115
if (output.indexOf("Error:") != -1)
116
throw new Error("javap reported error.");
117
return output;
118
}
119
}
120
121
122