< prev index next >

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 --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 {




  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         // jdk.jdeps is a service provider module so needs to be explicitly included
  64         options.add("--add-modules=jdk.jdeps");
  65 
  66         // add --add-exports
  67         String testModules = System.getProperty("test.modules", "");
  68         List<String> addExports = new ArrayList<>();
  69         for (String s : testModules.split("\\s+")) {
  70             if (s.isEmpty()) continue;
  71             if (s.indexOf('/') != -1)
  72                 addExports.add("--add-exports=" + s.trim() + "=ALL-UNNAMED");
  73         }
  74         options.addAll(addExports);
  75 
  76         for (String dir : srcDirs) {
  77             Path source = testsrc.resolve(dir);
  78             boolean ok = CompilerUtils.compile(source, dest, options.toArray(new String[0]));
  79             if (!ok) {
  80                 throw new RuntimeException("compilation fails");
  81             }
  82         }
  83     }
  84 
  85     int run() throws IOException {


< prev index next >