34
import java.lang.reflect.*;
38
public class T6627362 {
39
static String testSrc = System.getProperty("test.src", ".");
41
public static void main(String... args) throws Exception {
45
public void run() throws Exception {
49
throw new Error(errors + " test cases failed");
52
void testStandard() throws Exception {
54
File x = new File(testSrc, "x");
55
String[] jcArgs = { "-d", ".",
56
new File(x, "E.java").getPath() };
59
String[] jpArgs = { "-classpath", ".", "-c", "E" };
61
StringWriter sw = new StringWriter();
62
javap(new PrintWriter(sw, true), jpArgs);
63
check(sw.toString(), "Method \"[LE;\".clone:()Ljava/lang/Object;");
67
void testNoClone() throws Exception {
70
File x = new File(testSrc, "x");
71
String[] jcArgs = { "-d", ".", "--patch-module", "java.base=" + x.getAbsolutePath(),
72
new File(x, "E.java").getPath(),
73
new File(new File(new File(x, "java"), "lang"), "Object.java").getPath()};
76
String[] jpArgs = { "-classpath", ".", "-c", "E" };
78
StringWriter sw = new StringWriter();
79
javap(new PrintWriter(sw, true), jpArgs);
80
check(sw.toString(), "// Method java/lang/System.arraycopy:(Ljava/lang/Object;ILjava/lang/Object;II)V");
84
void compile(String... args) {
85
int rc = com.sun.tools.javac.Main.compile(args);
87
throw new Error("javac failed: " + Arrays.asList(args) + ": " + rc);
90
void javap(PrintWriter out, String... args) throws Exception {
91
int rc = com.sun.tools.javap.Main.run(args, out);
93
throw new Error("javap failed: " + Arrays.asList(args) + ": " + rc);
96
void check(String s, String require) {
97
System.out.println("Checking:\n" + s);
98
if (s.indexOf(require) == -1) {
99
System.err.println("Can't find " + require);
106
File dot = new File(System.getProperty("user.dir"));
107
ClassLoader cl = new URLClassLoader(new URL[] { dot.toURL() });
108
Class<?> e_class = cl.loadClass("E");
109
Method m = e_class.getMethod("values", new Class[] { });
111
Object o = m.invoke(null, (Object[]) null);
112
List<Object> v = Arrays.asList((Object[]) o);
113
if (!v.toString().equals("[a, b, c]"))
114
throw new Error("unexpected result for E.values(): " + v);
115
} catch (Exception e) {