82 *
83 * @return Full path to an executable in jdk/bin
84 */
85 public static String getTestJDKTool(String tool) {
86 try {
87 return getTool(tool, "test.jdk");
88 } catch (FileNotFoundException e) {
89 throw new RuntimeException(e);
90 }
91 }
92
93 private static String getTool(String tool, String property) throws FileNotFoundException {
94 String jdkPath = System.getProperty(property);
95
96 if (jdkPath == null) {
97 throw new RuntimeException(
98 "System property '" + property + "' not set. This property is normally set by jtreg. "
99 + "When running test separately, set this property using '-D" + property + "=/path/to/jdk'.");
100 }
101
102 Path toolName = Paths.get("bin", tool + (Platform.isWindows() ? ".exe" : ""));
103
104 Path jdkTool = Paths.get(jdkPath, toolName.toString());
105 if (!jdkTool.toFile().exists()) {
106 throw new FileNotFoundException("Could not find file " + jdkTool.toAbsolutePath());
107 }
108
109 return jdkTool.toAbsolutePath().toString();
110 }
111 }
|
82 *
83 * @return Full path to an executable in jdk/bin
84 */
85 public static String getTestJDKTool(String tool) {
86 try {
87 return getTool(tool, "test.jdk");
88 } catch (FileNotFoundException e) {
89 throw new RuntimeException(e);
90 }
91 }
92
93 private static String getTool(String tool, String property) throws FileNotFoundException {
94 String jdkPath = System.getProperty(property);
95
96 if (jdkPath == null) {
97 throw new RuntimeException(
98 "System property '" + property + "' not set. This property is normally set by jtreg. "
99 + "When running test separately, set this property using '-D" + property + "=/path/to/jdk'.");
100 }
101
102 Path toolName = Paths.get("bin", tool + (isWindows() ? ".exe" : ""));
103
104 Path jdkTool = Paths.get(jdkPath, toolName.toString());
105 if (!jdkTool.toFile().exists()) {
106 throw new FileNotFoundException("Could not find file " + jdkTool.toAbsolutePath());
107 }
108
109 return jdkTool.toAbsolutePath().toString();
110 }
111
112 private static boolean isWindows() {
113 return System.getProperty("os.name").toLowerCase().startsWith("win");
114 }
115 }
|