diff --git a/langtools/test/jdk/javadoc/tool/sampleapi/SampleApiTest.java b/langtools/test/jdk/javadoc/tool/sampleapi/SampleApiTest.java
index cc368d9e7f0..5051a5f4055 100644
--- a/langtools/test/jdk/javadoc/tool/sampleapi/SampleApiTest.java
+++ b/langtools/test/jdk/javadoc/tool/sampleapi/SampleApiTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,21 +30,30 @@
* jdk.compiler/com.sun.tools.javac.parser
* jdk.compiler/com.sun.tools.javac.tree
* jdk.compiler/com.sun.tools.javac.util
- * @run main sampleapi.SampleApiDefaultRunner -o:out/src
+ * jdk.javadoc/jdk.javadoc.internal.tool
* @run main SampleApiTest
*/
+import java.io.File;
-import com.sun.tools.javadoc.*;
-import java.nio.file.Paths;
+import jdk.javadoc.internal.tool.Main;
+import sampleapi.SampleApiDefaultRunner;
public class SampleApiTest {
- public static void main(String... args) {
+ public static void main(String... args) throws Exception {
- // html4
- Main.execute(
+ // generate
+ SampleApiDefaultRunner.execute(
new String[] {
- "-d", "out/doc.html4",
+ "-o=out/src",
+ "-r=" + System.getProperty("test.src") + "/res"
+ });
+
+ // html4 / unnamed modules
+ System.err.println(">> HTML4, unnamed modules");
+ int res1 = Main.execute(
+ new String[] {
+ "-d", "out/doc.html4.unnamed",
"-verbose",
"-private",
"-use",
@@ -53,16 +62,20 @@ public class SampleApiTest {
"-html4",
"-javafx",
"-windowtitle", "SampleAPI",
- "-sourcepath", "out/src",
+ "-overview", "overview.html",
+ "-sourcepath", "out/src" + File.pathSeparator + "out/src/sat.sampleapi",
"sampleapi.simple",
+ "sampleapi.simple.sub",
"sampleapi.tiny",
+ "sampleapi.tiny.sub",
"sampleapi.fx"
});
- // html5
- Main.execute(
+ // html5 / unnamed modules
+ System.err.println(">> HTML5, unnamed modules");
+ int res2 = Main.execute(
new String[] {
- "-d", "out/doc.html5",
+ "-d", "out/doc.html5.unnamed",
"-verbose",
"-private",
"-use",
@@ -71,10 +84,17 @@ public class SampleApiTest {
"-html5",
"-javafx",
"-windowtitle", "SampleAPI",
- "-sourcepath", "out/src",
+ "-overview", "overview.html",
+ "-sourcepath", "out/src" + File.pathSeparator + "out/src/sat.sampleapi",
"sampleapi.simple",
+ "sampleapi.simple.sub",
"sampleapi.tiny",
+ "sampleapi.tiny.sub",
"sampleapi.fx"
});
+
+ if (res1 > 0 || res2 > 0)
+ throw new Exception("One of exit statuses is non-zero: "
+ + res1 + " for HTML4, " + res2 + " for HTML5.");
}
}
diff --git a/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/SampleApi.java b/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/SampleApi.java
index 536787bcc26..e8b4eedf8d4 100644
--- a/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/SampleApi.java
+++ b/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/SampleApi.java
@@ -24,6 +24,7 @@
package sampleapi;
import java.io.File;
+import java.io.FilenameFilter;
import java.nio.file.Path;
import sampleapi.generator.PackageGenerator;
@@ -32,21 +33,21 @@ public class SampleApi {
PackageGenerator pkgGen = new PackageGenerator();
- public void generate(File dir) throws Fault {
- pkgGen.processDataSet("simple");
- pkgGen.generate(dir);
- pkgGen.processDataSet("tiny");
- pkgGen.generate(dir);
- pkgGen.processDataSet("fx");
- pkgGen.generate(dir);
+ public void generate(File resDir, File outDir) throws Fault {
+ FilenameFilter filter = (dir, name) -> { return name.endsWith(".xml"); };
+ File[] resFiles = resDir.listFiles(filter);
+ for (File resFile : resFiles) {
+ pkgGen.processDataSet(resFile);
+ pkgGen.generate(outDir);
+ }
}
- public void generate(Path dir) throws Fault {
- generate(dir.toFile());
+ public void generate(Path res, Path dir) throws Fault {
+ generate(res.toFile(), dir.toFile());
}
- public void generate(String dir) throws Fault {
- generate(new File(dir));
+ public void generate(String res, String dir) throws Fault {
+ generate(new File(res), new File(dir));
}
public static class Fault extends Exception {
diff --git a/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/SampleApiDefaultRunner.java b/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/SampleApiDefaultRunner.java
index 90f838eacf2..23459d5fec4 100644
--- a/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/SampleApiDefaultRunner.java
+++ b/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/SampleApiDefaultRunner.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,28 +29,48 @@ import sampleapi.SampleApi.Fault;
public class SampleApiDefaultRunner {
+ public static final String MSG_NO_OUTDIR =
+ "SampleApi: no outdir set";
+ public static final String MSG_NO_RESDIR =
+ "SampleApi: no resourcedir set";
public static final String MSG_DUP_OUTDIR =
"SampleApi: duplicated outdir detected: ";
+ public static final String MSG_DUP_RESDIR =
+ "SampleApi: duplicated resourcedir detected: ";
public static final String MSG_USE_FIRST =
" will use first occurance: ";
public static final String MSG_INVAL_OUTDIR =
"SampleApi: outdir is not valid: ";
+ public static final String MSG_INVAL_RESDIR =
+ "SampleApi: outdir is not valid: ";
public static final String MSG_CANNOT_GEN =
"SampleApi: cannot generate output: ";
public static final String MSG_WRONG_OPTION =
"SampleApi: incorrect option: ";
public static final String MSG_USE_HELP =
" use -? for help";
+ public static final String[] MSG_HELP = {
+ "SampleApi options:",
+ " -?|-h|--help - print help",
+ " -r=
|--resdir=|--resourcedir= - set to find xml resources",
+ " -o=|--outdir= - set to generate output"
+ };
public static void main(String... args) throws Exception {
+ System.exit(execute(args));
+ }
+
+ public static int execute(String... args) throws Exception {
if (args.length == 0) {
printHelp();
- System.exit(1);
+ return 1;
}
String outDirName = "";
+ String resDirName = "";
boolean isOutDirSet = false;
+ boolean isResDirSet = false;
boolean isHelpPrinted = false;
for (String arg : args) {
Option option = new Option(arg);
@@ -73,6 +93,17 @@ public class SampleApiDefaultRunner {
System.err.println(MSG_USE_FIRST + outDirName);
}
break;
+ case "-r":
+ case "--resdir":
+ case "--resourcedir":
+ if (!isResDirSet) {
+ resDirName = option.getOptionValue();
+ isResDirSet = true;
+ } else {
+ System.err.println(MSG_DUP_RESDIR + option.getOptionValue());
+ System.err.println(MSG_USE_FIRST + resDirName);
+ }
+ break;
default:
System.err.println(MSG_WRONG_OPTION + arg);
System.err.println(MSG_USE_HELP);
@@ -82,40 +113,47 @@ public class SampleApiDefaultRunner {
}
if (!isOutDirSet) {
- System.exit(1);
+ System.err.println(MSG_NO_OUTDIR);
+ return 1;
}
if (outDirName.length() == 0) {
System.err.println(MSG_INVAL_OUTDIR + outDirName);
- System.exit(1);
+ return 1;
}
+ if (!isResDirSet) {
+ System.err.println(MSG_NO_RESDIR);
+ return 1;
+ }
+
+ if (resDirName.length() == 0) {
+ System.err.println(MSG_INVAL_RESDIR + resDirName);
+ return 1;
+ }
+
+ File resDir = new File(resDirName);
File outDir = new File(outDirName);
outDir.mkdirs();
SampleApi apiGen = new SampleApi();
- try {
- apiGen.generate(outDir);
- } catch (Fault e) {
- System.err.println(MSG_CANNOT_GEN + e.getMessage());
- e.printStackTrace();
- }
+ apiGen.generate(resDir, outDir);
+
+ return 0;
}
private static void printHelp() {
- System.out.println("SampleApi:");
- System.out.println(" options: [-?|-h|--help] [-o:|--outdir:]");
- System.out.println(" -?|-h|--help - print help");
- System.out.println(" -o:|--outdir: - set to generate output");
+ for (String line : MSG_HELP)
+ System.out.println(line);
}
private static class Option {
- private String optionName;
- private String optionValue;
+ private final String optionName;
+ private final String optionValue;
public Option(String arg) {
- int delimPos = arg.indexOf(':');
+ int delimPos = arg.indexOf('=');
if (delimPos == -1) {
optionName = arg;
diff --git a/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/generator/DocCommentGenerator.java b/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/generator/DocCommentGenerator.java
index b3ca960fe4e..c81d6d06bfb 100644
--- a/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/generator/DocCommentGenerator.java
+++ b/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/generator/DocCommentGenerator.java
@@ -199,11 +199,11 @@ class DocCommentGenerator {
public String getPackageComment() {
return InlineTag.INDEX.value("PackageCommentLabel") + " "
+ Text.LOREMIPSUM
- + "\n
" + Text.LIEUROPANLINGUES
+ + "\n
" + Text.LIEUROPANLINGUES
+ "\n" + Text.CODE
+ "\n" + LinkTag.nextLink()
+ "\n" + LinkTag.nextSee()
- + "\n" + Tag.SINCE;
+ + "\n" + Tag.SINCE + "\n";
}
String[] serialVals = new String[] { "include", "exclude" };
diff --git a/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/generator/PackageGenerator.java b/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/generator/PackageGenerator.java
index 8e7ed7c1d4c..cab0adea709 100644
--- a/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/generator/PackageGenerator.java
+++ b/langtools/test/jdk/javadoc/tool/sampleapi/lib/sampleapi/generator/PackageGenerator.java
@@ -29,14 +29,14 @@ import java.io.InputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.Text;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -54,7 +54,6 @@ import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.TypeTag;
-import com.sun.tools.javac.code.TypeMetadata;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symtab;
@@ -67,16 +66,16 @@ public class PackageGenerator {
String packageDirName;
ArrayList topLevels;
- Hashtable nameIndex;
- Hashtable idBases;
- Hashtable idAnnos;
+ Map nameIndex;
+ Map idBases;
+ Map idAnnos;
TreeMaker make;
Names names;
Symtab syms;
DocumentBuilderFactory factory;
Documentifier documentifier;
- boolean fx = false;
+ boolean fx;
public PackageGenerator() {
JavacTool jt = JavacTool.create();
@@ -91,27 +90,27 @@ public class PackageGenerator {
documentifier = Documentifier.instance(ctx);
}
- String dataSetName;
+ boolean isDataSetProcessed = false;
- public void processDataSet(String dsName) throws Fault {
- dataSetName = dsName;
+ public void processDataSet(File dsFile) throws Fault {
+ isDataSetProcessed = true;
topLevels = new ArrayList<>();
- nameIndex = new Hashtable<>();
- idBases = new Hashtable<>();
- idAnnos = new Hashtable<>();
-
- String dsPath = "res/xml/" + dsName + ".xml";
+ nameIndex = new HashMap<>();
+ idBases = new HashMap<>();
+ idAnnos = new HashMap<>();
+ fx = false;
try {
- InputStream is = getClass().getResourceAsStream("/" + dsPath);
- if (is == null)
- is = new FileInputStream(dsPath);
+ InputStream is = new FileInputStream(dsFile);
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(is);
Element rootElement = document.getDocumentElement();
- packageName = rootElement.getAttribute("package");
+ if (!rootElement.getTagName().equals("package"))
+ throw new IllegalStateException("Unexpected tag name: "
+ + rootElement.getTagName());
+ packageName = rootElement.getAttribute("name");
fx = "fx".equals(rootElement.getAttribute("style"));
packageDirName = packageName.replace('.', '/');
@@ -122,17 +121,15 @@ public class PackageGenerator {
if (!(node instanceof Element))
continue;
- processTopLevel((Element)node);
+ processTopLevel((Element) node);
}
} catch (ParserConfigurationException | SAXException | IOException e) {
- throw new Fault("Error parsing dataset " + dsName, e);
+ throw new Fault("Error parsing dataset " + dsFile, e);
}
-
- fx = false;
}
public void generate(File outDir) throws Fault {
- if (dataSetName == null)
+ if (!isDataSetProcessed)
throw new Fault("No Data Set processed");
try {
@@ -140,9 +137,9 @@ public class PackageGenerator {
pkgDir.mkdirs();
for (JCCompilationUnit decl : topLevels) {
- JCClassDecl classDecl = (JCClassDecl)decl.getTypeDecls().get(0);
- File outFile = new File(pkgDir,
- classDecl.getSimpleName().toString() + ".java");
+ JCClassDecl classDecl = (JCClassDecl) decl.getTypeDecls().get(0);
+ File outFile
+ = new File(pkgDir, classDecl.getSimpleName().toString() + ".java");
FileWriter writer = new FileWriter(outFile);
writer.write(decl.toString());
writer.flush();
@@ -155,7 +152,19 @@ public class PackageGenerator {
writer.write("/**\n");
writer.write(documentifier.getDocGenerator().getPackageComment());
writer.write("*/\n");
- writer.write("package " + packageName + ";");
+ writer.write("package " + packageName + ";\n");
+ writer.flush();
+ writer.close();
+
+ // overview
+ outFile = new File(pkgDir, "overview.html");
+ writer = new FileWriter(outFile);
+ writer.write("\n");
+ writer.write("\n" + packageName + "\n\n");
+ writer.write("\n");
+ writer.write("
Package " + packageName + " overview.\n");
+ writer.write("\n");
+ writer.write("\n");
writer.flush();
writer.close();
} catch (IOException e) {
@@ -197,7 +206,7 @@ public class PackageGenerator {
}
}
- ListBuffer[] processBases(Element baseTag, Hashtable scope) {
+ ListBuffer[] processBases(Element baseTag, HashMap scope) {
String kind = baseTag.getTagName();
String baseName = baseTag.getAttribute("basename");
String typeParam = baseTag.getAttribute("tparam");
@@ -232,21 +241,21 @@ public class PackageGenerator {
if (!(node instanceof Element))
continue;
-
- switch (((Element)node).getTagName()) {
+ Element element = (Element)node;
+ switch (element.getTagName()) {
case "modifier":
- multiply.addAxis(((Element)node).getTextContent());
+ multiply.addAxis(element.getTextContent());
break;
case "anno":
- multiply.addAxis(((Element)node).getTextContent());
+ multiply.addAxis(element.getTextContent());
break;
case "member":
// process members here
- members.appendList(processMembers((Element)node, baseName, kind));
+ members.appendList(processMembers(element, baseName, kind));
break;
case "extend":
- String classId = ((Element)node).getAttribute("id"); // this pkg
- String classRef = ((Element)node).getAttribute("ref"); // external
+ String classId = element.getAttribute("id"); // this pkg
+ String classRef = element.getAttribute("ref"); // external
if (classId.length() !=0 &&
idBases.containsKey(classId)) {
// if have base, take methods from base members
@@ -260,8 +269,8 @@ public class PackageGenerator {
}
break;
case "implement":
- String interfaceId = ((Element)node).getAttribute("id");
- String interfaceRef = ((Element)node).getAttribute("ref");
+ String interfaceId = element.getAttribute("id");
+ String interfaceRef = element.getAttribute("ref");
if (interfaceId.length() != 0 &&
idBases.containsKey(interfaceId)) {
JCClassDecl baseDecl = idBases.get(interfaceId);
@@ -277,7 +286,7 @@ public class PackageGenerator {
case "import":
imports.append(
make.Import(
- make.Ident(names.fromString(((Element)node).getTextContent())),
+ make.Ident(names.fromString(element.getTextContent())),
false));
}
}
@@ -342,7 +351,7 @@ public class PackageGenerator {
ListBuffer processMembers(Element memberTag, String name, String kind) {
ListBuffer members = new ListBuffer<>();
NodeList nodes = memberTag.getChildNodes();
- Hashtable scope = new Hashtable<>();
+ HashMap scope = new HashMap<>();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
@@ -378,7 +387,7 @@ public class PackageGenerator {
return members;
}
- ListBuffer processFields(Element fieldsNode, Hashtable scope) {
+ ListBuffer processFields(Element fieldsNode, HashMap scope) {
String kind = fieldsNode.getTagName();
String baseName = fieldsNode.getAttribute("basename");
@@ -431,7 +440,7 @@ public class PackageGenerator {
TypeTag.BOT,
"String".equals(type)
? new String("blah-blah-blah")
- : new Integer(0));
+ : Integer.valueOf(0));
JCVariableDecl fieldDecl = make.VarDef(
make.Modifiers(declFlags, annos.toList()),
@@ -451,7 +460,7 @@ public class PackageGenerator {
String[] fieldTypes = sfNode.getTextContent().split(",");
ListBuffer serialFields = new ListBuffer<>();
- Hashtable scope = new Hashtable<>();
+ HashMap scope = new HashMap<>();
for (String fType : fieldTypes) {
String fieldName = baseName + getUniqIndex(scope, baseName);
@@ -482,7 +491,7 @@ public class PackageGenerator {
return sfDecl;
}
- ListBuffer processConstants(Element constNode, Hashtable scope) {
+ ListBuffer processConstants(Element constNode, HashMap scope) {
String baseName = constNode.getAttribute("basename");
int count = 1;
try {
@@ -507,7 +516,7 @@ public class PackageGenerator {
return fields;
}
- ListBuffer processMethods(Element methodsNode, Hashtable scope, boolean needBody, boolean isConstructor) {
+ ListBuffer processMethods(Element methodsNode, HashMap scope, boolean needBody, boolean isConstructor) {
String kind = methodsNode.getTagName();
String baseName = methodsNode.getAttribute("basename");
String name = methodsNode.getAttribute("name");
@@ -590,7 +599,7 @@ public class PackageGenerator {
retType.isPrimitive() ?
retType.getTag() :
TypeTag.BOT,
- new Integer(0))));
+ Integer.valueOf(0))));
}
body = make.Block(0, bodyStatements);
}
@@ -681,7 +690,7 @@ public class PackageGenerator {
retType.isPrimitive() ?
retType.getTag() :
TypeTag.BOT,
- new Integer(0))));
+ Integer.valueOf(0))));
JCBlock body = make.Block(0, bodyStatements);
@@ -763,16 +772,16 @@ public class PackageGenerator {
String getUniqName(String name) {
if (!nameIndex.containsKey(name))
- nameIndex.put(name, new Integer(0));
+ nameIndex.put(name, 0);
Integer index = nameIndex.get(name);
String uniqName = name + index;
nameIndex.put(name, index + 1);
return uniqName;
}
- int getUniqIndex(Hashtable scope, String name) {
+ int getUniqIndex(HashMap scope, String name) {
if (!scope.containsKey(name))
- scope.put(name, new Integer(0));
+ scope.put(name, 0);
Integer index = scope.get(name);
scope.put(name, index + 1);
return index;
diff --git a/langtools/test/tools/javadoc/sampleapi/res/xml/fx.xml b/langtools/test/jdk/javadoc/tool/sampleapi/res/fx.xml
similarity index 92%
rename from langtools/test/tools/javadoc/sampleapi/res/xml/fx.xml
rename to langtools/test/jdk/javadoc/tool/sampleapi/res/fx.xml
index 7f1c083c8f7..d26177227bf 100644
--- a/langtools/test/tools/javadoc/sampleapi/res/xml/fx.xml
+++ b/langtools/test/jdk/javadoc/tool/sampleapi/res/fx.xml
@@ -1,6 +1,6 @@
-
+public
@@ -42,4 +42,4 @@
-
+
diff --git a/langtools/test/jdk/javadoc/tool/sampleapi/res/xml/simple.xml b/langtools/test/jdk/javadoc/tool/sampleapi/res/simple.xml
similarity index 99%
rename from langtools/test/jdk/javadoc/tool/sampleapi/res/xml/simple.xml
rename to langtools/test/jdk/javadoc/tool/sampleapi/res/simple.xml
index f0bc25fc504..b5a49159b9d 100644
--- a/langtools/test/jdk/javadoc/tool/sampleapi/res/xml/simple.xml
+++ b/langtools/test/jdk/javadoc/tool/sampleapi/res/simple.xml
@@ -21,7 +21,7 @@
or visit www.oracle.com if you need additional information or have any
questions.
-->
-
+public
@@ -526,4 +526,4 @@
-
+
diff --git a/langtools/test/jdk/javadoc/tool/sampleapi/res/sub.xml b/langtools/test/jdk/javadoc/tool/sampleapi/res/sub.xml
new file mode 100644
index 00000000000..ff007c781ac
--- /dev/null
+++ b/langtools/test/jdk/javadoc/tool/sampleapi/res/sub.xml
@@ -0,0 +1,89 @@
+
+
+
+
+
+ public
+ none|abstract
+ SInterface0
+
+
+ public
+ int
+
+
+ public
+ int
+ SException0
+
+
+ public
+ int
+ void
+ SException0
+
+
+
+
+
+ public
+
+
+
+ public
+ String
+
+
+
+
+
+ public
+
+
+ public
+ void
+ int
+
+
+
+
+
+ public
+
+
+
+
+
+
+
+ public
+
+
+ public
+ boolean
+
+
+
+
+
diff --git a/langtools/test/tools/javadoc/sampleapi/res/xml/tiny.xml b/langtools/test/jdk/javadoc/tool/sampleapi/res/tiny.xml
similarity index 97%
rename from langtools/test/tools/javadoc/sampleapi/res/xml/tiny.xml
rename to langtools/test/jdk/javadoc/tool/sampleapi/res/tiny.xml
index 6fa5533553a..1bf631faa8c 100644
--- a/langtools/test/tools/javadoc/sampleapi/res/xml/tiny.xml
+++ b/langtools/test/jdk/javadoc/tool/sampleapi/res/tiny.xml
@@ -21,7 +21,7 @@
or visit www.oracle.com if you need additional information or have any
questions.
-->
-
+public
@@ -68,4 +68,4 @@
-
+
diff --git a/langtools/test/jdk/javadoc/tool/sampleapi/res/tinysub.xml b/langtools/test/jdk/javadoc/tool/sampleapi/res/tinysub.xml
new file mode 100644
index 00000000000..99b181f4899
--- /dev/null
+++ b/langtools/test/jdk/javadoc/tool/sampleapi/res/tinysub.xml
@@ -0,0 +1,89 @@
+
+
+
+
+
+ public
+ none|abstract
+ TSInterface0
+
+
+ public
+ int
+
+
+ public
+ int
+ TSException0
+
+
+ public
+ int
+ void
+ TSException0
+
+
+
+
+
+ public
+
+
+
+ public
+ String
+
+
+
+
+
+ public
+
+
+ public
+ void
+ int
+
+
+
+
+
+ public
+
+
+
+
+
+
+
+ public
+
+
+ public
+ boolean
+
+
+
+
+
diff --git a/langtools/test/tools/javadoc/sampleapi/README.txt b/langtools/test/tools/javadoc/sampleapi/README.txt
deleted file mode 100644
index f8e55c8f043..00000000000
--- a/langtools/test/tools/javadoc/sampleapi/README.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-
- SampleAPI Generator for javadoc
-
-1. General description
-
- The primary goal is to provide one or more data sets to be used as input
-to the javadoc tool, such that it can be used to generate representative samples
-of all the different content on all the different types of pages that can be
-generated by javadoc.
-
- The tool is implemented as generator based on xml descriptions of data sets.
-The xml description of data set provides top level entities (class, interface,
-enum, annotation) with all possible content. Desired output parameters (fields,
-methods, inner/nested classes) are also described in xml as lists of modifiers,
-types and annotations. The generator "multiply" the entities from the lists
-providing the set of all possible combinations.
-
- After the api generation the tool connects the javadoc style comments to
-the generated entities with full possible sets of supported tags.
-
-2. Tool structure
-
- Sources:
- test/tools/javadoc/sampleapi/lib - generator sources
- test/tools/javadoc/sampleapi/res/xml - sample data sets in xml
- test/tools/javadoc/sampleapi/res/txt - sample texts for doc comments
-
-3. Public API
-
-3.1 Command line runner
-
- * test/tools/javadoc/sampleapi/lib/sampleapi/SampleApiDefaultRunner.java
-
- class sampleapi.SampleApiDefaultRunner
-
- Options: [-?|-h|--help] [-o:|--outdir:]
- -?|-h|--help - print help
- -o:|--outdir: - set to generate output
-
-3.2 Programmatic access
-
- * test/tools/javadoc/sampleapi/lib/sampleapi/SampleApi.java
-
- class sampleapi.SampleApi
-
- public void generate(File dir)
- public void generate(Path dir)
- public void generate(String dir)
-
-3.3 How to run other xml data set description
-
- Put data set xml description into res/xml directory
-
- * test/tools/javadoc/sampleapi/lib/sampleapi/generator/PackageGenerator.java
-
- class sampleapi.generator.PackageGenerator
-
- public void processDataSet(String dsName)
- public void generate(File outDir)
diff --git a/langtools/test/tools/javadoc/sampleapi/SampleApiTest.java b/langtools/test/tools/javadoc/sampleapi/SampleApiTest.java
index 593693924a9..149d347cd55 100644
--- a/langtools/test/tools/javadoc/sampleapi/SampleApiTest.java
+++ b/langtools/test/tools/javadoc/sampleapi/SampleApiTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,24 +24,31 @@
/*
* @test
* @bug 8130880
- * @library lib
+ * @library /jdk/javadoc/tool/sampleapi/lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.code
* jdk.compiler/com.sun.tools.javac.parser
* jdk.compiler/com.sun.tools.javac.tree
* jdk.compiler/com.sun.tools.javac.util
- * @run main sampleapi.SampleApiDefaultRunner -o:out/src
* @run main SampleApiTest
*/
import com.sun.tools.javadoc.*;
+import sampleapi.*;
public class SampleApiTest {
- public static void main(String... args) {
+ public static void main(String... args) throws Exception {
+
+ // generate
+ SampleApiDefaultRunner.execute(
+ new String[] {
+ "-o=out/src",
+ "-r=" + System.getProperty("test.src") + "/res"
+ });
// html4
- Main.execute(
+ int res1 = Main.execute(
new String[] {
"-d", "out/doc.html4",
"-verbose",
@@ -54,12 +61,13 @@ public class SampleApiTest {
"-windowtitle", "SampleAPI",
"-sourcepath", "out/src",
"sampleapi.simple",
+ "sampleapi.simple.sub",
"sampleapi.tiny",
"sampleapi.fx"
});
// html5
- Main.execute(
+ int res2 = Main.execute(
new String[] {
"-d", "out/doc.html5",
"-verbose",
@@ -72,8 +80,13 @@ public class SampleApiTest {
"-windowtitle", "SampleAPI",
"-sourcepath", "out/src",
"sampleapi.simple",
+ "sampleapi.simple.sub",
"sampleapi.tiny",
"sampleapi.fx"
});
+
+ if (res1 + res2 > 0)
+ throw new Exception("One of exit statuses of test execution is non-zero: "
+ + res1 + " for HTML4, " + res2 + " for HTML5.");
}
}
diff --git a/langtools/test/tools/javadoc/sampleapi/lib/sampleapi/SampleApi.java b/langtools/test/tools/javadoc/sampleapi/lib/sampleapi/SampleApi.java
deleted file mode 100644
index 536787bcc26..00000000000
--- a/langtools/test/tools/javadoc/sampleapi/lib/sampleapi/SampleApi.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sampleapi;
-
-import java.io.File;
-import java.nio.file.Path;
-
-import sampleapi.generator.PackageGenerator;
-
-public class SampleApi {
-
- PackageGenerator pkgGen = new PackageGenerator();
-
- public void generate(File dir) throws Fault {
- pkgGen.processDataSet("simple");
- pkgGen.generate(dir);
- pkgGen.processDataSet("tiny");
- pkgGen.generate(dir);
- pkgGen.processDataSet("fx");
- pkgGen.generate(dir);
- }
-
- public void generate(Path dir) throws Fault {
- generate(dir.toFile());
- }
-
- public void generate(String dir) throws Fault {
- generate(new File(dir));
- }
-
- public static class Fault extends Exception {
- public Fault(String msg) {
- super(msg);
- }
- public Fault(String msg, Throwable th) {
- super(msg, th);
- }
- }
-}
diff --git a/langtools/test/tools/javadoc/sampleapi/lib/sampleapi/SampleApiDefaultRunner.java b/langtools/test/tools/javadoc/sampleapi/lib/sampleapi/SampleApiDefaultRunner.java
deleted file mode 100644
index 90f838eacf2..00000000000
--- a/langtools/test/tools/javadoc/sampleapi/lib/sampleapi/SampleApiDefaultRunner.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sampleapi;
-
-import java.io.File;
-
-import sampleapi.SampleApi.Fault;
-
-public class SampleApiDefaultRunner {
-
- public static final String MSG_DUP_OUTDIR =
- "SampleApi: duplicated outdir detected: ";
- public static final String MSG_USE_FIRST =
- " will use first occurance: ";
- public static final String MSG_INVAL_OUTDIR =
- "SampleApi: outdir is not valid: ";
- public static final String MSG_CANNOT_GEN =
- "SampleApi: cannot generate output: ";
- public static final String MSG_WRONG_OPTION =
- "SampleApi: incorrect option: ";
- public static final String MSG_USE_HELP =
- " use -? for help";
-
- public static void main(String... args) throws Exception {
- if (args.length == 0) {
- printHelp();
- System.exit(1);
- }
-
- String outDirName = "";
-
- boolean isOutDirSet = false;
- boolean isHelpPrinted = false;
- for (String arg : args) {
- Option option = new Option(arg);
- switch (option.getOptionName()) {
- case "-?":
- case "-h":
- case "--help":
- if (!isHelpPrinted) {
- printHelp();
- isHelpPrinted = true;
- }
- break;
- case "-o":
- case "--outdir":
- if (!isOutDirSet) {
- outDirName = option.getOptionValue();
- isOutDirSet = true;
- } else {
- System.err.println(MSG_DUP_OUTDIR + option.getOptionValue());
- System.err.println(MSG_USE_FIRST + outDirName);
- }
- break;
- default:
- System.err.println(MSG_WRONG_OPTION + arg);
- System.err.println(MSG_USE_HELP);
- break;
- }
-
- }
-
- if (!isOutDirSet) {
- System.exit(1);
- }
-
- if (outDirName.length() == 0) {
- System.err.println(MSG_INVAL_OUTDIR + outDirName);
- System.exit(1);
- }
-
- File outDir = new File(outDirName);
- outDir.mkdirs();
- SampleApi apiGen = new SampleApi();
-
- try {
- apiGen.generate(outDir);
- } catch (Fault e) {
- System.err.println(MSG_CANNOT_GEN + e.getMessage());
- e.printStackTrace();
- }
- }
-
- private static void printHelp() {
- System.out.println("SampleApi:");
- System.out.println(" options: [-?|-h|--help] [-o:|--outdir:]");
- System.out.println(" -?|-h|--help - print help");
- System.out.println(" -o:|--outdir: - set to generate output");
- }
-
- private static class Option {
-
- private String optionName;
- private String optionValue;
-
- public Option(String arg) {
- int delimPos = arg.indexOf(':');
-
- if (delimPos == -1) {
- optionName = arg;
- optionValue = "";
- } else {
- optionName = arg.substring(0, delimPos);
- optionValue = arg.substring(delimPos + 1, arg.length());
- }
- }
-
- public String getOptionName() {
- return optionName;
- }
-
- public String getOptionValue() {
- return optionValue;
- }
- }
-}
diff --git a/langtools/test/tools/javadoc/sampleapi/lib/sampleapi/generator/DocCommentGenerator.java b/langtools/test/tools/javadoc/sampleapi/lib/sampleapi/generator/DocCommentGenerator.java
deleted file mode 100644
index b3ca960fe4e..00000000000
--- a/langtools/test/tools/javadoc/sampleapi/lib/sampleapi/generator/DocCommentGenerator.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sampleapi.generator;
-
-import java.io.File;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.util.Set;
-import javax.lang.model.element.Modifier;
-
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.*;
-import com.sun.tools.javac.util.List;
-import java.util.HashMap;
-import java.util.Map;
-
-class DocCommentGenerator {
-
- public enum Text {
- BROWNFOX(BROWNFOX_TEXT),
- NOWISTHETIME(NOWISTHETIME_TEXT),
- THISPANGRAM(THISPANGRAM_TEXT),
- LOREMIPSUM(LOREMIPSUM_TEXT),
- LIEUROPANLINGUES(LIEUROPANLINGUES_TEXT),
- CODE(CODE_TEXT);
-
- String commentText;
-
- Text(String text) {
- commentText = text;
- }
-
- @Override
- public String toString() {
- return commentText;
- }
- }
-
- public enum Tag {
- AUTHOR("@author", "Cody J. Writer"),
- PARAM("@param", ""),
- RETURN("@return", Text.NOWISTHETIME.toString()),
- SINCE("@since", "1.0"),
- THROWS("@throws", "If problem detected"),
- EXCEPTION("@exception", "If problem detected"),
- SERIAL("@serial", ""),
- SERIALDATA("@serialData", "The types and order of data could be here."),
- SERIALFIELD("@serialField", "\n Serial field in special array"),
- FX_PROPSETTER("@propertySetter", "Set the property"),
- FX_PROPGETTER("@propertyGetter", "Get the property"),
- FX_PROPDESC("@propertyDescription", ""),
- FX_DEFVALUE("@defaultValue", ""),
- FX_TREATASPRIVATE("@treatAsPrivate", "");
-
- String tagName;
- String tagValue;
-
- Tag(String tagName, String tagValue) {
- this.tagName = tagName;
- this.tagValue = tagValue;
- }
-
- public String toString() {
- return value("", "");
- }
-
- public String value(String value) {
- return value(value, "");
- }
-
- public String value(String value, String extra) {
- return tagName
- + ((value.length() != 0) ? " " + value : "")
- + ((tagValue.length() != 0) ? " " + tagValue : "")
- + ((extra.length() != 0) ? " " + extra : "");
- }
- }
-
- public enum InlineTag {
- LITERAL("@literal", "Use < and > brackets instead of < and > escapes."),
- CODE("@code", "(i) -> new Abc