author | dstewart |
Thu, 29 Mar 2018 16:07:39 -0400 | |
changeset 49649 | 17c6ab93710e |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
1 |
/* |
43268
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
2 |
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
4 |
* |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
8 |
* |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
14 |
* |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
18 |
* |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
21 |
* questions. |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
22 |
*/ |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
23 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
24 |
/* |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
25 |
* @test |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
26 |
* @bug 8147801 |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
27 |
* @summary java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9 |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
28 |
* @modules jdk.javadoc/com.sun.tools.javadoc |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
29 |
* @library jarsrc |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
30 |
* @build lib.* p.* |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
31 |
* @run main T8147801 |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
32 |
*/ |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
33 |
|
45861
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
43268
diff
changeset
|
34 |
import java.io.File; |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
35 |
import java.io.IOException; |
43268
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
36 |
import java.io.PrintWriter; |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
37 |
import java.io.StringWriter; |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
38 |
import java.nio.file.ClosedFileSystemException; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
39 |
import java.nio.file.Files; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
40 |
import java.nio.file.Path; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
41 |
import java.nio.file.Paths; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
42 |
import java.util.ArrayList; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
43 |
import java.util.List; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
44 |
import java.util.jar.JarEntry; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
45 |
import java.util.jar.JarOutputStream; |
45861
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
43268
diff
changeset
|
46 |
import java.util.stream.Stream; |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
47 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
48 |
import com.sun.javadoc.ClassDoc; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
49 |
import com.sun.javadoc.FieldDoc; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
50 |
import com.sun.javadoc.RootDoc; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
51 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
52 |
/* |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
53 |
* This test verifies the use of the hidden fileManager.deferClose |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
54 |
* option, to work around the limitation that javadoc objects |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
55 |
* (like RootDoc and related types) should cannot normally be used |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
56 |
* after javadoc exits, closing its file manager (if it opened it.) |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
57 |
* |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
58 |
* The test runs javadoc on a chain of classes, 1 in source form, |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
59 |
* and 2 in a jar file. javadoc/javac will "complete" classes found |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
60 |
* in source, but will eagerly "classes" in class form. |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
61 |
* The chain is p/Test.java -> lib/Lib1.class -> lib/Lib2.class. |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
62 |
* After javadoc exits, the classes are examined, to finally force |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
63 |
* the classes to be completed, possibly causing javac to try and access |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
64 |
* references into a .jar file system which has now been closed. |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
65 |
* |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
66 |
* The test runs two test cases -- one without the workaround option, |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
67 |
* to test the validity of the test case, and one with the workaround |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
68 |
* option, to test that it works as expected. |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
69 |
*/ |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
70 |
public class T8147801 { |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
71 |
public static void main(String... args) throws Exception { |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
72 |
new T8147801().run(); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
73 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
74 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
75 |
void run() throws Exception { |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
76 |
initJar(); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
77 |
test(false); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
78 |
test(true); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
79 |
if (errors > 0) { |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
80 |
throw new Exception(errors + " errors occurred"); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
81 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
82 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
83 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
84 |
void test(boolean withOption) { |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
85 |
System.err.println("Testing " + (withOption ? "with" : "without") + " option"); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
86 |
try { |
43268
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
87 |
String dump = ""; |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
88 |
RootDoc root = getRootDoc(withOption); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
89 |
for (ClassDoc cd: root.specifiedClasses()) { |
43268
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
90 |
dump += dump(cd); |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
91 |
} |
43268
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
92 |
if (dump.contains("lib.Lib2.i")) { |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
93 |
if (!withOption) { |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
94 |
error("control case failed: Lib2 class file was read, unexpectedly, without using option"); |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
95 |
} |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
96 |
} else { |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
97 |
if (withOption) { |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
98 |
error("test case failed: could not read Lib2 class file, using option"); |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
99 |
} |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
100 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
101 |
} catch (ClosedFileSystemException e) { |
43268
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
102 |
error("Unexpected exception: " + e); |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
103 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
104 |
System.err.println(); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
105 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
106 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
107 |
RootDoc getRootDoc(boolean withOption) { |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
108 |
List<String> opts = new ArrayList<>(); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
109 |
if (withOption) |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
110 |
opts.add("-XDfileManager.deferClose=10"); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
111 |
opts.add("-doclet"); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
112 |
opts.add(getClass().getName()); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
113 |
opts.add("-classpath"); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
114 |
opts.add(jarPath.toString()); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
115 |
opts.add(Paths.get(System.getProperty("test.src"), "p", "Test.java").toString()); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
116 |
System.err.println("javadoc opts: " + opts); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
117 |
int rc = com.sun.tools.javadoc.Main.execute( |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
118 |
"javadoc", |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
119 |
// by specifying our own class loader, we get the same Class instance as this |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
120 |
getClass().getClassLoader(), |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
121 |
opts.toArray(new String[opts.size()])); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
122 |
if (rc != 0) { |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
123 |
error("unexpected exit from javadoc or doclet: " + rc); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
124 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
125 |
return cachedRoot; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
126 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
127 |
|
43268
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
128 |
String dump(ClassDoc cd) { |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
129 |
StringWriter sw = new StringWriter(); |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
130 |
PrintWriter pw = new PrintWriter(sw); |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
131 |
dump(pw, "", cd); |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
132 |
String out = sw.toString(); |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
133 |
System.err.println(out); |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
134 |
return out; |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
135 |
} |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
136 |
|
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
137 |
void dump(PrintWriter out, String prefix, ClassDoc cd) { |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
138 |
out.println(prefix + "class: " + cd); |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
139 |
for (FieldDoc fd: cd.fields()) { |
43268
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
140 |
out.println(prefix + " " + fd); |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
141 |
if (fd.type().asClassDoc() != null) { |
43268
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
35807
diff
changeset
|
142 |
dump(out, prefix + " ", fd.type().asClassDoc()); |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
143 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
144 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
145 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
146 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
147 |
void initJar() throws IOException { |
45861
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
43268
diff
changeset
|
148 |
String testClassPath = System.getProperty("test.class.path", ""); |
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
43268
diff
changeset
|
149 |
Path jarsrc = Stream.of(testClassPath.split(File.pathSeparator)) |
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
43268
diff
changeset
|
150 |
.map(Paths::get) |
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
43268
diff
changeset
|
151 |
.filter(e -> e.endsWith("jarsrc")) |
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
43268
diff
changeset
|
152 |
.findAny() |
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
43268
diff
changeset
|
153 |
.orElseThrow(() -> new InternalError("jarsrc not found")); |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
154 |
jarPath = Paths.get("lib.jar"); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
155 |
try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(jarPath))) { |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
156 |
String[] classNames = {"Lib1.class", "Lib2.class"}; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
157 |
for (String cn : classNames) { |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
158 |
out.putNextEntry(new JarEntry("lib/" + cn)); |
45861
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
43268
diff
changeset
|
159 |
Path libClass = jarsrc.resolve("lib").resolve(cn); |
35807
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
160 |
out.write(Files.readAllBytes(libClass)); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
161 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
162 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
163 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
164 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
165 |
void error(String msg) { |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
166 |
System.err.println("Error: " + msg); |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
167 |
errors++; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
168 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
169 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
170 |
Path jarPath; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
171 |
int errors; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
172 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
173 |
// Bad doclet caches the RootDoc for later use |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
174 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
175 |
static RootDoc cachedRoot; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
176 |
|
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
177 |
public static boolean start(RootDoc root) { |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
178 |
cachedRoot = root; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
179 |
return true; |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
180 |
} |
2eb1d877da0f
8147801: java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
jjg
parents:
diff
changeset
|
181 |
} |