268 File symLink = null; 269 String libPathPrefix = isSDK ? "jre/lib" : "/lib"; 270 symLink = new File(JAVAHOME, libPathPrefix + 271 getJreArch() + "/" + LIBJVM); 272 if (symLink.exists()) { 273 throw new RuntimeException("symlink exists " + symLink.getAbsolutePath()); 274 } 275 } 276 277 /* 278 * verify if all the symlinks in the images are created correctly, 279 * only on solaris, this test works only on images. 280 */ 281 @Test 282 void testSymLinks() throws Exception { 283 if (!isSolaris) 284 return; 285 verifySymLinks(JAVA_BIN); 286 verifySymLinks(JAVA_JRE_BIN); 287 } 288 // exclude non-consequential binaries or scripts co-packaged in install 289 private Pattern symlinkExcludes = Pattern.compile(".*jvisualvm.*"); 290 291 private void verifySymLinks(String bindir) throws IOException { 292 File binDir = new File(bindir); 293 System.err.println("verifying links in: " + bindir); 294 File isaDir = new File(binDir, getArch()).getAbsoluteFile(); 295 if (!isaDir.exists()) { 296 throw new RuntimeException("dir: " + isaDir + " does not exist"); 297 } 298 try (DirectoryStream<Path> ds = Files.newDirectoryStream(binDir.toPath())) { 299 for (Path p : ds) { 300 if (symlinkExcludes.matcher(p.toString()).matches() || 301 Files.isDirectory(p, NOFOLLOW_LINKS)) { 302 continue; 303 } 304 Path link = new File(isaDir, p.getFileName().toString()).toPath(); 305 if (Files.isSymbolicLink(link)) { 306 Path target = Files.readSymbolicLink(link); 307 if (target.startsWith("..") && p.endsWith(target.getFileName())) { 308 // System.out.println(target + " OK"); 309 continue; | 268 File symLink = null; 269 String libPathPrefix = isSDK ? "jre/lib" : "/lib"; 270 symLink = new File(JAVAHOME, libPathPrefix + 271 getJreArch() + "/" + LIBJVM); 272 if (symLink.exists()) { 273 throw new RuntimeException("symlink exists " + symLink.getAbsolutePath()); 274 } 275 } 276 277 /* 278 * verify if all the symlinks in the images are created correctly, 279 * only on solaris, this test works only on images. 280 */ 281 @Test 282 void testSymLinks() throws Exception { 283 if (!isSolaris) 284 return; 285 verifySymLinks(JAVA_BIN); 286 verifySymLinks(JAVA_JRE_BIN); 287 } 288 // exclude non-consequential binaries or scripts co-packaged in other 289 // build phases 290 private final String excludeRE = 291 ".*jvisualvm.*" + 292 "|.*javaws.*" + 293 "|.*ControlPanel.*" + 294 "|.*java-rmi.cgi" + 295 "|.*jcontrol.*"; 296 private final Pattern symlinkExcludes = Pattern.compile(excludeRE); 297 298 private void verifySymLinks(String bindir) throws IOException { 299 File binDir = new File(bindir); 300 System.err.println("verifying links in: " + bindir); 301 File isaDir = new File(binDir, getArch()).getAbsoluteFile(); 302 if (!isaDir.exists()) { 303 throw new RuntimeException("dir: " + isaDir + " does not exist"); 304 } 305 try (DirectoryStream<Path> ds = Files.newDirectoryStream(binDir.toPath())) { 306 for (Path p : ds) { 307 if (symlinkExcludes.matcher(p.toString()).matches() || 308 Files.isDirectory(p, NOFOLLOW_LINKS)) { 309 continue; 310 } 311 Path link = new File(isaDir, p.getFileName().toString()).toPath(); 312 if (Files.isSymbolicLink(link)) { 313 Path target = Files.readSymbolicLink(link); 314 if (target.startsWith("..") && p.endsWith(target.getFileName())) { 315 // System.out.println(target + " OK"); 316 continue; |