< prev index next >

langtools/test/tools/jdeps/APIDeps.java

Print this page




  43 import java.util.stream.Collectors;
  44 
  45 public class APIDeps {
  46     public static void main(String... args) throws Exception {
  47         int errors = 0;
  48         errors += new APIDeps().run();
  49         if (errors > 0)
  50             throw new Exception(errors + " errors found");
  51     }
  52 
  53     private static final Path dest = Paths.get(System.getProperty("test.classes", "."), "tmp");
  54     private static final String[] srcDirs = new String[] {
  55             "m", "b", "c", "d", "e", "f", "g"
  56     };
  57     void setup(Path dest) throws IOException {
  58         CompilerUtils.cleanDir(dest);
  59         Files.createDirectories(dest);
  60         Path testsrc = Paths.get(System.getProperty("test.src"));
  61         List<String> options = new ArrayList<>();
  62 
  63         // add -XaddExports
  64         String testModules = System.getProperty("test.modules", "");
  65         List<String> addExports = new ArrayList<>();
  66         for (String s : testModules.split("\\s+")) {
  67             if (s.isEmpty()) continue;
  68             if (s.indexOf('/') != -1)
  69                 addExports.add("-XaddExports:" + s.trim() + "=ALL-UNNAMED");
  70         }
  71         options.addAll(addExports);
  72 
  73         for (String dir : srcDirs) {
  74             Path source = testsrc.resolve(dir);
  75             boolean ok = CompilerUtils.compile(source, dest, options.toArray(new String[0]));
  76             if (!ok) {
  77                 throw new RuntimeException("compilation fails");
  78             }
  79         }
  80     }
  81 
  82     int run() throws IOException {
  83         // compile classes in a separate directory for analysis
  84         setup(dest);
  85 
  86         File testDir = dest.toFile();
  87         String testDirBasename = testDir.toPath().getFileName().toString();
  88         File mDir = new File(testDir, "m");
  89         // all dependencies




  43 import java.util.stream.Collectors;
  44 
  45 public class APIDeps {
  46     public static void main(String... args) throws Exception {
  47         int errors = 0;
  48         errors += new APIDeps().run();
  49         if (errors > 0)
  50             throw new Exception(errors + " errors found");
  51     }
  52 
  53     private static final Path dest = Paths.get(System.getProperty("test.classes", "."), "tmp");
  54     private static final String[] srcDirs = new String[] {
  55             "m", "b", "c", "d", "e", "f", "g"
  56     };
  57     void setup(Path dest) throws IOException {
  58         CompilerUtils.cleanDir(dest);
  59         Files.createDirectories(dest);
  60         Path testsrc = Paths.get(System.getProperty("test.src"));
  61         List<String> options = new ArrayList<>();
  62 
  63         // add --add-exports
  64         String testModules = System.getProperty("test.modules", "");
  65         List<String> addExports = new ArrayList<>();
  66         for (String s : testModules.split("\\s+")) {
  67             if (s.isEmpty()) continue;
  68             if (s.indexOf('/') != -1)
  69                 addExports.add("--add-exports=" + s.trim() + "=ALL-UNNAMED");
  70         }
  71         options.addAll(addExports);
  72 
  73         for (String dir : srcDirs) {
  74             Path source = testsrc.resolve(dir);
  75             boolean ok = CompilerUtils.compile(source, dest, options.toArray(new String[0]));
  76             if (!ok) {
  77                 throw new RuntimeException("compilation fails");
  78             }
  79         }
  80     }
  81 
  82     int run() throws IOException {
  83         // compile classes in a separate directory for analysis
  84         setup(dest);
  85 
  86         File testDir = dest.toFile();
  87         String testDirBasename = testDir.toPath().getFileName().toString();
  88         File mDir = new File(testDir, "m");
  89         // all dependencies


< prev index next >