8024988: javac, LVT test harness should generate tests .class files in the scratch folder
Summary: Set the CLASS_OUTPUT location to the scratch directory. Changed the argument to checkClassFile accordingly.
Reviewed-by: jjg, vromero
--- a/langtools/test/tools/javac/flow/LVTHarness.java Sun Sep 22 20:20:38 2013 -0700
+++ b/langtools/test/tools/javac/flow/LVTHarness.java Mon Sep 23 10:10:07 2013 +0200
@@ -64,6 +64,7 @@
import static javax.tools.StandardLocation.*;
import static com.sun.tools.classfile.LocalVariableTable_attribute.Entry;
+import static javax.tools.JavaFileObject.Kind.SOURCE;
public class LVTHarness {
@@ -73,10 +74,14 @@
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
public static void main(String[] args) throws Exception {
- fm.setLocation(SOURCE_PATH,
- Arrays.asList(new File(System.getProperty("test.src"), "tests")));
- for (JavaFileObject jfo : fm.list(SOURCE_PATH, "",
- Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
+
+ String testDir = System.getProperty("test.src");
+ fm.setLocation(SOURCE_PATH, Arrays.asList(new File(testDir, "tests")));
+
+ // Make sure classes are written to scratch dir.
+ fm.setLocation(CLASS_OUTPUT, Arrays.asList(new File(".")));
+
+ for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(SOURCE), true)) {
new LVTHarness(jfo).check();
}
if (nerrors > 0) {
@@ -86,8 +91,7 @@
JavaFileObject jfo;
- Map<ElementKey, AliveRanges> aliveRangeMap =
- new HashMap<ElementKey, AliveRanges>();
+ Map<ElementKey, AliveRanges> aliveRangeMap = new HashMap<>();
Set<String> declaredKeys = new HashSet<>();
List<ElementKey> seenAliveRanges = new ArrayList<>();
@@ -96,15 +100,19 @@
}
protected void check() throws Exception {
- JavacTask ct = (JavacTask)comp.getTask(null, fm, null, Arrays.asList("-g"),
- null, Arrays.asList(jfo));
- System.err.println("compiling code " + jfo.toString());
+
+ JavacTask ct = (JavacTask) comp.getTask(null, fm, null, Arrays.asList("-g"),
+ null, Arrays.asList(jfo));
+ System.err.println("compiling code " + jfo);
ct.setProcessors(Collections.singleton(new AliveRangeFinder()));
if (!ct.call()) {
throw new AssertionError("Error during compilation");
}
- checkClassFile(new File(jfo.getName().replace(".java", ".class")));
+
+ File javaFile = new File(jfo.getName());
+ File classFile = new File(javaFile.getName().replace(".java", ".class"));
+ checkClassFile(classFile);
//check all candidates have been used up
for (Map.Entry<ElementKey, AliveRanges> entry : aliveRangeMap.entrySet()) {