6764226: ListTest fails on javap output with bad characters
Reviewed-by: darcy
This commit is contained in:
parent
c85afdbe86
commit
49c8929c4a
@ -82,16 +82,16 @@ public class ListTest {
|
|||||||
String[] args = new String[options.size() + 1];
|
String[] args = new String[options.size() + 1];
|
||||||
options.toArray(args);
|
options.toArray(args);
|
||||||
args[args.length - 1] = testClassName;
|
args[args.length - 1] = testClassName;
|
||||||
String oldOut = runOldJavap(args);
|
byte[] oldOut = runOldJavap(args);
|
||||||
String newOut = runNewJavap(args);
|
byte[] newOut = runNewJavap(args);
|
||||||
boolean ok = oldOut.equals(newOut);
|
boolean ok = equal(oldOut, newOut);
|
||||||
System.err.println((ok ? "pass" : "FAIL") + ": " + testClassName);
|
System.err.println((ok ? "pass" : "FAIL") + ": " + testClassName);
|
||||||
if (!ok && viewResults)
|
if (!ok && viewResults)
|
||||||
view(oldOut, newOut);
|
view(oldOut, newOut);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
String runOldJavap(String[] args) {
|
byte[] runOldJavap(String[] args) {
|
||||||
//System.err.println("OLD: " + Arrays.asList(args));
|
//System.err.println("OLD: " + Arrays.asList(args));
|
||||||
PrintStream oldOut = System.out;
|
PrintStream oldOut = System.out;
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
@ -101,29 +101,34 @@ public class ListTest {
|
|||||||
} finally {
|
} finally {
|
||||||
System.setOut(oldOut);
|
System.setOut(oldOut);
|
||||||
}
|
}
|
||||||
return out.toString();
|
return out.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
String runNewJavap(String[] args) {
|
byte[] runNewJavap(String[] args) {
|
||||||
String[] nArgs = new String[args.length + 2];
|
String[] nArgs = new String[args.length + 2];
|
||||||
nArgs[0] = "-XDcompat";
|
nArgs[0] = "-XDcompat";
|
||||||
nArgs[1] = "-XDignore.symbol.file";
|
nArgs[1] = "-XDignore.symbol.file";
|
||||||
System.arraycopy(args, 0, nArgs, 2, args.length);
|
System.arraycopy(args, 0, nArgs, 2, args.length);
|
||||||
//System.err.println("NEW: " + Arrays.asList(nArgs));
|
//System.err.println("NEW: " + Arrays.asList(nArgs));
|
||||||
StringWriter out = new StringWriter();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
com.sun.tools.javap.Main.run(nArgs, new PrintWriter(out, true));
|
com.sun.tools.javap.Main.run(nArgs,
|
||||||
return out.toString();
|
new PrintWriter(new OutputStreamWriter(out), true));
|
||||||
|
return out.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
File write(String text, String suffix) throws IOException {
|
File write(byte[] text, String suffix) throws IOException {
|
||||||
File f = File.createTempFile("ListTest", suffix);
|
File f = new File("ListTest." + suffix);
|
||||||
FileWriter out = new FileWriter(f);
|
FileOutputStream out = new FileOutputStream(f);
|
||||||
out.write(text);
|
out.write(text);
|
||||||
out.close();
|
out.close();
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void view(String oldOut, String newOut) throws Exception {
|
boolean equal(byte[] a1, byte[] a2) {
|
||||||
|
return Arrays.equals(a1, a2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void view(byte[] oldOut, byte[] newOut) throws Exception {
|
||||||
File oldFile = write(oldOut, "old");
|
File oldFile = write(oldOut, "old");
|
||||||
File newFile = write(newOut, "new");
|
File newFile = write(newOut, "new");
|
||||||
List<String> cmd = new ArrayList<String>();
|
List<String> cmd = new ArrayList<String>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user