37 import java.nio.file.Paths; |
37 import java.nio.file.Paths; |
38 import java.util.*; |
38 import java.util.*; |
39 import java.util.regex.*; |
39 import java.util.regex.*; |
40 |
40 |
41 public class APIDeps { |
41 public class APIDeps { |
42 private static boolean symbolFileExist = initProfiles(); |
|
43 private static boolean initProfiles() { |
|
44 // check if ct.sym exists; if not use the profiles.properties file |
|
45 Path home = Paths.get(System.getProperty("java.home")); |
|
46 if (home.endsWith("jre")) { |
|
47 home = home.getParent(); |
|
48 } |
|
49 Path ctsym = home.resolve("lib").resolve("ct.sym"); |
|
50 boolean symbolExists = ctsym.toFile().exists(); |
|
51 if (!symbolExists) { |
|
52 Path testSrcProfiles = |
|
53 Paths.get(System.getProperty("test.src", "."), "profiles.properties"); |
|
54 if (!testSrcProfiles.toFile().exists()) |
|
55 throw new Error(testSrcProfiles + " does not exist"); |
|
56 System.out.format("%s doesn't exist.%nUse %s to initialize profiles info%n", |
|
57 ctsym, testSrcProfiles); |
|
58 System.setProperty("jdeps.profiles", testSrcProfiles.toString()); |
|
59 } |
|
60 return symbolExists; |
|
61 } |
|
62 |
|
63 public static void main(String... args) throws Exception { |
42 public static void main(String... args) throws Exception { |
64 int errors = 0; |
43 int errors = 0; |
65 errors += new APIDeps().run(); |
44 errors += new APIDeps().run(); |
66 if (errors > 0) |
45 if (errors > 0) |
67 throw new Exception(errors + " errors found"); |
46 throw new Exception(errors + " errors found"); |