author | enevill |
Tue, 05 May 2015 09:08:20 +0000 | |
changeset 30325 | 1472b22475f2 |
parent 5520 | 86e4b9a9da40 |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
1990
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
1 |
/* |
5520 | 2 |
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. |
1990
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
4 |
* |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
8 |
* |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
14 |
* |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
18 |
* |
5520 | 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. |
|
1990
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
22 |
*/ |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
23 |
|
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
24 |
/* |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
25 |
* @test |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
26 |
* @bug 6176978 |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
27 |
* @summary current Javadoc's invocation and extension (Doclet) mechanisms are problematic |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
28 |
* @build T6176978 |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
29 |
* @run main T6176978 |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
30 |
*/ |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
31 |
|
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
32 |
import java.io.*; |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
33 |
import java.net.*; |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
34 |
|
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
35 |
public class T6176978 |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
36 |
{ |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
37 |
public static void main(String[] args) throws Exception { |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
38 |
// create and use a temp dir that will not be on jtreg's |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
39 |
// default class path |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
40 |
File tmpDir = new File("tmp"); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
41 |
tmpDir.mkdirs(); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
42 |
|
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
43 |
File testSrc = new File(System.getProperty("test.src", ".")); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
44 |
String[] javac_args = { |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
45 |
"-d", |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
46 |
"tmp", |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
47 |
new File(testSrc, "X.java").getPath() |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
48 |
}; |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
49 |
|
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
50 |
int rc = com.sun.tools.javac.Main.compile(javac_args); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
51 |
if (rc != 0) |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
52 |
throw new Error("javac exit code: " + rc); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
53 |
|
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
54 |
String[] jdoc_args = { |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
55 |
"-doclet", |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
56 |
"X", |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
57 |
new File(testSrc, "T6176978.java").getPath() |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
58 |
}; |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
59 |
|
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
60 |
rc = com.sun.tools.javadoc.Main.execute(jdoc_args); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
61 |
if (rc == 0) |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
62 |
throw new Error("javadoc unexpectedly succeeded"); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
63 |
|
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
64 |
|
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
65 |
|
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
66 |
Thread currThread = Thread.currentThread(); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
67 |
ClassLoader saveClassLoader = currThread.getContextClassLoader(); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
68 |
URLClassLoader urlCL = new URLClassLoader(new URL[] { tmpDir.toURL() }); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
69 |
currThread.setContextClassLoader(urlCL); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
70 |
|
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
71 |
try { |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
72 |
rc = com.sun.tools.javadoc.Main.execute(jdoc_args); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
73 |
if (rc != 0) |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
74 |
throw new Error("javadoc exit: " + rc); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
75 |
} |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
76 |
finally { |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
77 |
currThread.setContextClassLoader(saveClassLoader); |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
78 |
} |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
79 |
} |
5d90be5d60bb
6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff
changeset
|
80 |
} |