author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 40310 | langtools/test/jdk/javadoc/tool/8025693/Test.java@a979695d72a1 |
permissions | -rw-r--r-- |
21020
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
1 |
/* |
40310
a979695d72a1
8152054: fix @ignored langtools/test/jdk/javadoc/tool/ tests
ksrini
parents:
35426
diff
changeset
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
21020
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
4 |
* |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
8 |
* |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
14 |
* |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
18 |
* |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
21 |
* questions. |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
22 |
*/ |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
23 |
|
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
24 |
/* |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
25 |
* @test |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
26 |
* @bug 8025693 |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
27 |
* @summary javadoc should ignore <clinit> methods found in classes on classpath |
40310
a979695d72a1
8152054: fix @ignored langtools/test/jdk/javadoc/tool/ tests
ksrini
parents:
35426
diff
changeset
|
28 |
* @modules jdk.javadoc/jdk.javadoc.internal.tool |
21020
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
29 |
*/ |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
30 |
|
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
31 |
import java.io.*; |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
32 |
|
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
33 |
public class Test { |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
34 |
public static void main(String[] args) throws Exception { |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
35 |
new Test().run(); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
36 |
} |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
37 |
|
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
38 |
final File baseFile = new File("src/Base.java"); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
39 |
final String baseText = |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
40 |
"package p;\n" + |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
41 |
"public class Base { static { } }\n"; |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
42 |
|
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
43 |
final File srcFile = new File("src/C.java"); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
44 |
final String srcText = |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
45 |
"package p;\n" + |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
46 |
"/** comment */\n" + |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
47 |
"public abstract class C extends Base { }\n"; |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
48 |
|
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
49 |
void run() throws Exception { |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
50 |
File classesDir = new File("classes"); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
51 |
classesDir.mkdirs(); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
52 |
writeFile(baseFile, baseText); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
53 |
String[] javacArgs = { |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
54 |
"-d", classesDir.getPath(), |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
55 |
baseFile.getPath() |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
56 |
}; |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
57 |
com.sun.tools.javac.Main.compile(javacArgs); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
58 |
|
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
59 |
writeFile(srcFile, srcText); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
60 |
String[] args = { |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
61 |
"-d", "api", |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
62 |
"-classpath", classesDir.getPath(), |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
63 |
"-package", "p", |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
64 |
srcFile.getPath() |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
65 |
}; |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
66 |
|
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
67 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
68 |
PrintStream ps = new PrintStream(baos); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
69 |
PrintStream prev = System.err; |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
70 |
System.setErr(ps); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
71 |
try { |
40310
a979695d72a1
8152054: fix @ignored langtools/test/jdk/javadoc/tool/ tests
ksrini
parents:
35426
diff
changeset
|
72 |
int rc = jdk.javadoc.internal.tool.Main.execute(args); |
21020
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
73 |
} finally { |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
74 |
System.err.flush(); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
75 |
System.setErr(prev); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
76 |
} |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
77 |
String out = baos.toString(); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
78 |
System.out.println(out); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
79 |
|
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
80 |
String errorMessage = "java.lang.IllegalArgumentException: <clinit>"; |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
81 |
if (out.contains(errorMessage)) |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
82 |
throw new Exception("error message found: " + errorMessage); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
83 |
} |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
84 |
|
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
85 |
void writeFile(File file, String body) throws IOException { |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
86 |
file.getParentFile().mkdirs(); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
87 |
try (FileWriter out = new FileWriter(file)) { |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
88 |
out.write(body); |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
89 |
} |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
90 |
} |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
91 |
} |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
diff
changeset
|
92 |