jjg@209: /* xdono@229: * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved. jjg@209: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@209: * jjg@209: * This code is free software; you can redistribute it and/or modify it jjg@209: * under the terms of the GNU General Public License version 2 only, as jjg@209: * published by the Free Software Foundation. jjg@209: * jjg@209: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@209: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@209: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@209: * version 2 for more details (a copy is included in the LICENSE file that jjg@209: * accompanied this code). jjg@209: * jjg@209: * You should have received a copy of the GNU General Public License version jjg@209: * 2 along with this work; if not, write to the Free Software Foundation, jjg@209: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@209: * jjg@209: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, jjg@209: * CA 95054 USA or visit www.sun.com if you need additional information or jjg@209: * have any questions. jjg@209: */ jjg@209: jjg@209: /* jjg@209: * @test jjg@209: * @bug 6176978 jjg@209: * @summary current Javadoc's invocation and extension (Doclet) mechanisms are problematic jjg@209: * @build T6176978 jjg@209: * @run main T6176978 jjg@209: */ jjg@209: jjg@209: import java.io.*; jjg@209: import java.net.*; jjg@209: jjg@209: public class T6176978 jjg@209: { jjg@209: public static void main(String[] args) throws Exception { jjg@209: // create and use a temp dir that will not be on jtreg's jjg@209: // default class path jjg@209: File tmpDir = new File("tmp"); jjg@209: tmpDir.mkdirs(); jjg@209: jjg@209: File testSrc = new File(System.getProperty("test.src", ".")); jjg@209: String[] javac_args = { jjg@209: "-d", jjg@209: "tmp", jjg@209: new File(testSrc, "X.java").getPath() jjg@209: }; jjg@209: jjg@209: int rc = com.sun.tools.javac.Main.compile(javac_args); jjg@209: if (rc != 0) jjg@209: throw new Error("javac exit code: " + rc); jjg@209: jjg@209: String[] jdoc_args = { jjg@209: "-doclet", jjg@209: "X", jjg@209: new File(testSrc, "T6176978.java").getPath() jjg@209: }; jjg@209: jjg@209: rc = com.sun.tools.javadoc.Main.execute(jdoc_args); jjg@209: if (rc == 0) jjg@209: throw new Error("javadoc unexpectedly succeeded"); jjg@209: jjg@209: jjg@209: jjg@209: Thread currThread = Thread.currentThread(); jjg@209: ClassLoader saveClassLoader = currThread.getContextClassLoader(); jjg@209: URLClassLoader urlCL = new URLClassLoader(new URL[] { tmpDir.toURL() }); jjg@209: currThread.setContextClassLoader(urlCL); jjg@209: jjg@209: try { jjg@209: rc = com.sun.tools.javadoc.Main.execute(jdoc_args); jjg@209: if (rc != 0) jjg@209: throw new Error("javadoc exit: " + rc); jjg@209: } jjg@209: finally { jjg@209: currThread.setContextClassLoader(saveClassLoader); jjg@209: } jjg@209: } jjg@209: }