Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javadoc/6176978/T6176978.java
38813 views
/*1* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 617697826* @summary current Javadoc's invocation and extension (Doclet) mechanisms are problematic27* @build T617697828* @run main T617697829*/3031import java.io.*;32import java.net.*;3334public class T617697835{36public static void main(String[] args) throws Exception {37// create and use a temp dir that will not be on jtreg's38// default class path39File tmpDir = new File("tmp");40tmpDir.mkdirs();4142File testSrc = new File(System.getProperty("test.src", "."));43String[] javac_args = {44"-d",45"tmp",46new File(testSrc, "X.java").getPath()47};4849int rc = com.sun.tools.javac.Main.compile(javac_args);50if (rc != 0)51throw new Error("javac exit code: " + rc);5253String[] jdoc_args = {54"-doclet",55"X",56new File(testSrc, "T6176978.java").getPath()57};5859rc = com.sun.tools.javadoc.Main.execute(jdoc_args);60if (rc == 0)61throw new Error("javadoc unexpectedly succeeded");62636465Thread currThread = Thread.currentThread();66ClassLoader saveClassLoader = currThread.getContextClassLoader();67URLClassLoader urlCL = new URLClassLoader(new URL[] { tmpDir.toURL() });68currThread.setContextClassLoader(urlCL);6970try {71rc = com.sun.tools.javadoc.Main.execute(jdoc_args);72if (rc != 0)73throw new Error("javadoc exit: " + rc);74}75finally {76currThread.setContextClassLoader(saveClassLoader);77}78}79}808182