|
1 /* |
|
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
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 |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 /* |
|
25 * @test |
|
26 * @bug 8187588 |
|
27 * @summary -bootclasspath should work with -source 8 |
|
28 * @modules jdk.compiler/com.sun.tools.javac.api |
|
29 * jdk.compiler/com.sun.tools.javac.main |
|
30 * jdk.javadoc/jdk.javadoc.internal.api |
|
31 * jdk.javadoc/jdk.javadoc.internal.tool |
|
32 * @library /tools/lib |
|
33 * @build toolbox.JavacTask toolbox.JavadocTask toolbox.TestRunner toolbox.ToolBox |
|
34 * @run main TestSourceOption |
|
35 */ |
|
36 |
|
37 import java.io.IOException; |
|
38 import java.nio.file.Files; |
|
39 import java.nio.file.Path; |
|
40 import java.nio.file.Paths; |
|
41 |
|
42 import toolbox.JarTask; |
|
43 import toolbox.JavadocTask; |
|
44 import toolbox.ModuleBuilder; |
|
45 import toolbox.Task; |
|
46 import toolbox.Task.Expect; |
|
47 import toolbox.TestRunner; |
|
48 import toolbox.ToolBox; |
|
49 |
|
50 import javax.tools.JavaFileManager; |
|
51 import javax.tools.StandardLocation; |
|
52 import javax.tools.ToolProvider; |
|
53 |
|
54 public class TestSourceOption extends TestRunner { |
|
55 |
|
56 public static void main(String... args) throws Exception { |
|
57 TestSourceOption t = new TestSourceOption(); |
|
58 t.runTests(m -> new Object[] { Paths.get(m.getName()) }); |
|
59 } |
|
60 |
|
61 private final ToolBox tb = new ToolBox(); |
|
62 |
|
63 TestSourceOption() throws IOException { |
|
64 super(System.err); |
|
65 } |
|
66 |
|
67 @Test |
|
68 public void testSourceWithBootclasspath(Path base) throws Exception { |
|
69 Files.createDirectory(base); |
|
70 |
|
71 Path smallRtJar = base.resolve("small-rt.jar"); |
|
72 try (JavaFileManager fm = ToolProvider.getSystemJavaCompiler() |
|
73 .getStandardFileManager(null, null, null)) { |
|
74 |
|
75 new JarTask(tb, smallRtJar) |
|
76 .files(fm, StandardLocation.PLATFORM_CLASS_PATH, |
|
77 "java.lang.**", "java.io.*", "java.util.*") |
|
78 .run(); |
|
79 } |
|
80 |
|
81 tb.writeJavaFiles(base, "public class C { }"); |
|
82 Path out = base.resolve("out"); |
|
83 Files.createDirectory(out); |
|
84 |
|
85 JavadocTask task = new JavadocTask(tb); |
|
86 task.outdir(out) |
|
87 .options("-bootclasspath", smallRtJar.toString(), |
|
88 "-source", "8") |
|
89 .files(base.resolve("C.java")) |
|
90 .run(Expect.SUCCESS); |
|
91 } |
|
92 } |