1 /* |
1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
28 * @library /tools/javac/lib |
28 * @library /tools/javac/lib |
29 * @build ToolBox |
29 * @build ToolBox |
30 * @run main LinksTest |
30 * @run main LinksTest |
31 */ |
31 */ |
32 |
32 |
|
33 import java.io.IOException; |
33 import java.nio.file.Files; |
34 import java.nio.file.Files; |
34 import java.nio.file.Paths; |
35 import java.nio.file.Paths; |
35 |
36 |
36 //original test: test/tools/javac/links/links.sh |
37 //original test: test/tools/javac/links/links.sh |
37 public class LinksTest { |
38 public class LinksTest { |
46 |
47 |
47 public static void main(String args[]) |
48 public static void main(String args[]) |
48 throws Exception { |
49 throws Exception { |
49 // mkdir tmp |
50 // mkdir tmp |
50 // cp ${TESTSRC}/b/B.java tmp |
51 // cp ${TESTSRC}/b/B.java tmp |
51 ToolBox.writeFile(Paths.get("tmp", "B.java"), BSrc); |
52 ToolBox.writeFile(Paths.get("tmp/B.java"), BSrc); |
52 |
53 |
|
54 // Try to set up a symbolic link for the test. |
|
55 // ln -s `pwd`/tmp "${TESTCLASSES}/a" |
53 try { |
56 try { |
54 // ln -s `pwd`/tmp "${TESTCLASSES}/a" |
|
55 Files.createSymbolicLink(Paths.get("a"), Paths.get("tmp")); |
57 Files.createSymbolicLink(Paths.get("a"), Paths.get("tmp")); |
56 ////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1 |
58 System.err.println("Created symbolic link"); |
57 ToolBox.JavaToolArgs javacArgs = |
59 } catch (UnsupportedOperationException | IOException e) { |
58 new ToolBox.JavaToolArgs() |
60 System.err.println("Problem creating symbolic link: " + e); |
59 .setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc); |
61 System.err.println("Test cannot continue; test passed by default"); |
60 ToolBox.javac(javacArgs); |
62 return; |
61 } catch (UnsupportedOperationException e) { |
|
62 System.err.println("Symbolic links not supported on this system. The test can't finish"); |
|
63 } |
63 } |
|
64 |
|
65 // If symbolic link was successfully created, |
|
66 // try a compilation that will use it. |
|
67 ////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1 |
|
68 ToolBox.JavaToolArgs javacArgs = |
|
69 new ToolBox.JavaToolArgs() |
|
70 .setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc); |
|
71 ToolBox.javac(javacArgs); |
64 } |
72 } |
65 |
73 |
66 } |
74 } |