mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8024988: javac, LVT test harness should generate tests .class files in the scratch folder
Set the CLASS_OUTPUT location to the scratch directory. Changed the argument to checkClassFile accordingly. Reviewed-by: jjg, vromero
This commit is contained in:
parent
186556ad21
commit
a2a38c6b65
1 changed files with 18 additions and 10 deletions
|
@ -64,6 +64,7 @@ import com.sun.tools.classfile.Method;
|
||||||
|
|
||||||
import static javax.tools.StandardLocation.*;
|
import static javax.tools.StandardLocation.*;
|
||||||
import static com.sun.tools.classfile.LocalVariableTable_attribute.Entry;
|
import static com.sun.tools.classfile.LocalVariableTable_attribute.Entry;
|
||||||
|
import static javax.tools.JavaFileObject.Kind.SOURCE;
|
||||||
|
|
||||||
public class LVTHarness {
|
public class LVTHarness {
|
||||||
|
|
||||||
|
@ -73,10 +74,14 @@ public class LVTHarness {
|
||||||
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
fm.setLocation(SOURCE_PATH,
|
|
||||||
Arrays.asList(new File(System.getProperty("test.src"), "tests")));
|
String testDir = System.getProperty("test.src");
|
||||||
for (JavaFileObject jfo : fm.list(SOURCE_PATH, "",
|
fm.setLocation(SOURCE_PATH, Arrays.asList(new File(testDir, "tests")));
|
||||||
Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
|
|
||||||
|
// 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();
|
new LVTHarness(jfo).check();
|
||||||
}
|
}
|
||||||
if (nerrors > 0) {
|
if (nerrors > 0) {
|
||||||
|
@ -86,8 +91,7 @@ public class LVTHarness {
|
||||||
|
|
||||||
|
|
||||||
JavaFileObject jfo;
|
JavaFileObject jfo;
|
||||||
Map<ElementKey, AliveRanges> aliveRangeMap =
|
Map<ElementKey, AliveRanges> aliveRangeMap = new HashMap<>();
|
||||||
new HashMap<ElementKey, AliveRanges>();
|
|
||||||
Set<String> declaredKeys = new HashSet<>();
|
Set<String> declaredKeys = new HashSet<>();
|
||||||
List<ElementKey> seenAliveRanges = new ArrayList<>();
|
List<ElementKey> seenAliveRanges = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -96,15 +100,19 @@ public class LVTHarness {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void check() throws Exception {
|
protected void check() throws Exception {
|
||||||
JavacTask ct = (JavacTask)comp.getTask(null, fm, null, Arrays.asList("-g"),
|
|
||||||
null, Arrays.asList(jfo));
|
JavacTask ct = (JavacTask) comp.getTask(null, fm, null, Arrays.asList("-g"),
|
||||||
System.err.println("compiling code " + jfo.toString());
|
null, Arrays.asList(jfo));
|
||||||
|
System.err.println("compiling code " + jfo);
|
||||||
ct.setProcessors(Collections.singleton(new AliveRangeFinder()));
|
ct.setProcessors(Collections.singleton(new AliveRangeFinder()));
|
||||||
if (!ct.call()) {
|
if (!ct.call()) {
|
||||||
throw new AssertionError("Error during compilation");
|
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
|
//check all candidates have been used up
|
||||||
for (Map.Entry<ElementKey, AliveRanges> entry : aliveRangeMap.entrySet()) {
|
for (Map.Entry<ElementKey, AliveRanges> entry : aliveRangeMap.entrySet()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue