langtools/test/tools/javadoc/6176978/T6176978.java
author xdono
Mon, 09 Mar 2009 13:29:06 -0700
changeset 2212 1d3dc0e0ba0c
parent 1990 5d90be5d60bb
child 5520 86e4b9a9da40
permissions -rw-r--r--
6814575: Update copyright year Summary: Update copyright for files that have been modified in 2009, up to 03/09 Reviewed-by: katleman, tbell, ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1990
5d90be5d60bb 6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff changeset
     1
/*
2212
1d3dc0e0ba0c 6814575: Update copyright year
xdono
parents: 1990
diff changeset
     2
 * Copyright 2008-2009 Sun Microsystems, Inc.  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
 *
5d90be5d60bb 6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
5d90be5d60bb 6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
5d90be5d60bb 6176978: current Javadoc's invocation and extension (Doclet) mechanisms are problematic
jjg
parents:
diff changeset
    21
 * have any questions.
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
}