test/tools/javadoc/parser/7091528/T7091528.java

Fri, 16 Sep 2011 16:18:46 -0700

author
jjg
date
Fri, 16 Sep 2011 16:18:46 -0700
changeset 1094
dea82aa3ca4f
child 2281
b06e33ab7f61
permissions
-rw-r--r--

7091528: javadoc attempts to parse .class files
Reviewed-by: darcy

jjg@1094 1 /*
jjg@1094 2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
jjg@1094 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@1094 4 *
jjg@1094 5 * This code is free software; you can redistribute it and/or modify it
jjg@1094 6 * under the terms of the GNU General Public License version 2 only, as
jjg@1094 7 * published by the Free Software Foundation.
jjg@1094 8 *
jjg@1094 9 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@1094 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@1094 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@1094 12 * version 2 for more details (a copy is included in the LICENSE file that
jjg@1094 13 * accompanied this code).
jjg@1094 14 *
jjg@1094 15 * You should have received a copy of the GNU General Public License version
jjg@1094 16 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@1094 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@1094 18 *
jjg@1094 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jjg@1094 20 * or visit www.oracle.com if you need additional information or have any
jjg@1094 21 * questions.
jjg@1094 22 */
jjg@1094 23
jjg@1094 24 /**
jjg@1094 25 * @test
jjg@1094 26 * @bug 7091528
jjg@1094 27 * @summary javadoc attempts to parse .class files
jjg@1094 28 * @compile p/C1.java p/q/C2.java
jjg@1094 29 * @run main T7091528
jjg@1094 30 */
jjg@1094 31
jjg@1094 32 import java.io.File;
jjg@1094 33 import java.io.PrintWriter;
jjg@1094 34 import java.io.StringWriter;
jjg@1094 35
jjg@1094 36 public class T7091528 {
jjg@1094 37 public static void main(String... args) {
jjg@1094 38 new T7091528().run();
jjg@1094 39 }
jjg@1094 40
jjg@1094 41 void run() {
jjg@1094 42 File testSrc = new File(System.getProperty("test.src"));
jjg@1094 43 File testClasses = new File(System.getProperty("test.classes"));
jjg@1094 44 String[] args = {
jjg@1094 45 "-d", ".",
jjg@1094 46 "-sourcepath", testClasses + File.pathSeparator + testSrc,
jjg@1094 47 "-subpackages",
jjg@1094 48 "p"
jjg@1094 49 };
jjg@1094 50
jjg@1094 51 StringWriter sw = new StringWriter();
jjg@1094 52 PrintWriter pw = new PrintWriter(sw);
jjg@1094 53 String doclet = com.sun.tools.doclets.standard.Standard.class.getName();
jjg@1094 54 int rc = com.sun.tools.javadoc.Main.execute("javadoc", pw, pw, pw, doclet, args);
jjg@1094 55 pw.close();
jjg@1094 56
jjg@1094 57 String out = sw.toString();
jjg@1094 58 if (!out.isEmpty()) {
jjg@1094 59 System.err.println(out);
jjg@1094 60 }
jjg@1094 61
jjg@1094 62 if (rc != 0)
jjg@1094 63 System.err.println("javadoc failed: exit code = " + rc);
jjg@1094 64
jjg@1094 65 if (out.matches("(?s).*p/[^ ]+\\.class.*"))
jjg@1094 66 throw new Error("reading .class files");
jjg@1094 67
jjg@1094 68 if (!new File("index.html").exists())
jjg@1094 69 throw new Error("index.html not found");
jjg@1094 70 }
jjg@1094 71 }

mercurial