author | avstepan |
Tue, 19 May 2015 16:04:14 +0400 | |
changeset 30655 | d83f50188ca9 |
parent 27852 | 2e6ad0e4fe20 |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
1 |
/* |
26100 | 2 |
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
4 |
* |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
8 |
* |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
13 |
* accompanied this code). |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
14 |
* |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
18 |
* |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
21 |
* questions. |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
22 |
*/ |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
23 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
24 |
/* |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
25 |
* @test |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
26 |
* @bug 4266026 |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
27 |
* @summary javac no longer follows symlinks |
26100 | 28 |
* @library /tools/lib |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
29 |
* @build ToolBox |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
30 |
* @run main LinksTest |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
31 |
*/ |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
32 |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
33 |
import java.io.IOException; |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
34 |
import java.nio.file.Files; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
35 |
import java.nio.file.Paths; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
36 |
|
26100 | 37 |
// Original test: test/tools/javac/links/links.sh |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
38 |
public class LinksTest { |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
39 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
40 |
private static final String BSrc = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
41 |
"package a;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
42 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
43 |
"public class B {}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
44 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
45 |
private static final String TSrc = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
46 |
"class T extends a.B {}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
47 |
|
26100 | 48 |
public static void main(String... args) throws Exception { |
49 |
ToolBox tb = new ToolBox(); |
|
50 |
tb.writeFile("tmp/B.java", BSrc); |
|
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
51 |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
52 |
// Try to set up a symbolic link for the test. |
16549
1bdeedb5446c
8008582: jtreg failures after conversion of shell tests to Java
vromero
parents:
16304
diff
changeset
|
53 |
try { |
1bdeedb5446c
8008582: jtreg failures after conversion of shell tests to Java
vromero
parents:
16304
diff
changeset
|
54 |
Files.createSymbolicLink(Paths.get("a"), Paths.get("tmp")); |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
55 |
System.err.println("Created symbolic link"); |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
56 |
} catch (UnsupportedOperationException | IOException e) { |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
57 |
System.err.println("Problem creating symbolic link: " + e); |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
58 |
System.err.println("Test cannot continue; test passed by default"); |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
59 |
return; |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
60 |
} |
26100 | 61 |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
62 |
// If symbolic link was successfully created, |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
63 |
// try a compilation that will use it. |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
64 |
tb.new JavacTask() |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
65 |
.sourcepath(".") |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
66 |
.outdir(".") |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
67 |
.sources(TSrc) |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
68 |
.run() |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
26100
diff
changeset
|
69 |
.writeAll(); |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
70 |
} |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
71 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
72 |
} |