changeset 2879:5ef20044e3cf

8130426: Test tools/javac/links/LinksTest.java fails on Windows 10(x64) Summary: Restructure test to use the logic from the JDK 9 version. Reviewed-by: jjg
author bpb
date Wed, 08 Jul 2015 11:40:43 -0700
parents 7f88b5dc78ce
children ec4e102b4bd0
files test/tools/javac/links/LinksTest.java
diffstat 1 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/test/tools/javac/links/LinksTest.java	Wed Jul 01 21:54:20 2015 -0700
+++ b/test/tools/javac/links/LinksTest.java	Wed Jul 08 11:40:43 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
  * @run main LinksTest
  */
 
+import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 
@@ -48,19 +49,26 @@
             throws Exception {
 //      mkdir tmp
 //      cp ${TESTSRC}/b/B.java tmp
-        ToolBox.writeFile(Paths.get("tmp", "B.java"), BSrc);
+        ToolBox.writeFile(Paths.get("tmp/B.java"), BSrc);
 
+        // Try to set up a symbolic link for the test.
+//        ln -s `pwd`/tmp "${TESTCLASSES}/a"
         try {
-//        ln -s `pwd`/tmp "${TESTCLASSES}/a"
             Files.createSymbolicLink(Paths.get("a"), Paths.get("tmp"));
-            ////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1
-            ToolBox.JavaToolArgs javacArgs =
-                    new ToolBox.JavaToolArgs()
-                    .setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc);
-            ToolBox.javac(javacArgs);
-        } catch (UnsupportedOperationException e) {
-            System.err.println("Symbolic links not supported on this system. The test can't finish");
+            System.err.println("Created symbolic link");
+        } catch (UnsupportedOperationException | IOException e) {
+            System.err.println("Problem creating symbolic link: " + e);
+            System.err.println("Test cannot continue; test passed by default");
+            return;
         }
+
+        // If symbolic link was successfully created,
+        // try a compilation that will use it.
+        ////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1
+        ToolBox.JavaToolArgs javacArgs =
+                new ToolBox.JavaToolArgs()
+                .setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc);
+        ToolBox.javac(javacArgs);
     }
 
 }