diff --git a/langtools/make/build.xml b/langtools/make/build.xml
index 52b13b7226a..be1c357852c 100644
--- a/langtools/make/build.xml
+++ b/langtools/make/build.xml
@@ -1,6 +1,6 @@
+ style="${checkstyle.home}/contrib/checkstyle-simple.xsl"/>
-
+
-
+
@@ -368,7 +368,7 @@
executable="${dist.bin.dir}/javac"
srcdir="test/tools/javac/diags"
destdir="${build.dir}/diag-examples/classes"
- includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java"
+ includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java,DocCommentProcessor.java"
sourcepath=""
classpath="${dist.lib.dir}/javac.jar"
includeAntRuntime="no"
@@ -381,6 +381,7 @@
dir="test/tools/javac/diags"
classpath="${build.dir}/diag-examples/classes;${dist.lib.dir}/javac.jar"
classname="RunExamples">
+
@@ -695,7 +696,7 @@
-
+
@@ -1005,7 +1006,7 @@
-
+
diff --git a/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java b/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java
new file mode 100644
index 00000000000..26dd4c3995f
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for an attribute in an HTML element.
+ *
+ * @since 1.8
+ */
+public interface AttributeTree extends DocTree {
+ enum ValueKind { EMPTY, UNQUOTED, SINGLE, DOUBLE };
+
+ Name getName();
+ ValueKind getValueKind();
+ List extends DocTree> getValue();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java b/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java
new file mode 100644
index 00000000000..d6580c5eaf2
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @author block tag.
+ *
+ *
+ * @author name-text.
+ *
+ * @since 1.8
+ */
+public interface AuthorTree extends BlockTagTree {
+ List extends DocTree> getName();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java
new file mode 100644
index 00000000000..9c72c1d973b
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+/**
+ * A tree node used as the base class for the different types of
+ * block tags.
+ *
+ * @since 1.8
+ */
+public interface BlockTagTree extends DocTree {
+ String getTagName();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java b/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java
new file mode 100644
index 00000000000..cd89cf5ca0d
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+/**
+ * An embedded HTML comment.
+ *
+ *
+ * {@literal }
+ *
+ * @since 1.8
+ */
+public interface CommentTree extends DocTree {
+ String getBody();
+}
+
diff --git a/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java b/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java
new file mode 100644
index 00000000000..c24baacc7ee
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @deprecated block tag.
+ *
+ *
+ * @deprecated deprecated text.
+ *
+ * @since 1.8
+ */
+public interface DeprecatedTree extends BlockTagTree {
+ List extends DocTree> getBody();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java b/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java
new file mode 100644
index 00000000000..d59cfffc2db
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * The top level representation of a documentation comment.
+ *
+ *
+ * first-sentence body block-tags
+ *
+ * @since 1.8
+ */
+public interface DocCommentTree extends DocTree {
+ List extends DocTree> getFirstSentence();
+ List extends DocTree> getBody();
+ List extends DocTree> getBlockTags();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocRootTree.java b/langtools/src/share/classes/com/sun/source/doctree/DocRootTree.java
new file mode 100644
index 00000000000..05205fb0faf
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocRootTree.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+/**
+ * A tree node for an @docroot inline tag.
+ *
+ *
+ * {@docroot}
+ *
+ * @since 1.8
+ */
+public interface DocRootTree extends InlineTagTree { }
diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocTree.java b/langtools/src/share/classes/com/sun/source/doctree/DocTree.java
new file mode 100644
index 00000000000..a28cdcbe852
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocTree.java
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+/**
+ * Common interface for all nodes in a documentation syntax tree.
+ *
+ * @since 1.8
+ */
+public interface DocTree {
+ enum Kind {
+ /**
+ * Used for instances of {@link AttributeTree}
+ * representing an HTML attribute.
+ */
+ ATTRIBUTE,
+
+ /**
+ * Used for instances of {@link AuthorTree}
+ * representing an @author tag.
+ */
+ AUTHOR("author"),
+
+ /**
+ * Used for instances of {@link LiteralTree}
+ * representing an @code tag.
+ */
+ CODE("code"),
+
+ /**
+ * Used for instances of {@link CommentTree}
+ * representing an HTML comment.
+ */
+ COMMENT,
+
+ /**
+ * Used for instances of {@link DeprecatedTree}
+ * representing an @deprecated tag.
+ */
+ DEPRECATED("deprecated"),
+
+ /**
+ * Used for instances of {@link DocCommentTree}
+ * representing a complete doc comment.
+ */
+ DOC_COMMENT,
+
+ /**
+ * Used for instances of {@link DocRootTree}
+ * representing an @docRoot tag.
+ */
+ DOC_ROOT("docRoot"),
+
+ /**
+ * Used for instances of {@link EndElementTree}
+ * representing the end of an HTML element.
+ */
+ END_ELEMENT,
+
+ /**
+ * Used for instances of {@link EntityTree}
+ * representing an HTML entity.
+ */
+ ENTITY,
+
+ /**
+ * Used for instances of {@link ErroneousTree}
+ * representing some invalid text.
+ */
+ ERRONEOUS,
+
+ /**
+ * Used for instances of {@link ThrowsTree}
+ * representing an @exception tag.
+ */
+ EXCEPTION("exception"),
+
+ /**
+ * Used for instances of {@link IdentifierTree}
+ * representing an identifier.
+ */
+ IDENTIFIER,
+
+ /**
+ * Used for instances of {@link InheritDocTree}
+ * representing an @inheritDoc tag.
+ */
+ INHERIT_DOC("inheritDoc"),
+
+ /**
+ * Used for instances of {@link LinkTree}
+ * representing an @link tag.
+ */
+ LINK("link"),
+
+ /**
+ * Used for instances of {@link LinkTree}
+ * representing an @linkplain tag.
+ */
+ LINK_PLAIN("linkplain"),
+
+ /**
+ * Used for instances of {@link LiteralTree}
+ * representing an @literal tag.
+ */
+ LITERAL("literal"),
+
+ /**
+ * Used for instances of {@link ParamTree}
+ * representing an @param tag.
+ */
+ PARAM("param"),
+
+ /**
+ * Used for instances of {@link ReferenceTree}
+ * representing a reference to a element in the
+ * Java programming language.
+ */
+ REFERENCE,
+
+ /**
+ * Used for instances of {@link ReturnTree}
+ * representing an @return tag.
+ */
+ RETURN("return"),
+
+ /**
+ * Used for instances of {@link SeeTree}
+ * representing an @see tag.
+ */
+ SEE("see"),
+
+ /**
+ * Used for instances of {@link SerialTree}
+ * representing an @serial tag.
+ */
+ SERIAL("serial"),
+
+ /**
+ * Used for instances of {@link SerialDataTree}
+ * representing an @serialData tag.
+ */
+ SERIAL_DATA("serialData"),
+
+ /**
+ * Used for instances of {@link SerialFieldTree}
+ * representing an @serialField tag.
+ */
+ SERIAL_FIELD("serialField"),
+
+ /**
+ * Used for instances of {@link SinceTree}
+ * representing an @since tag.
+ */
+ SINCE("since"),
+
+ /**
+ * Used for instances of {@link EndElementTree}
+ * representing the start of an HTML element.
+ */
+ START_ELEMENT,
+
+ /**
+ * Used for instances of {@link TextTree}
+ * representing some documentation text.
+ */
+ TEXT,
+
+ /**
+ * Used for instances of {@link ThrowsTree}
+ * representing an @throws tag.
+ */
+ THROWS("throws"),
+
+ /**
+ * Used for instances of {@link UnknownBlockTagTree}
+ * representing an unknown block tag.
+ */
+ UNKNOWN_BLOCK_TAG,
+
+ /**
+ * Used for instances of {@link UnknownInlineTagTree}
+ * representing an unknown inline tag.
+ */
+ UNKNOWN_INLINE_TAG,
+
+ /**
+ * Used for instances of {@link ValueTree}
+ * representing an @value tag.
+ */
+ VALUE("value"),
+
+ /**
+ * Used for instances of {@link VersionTree}
+ * representing an @version tag.
+ */
+ VERSION("version"),
+
+ /**
+ * An implementation-reserved node. This is the not the node
+ * you are looking for.
+ */
+ OTHER;
+
+ public final String tagName;
+
+ Kind() {
+ tagName = null;
+ }
+
+ Kind(String tagName) {
+ this.tagName = tagName;
+ }
+ };
+
+ /**
+ * Gets the kind of this tree.
+ *
+ * @return the kind of this tree.
+ */
+ Kind getKind();
+
+ /**
+ * Accept method used to implement the visitor pattern. The
+ * visitor pattern is used to implement operations on trees.
+ *
+ * @param result type of this operation.
+ * @param type of additional data.
+ */
+ R accept(DocTreeVisitor visitor, D data);
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java b/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java
new file mode 100644
index 00000000000..c7feb40d244
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+
+/**
+ * A visitor of trees, in the style of the visitor design pattern.
+ * Classes implementing this interface are used to operate
+ * on a tree when the kind of tree is unknown at compile time.
+ * When a visitor is passed to an tree's {@link DocTree#accept
+ * accept} method, the visitXYZ method most applicable
+ * to that tree is invoked.
+ *
+ *
Classes implementing this interface may or may not throw a
+ * {@code NullPointerException} if the additional parameter {@code p}
+ * is {@code null}; see documentation of the implementing class for
+ * details.
+ *
+ *
WARNING: It is possible that methods will be added to
+ * this interface to accommodate new, currently unknown, doc comment
+ * structures added to future versions of the Java™ programming
+ * language. Therefore, visitor classes directly implementing this
+ * interface may be source incompatible with future versions of the
+ * platform.
+ *
+ * @param the return type of this visitor's methods. Use {@link
+ * Void} for visitors that do not need to return results.
+ * @param
the type of the additional parameter to this visitor's
+ * methods. Use {@code Void} for visitors that do not need an
+ * additional parameter.
+ *
+ * @since 1.8
+ */
+public interface DocTreeVisitor {
+ R visitAttribute(AttributeTree node, P p);
+ R visitAuthor(AuthorTree node, P p);
+ R visitComment(CommentTree node, P p);
+ R visitDeprecated(DeprecatedTree node, P p);
+ R visitDocComment(DocCommentTree node, P p);
+ R visitDocRoot(DocRootTree node, P p);
+ R visitEndElement(EndElementTree node, P p);
+ R visitEntity(EntityTree node, P p);
+ R visitErroneous(ErroneousTree node, P p);
+ R visitIdentifier(IdentifierTree node, P p);
+ R visitInheritDoc(InheritDocTree node, P p);
+ R visitLink(LinkTree node, P p);
+ R visitLiteral(LiteralTree node, P p);
+ R visitParam(ParamTree node, P p);
+ R visitReference(ReferenceTree node, P p);
+ R visitReturn(ReturnTree node, P p);
+ R visitSee(SeeTree node, P p);
+ R visitSerial(SerialTree node, P p);
+ R visitSerialData(SerialDataTree node, P p);
+ R visitSerialField(SerialFieldTree node, P p);
+ R visitSince(SinceTree node, P p);
+ R visitStartElement(StartElementTree node, P p);
+ R visitText(TextTree node, P p);
+ R visitThrows(ThrowsTree node, P p);
+ R visitUnknownBlockTag(UnknownBlockTagTree node, P p);
+ R visitUnknownInlineTag(UnknownInlineTagTree node, P p);
+ R visitValue(ValueTree node, P p);
+ R visitVersion(VersionTree node, P p);
+ R visitOther(DocTree node, P p);
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java b/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java
new file mode 100644
index 00000000000..2584f798c6c
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for the end of an HTML element.
+ *
+ *
+ * </ name >
+ *
+ * @since 1.8
+ */
+public interface EndElementTree extends DocTree {
+ Name getName();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java b/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java
new file mode 100644
index 00000000000..9c6ad50aee0
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import javax.lang.model.element.Name;
+
+
+/**
+ * A tree node for an HTML entity.
+ *
+ *
+ * & name ;
+ *
+ * @since 1.8
+ */
+public interface EntityTree extends DocTree {
+ Name getName();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java b/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java
new file mode 100644
index 00000000000..ca50acbbfc7
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+
+/**
+ * A tree node to stand in for a malformed text
+ *
+ * @since 1.8
+ */
+public interface ErroneousTree extends TextTree {
+ /**
+ * Gets a diagnostic object giving details about
+ * the reason the body text is in error.
+ *
+ * @return a diagnostic
+ */
+ Diagnostic getDiagnostic();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java b/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java
new file mode 100644
index 00000000000..0be2ddf2a34
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import javax.lang.model.element.Name;
+
+/**
+ * An identifier in a documentation comment.
+ *
+ *
+ * name
+ *
+ * @since 1.8
+ */
+public interface IdentifierTree extends DocTree {
+ Name getName();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/InheritDocTree.java b/langtools/src/share/classes/com/sun/source/doctree/InheritDocTree.java
new file mode 100644
index 00000000000..8af74b6a330
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/InheritDocTree.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+/**
+ *
+ * A tree node for an @inheritDoc inline tag.
+ *
+ *
+ * {@inheritDoc}
+ *
+ * @since 1.8
+ */
+public interface InheritDocTree extends InlineTagTree { }
diff --git a/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java
new file mode 100644
index 00000000000..a6cec5307c2
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+/**
+ * A tree node used as the base class for the different types of
+ * inline tags.
+ *
+ * @since 1.8
+ */
+public interface InlineTagTree extends DocTree {
+ String getTagName();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java b/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java
new file mode 100644
index 00000000000..41f28e0e95f
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @link or @linkplain inline tag.
+ *
+ *
+ * {@link reference label}
+ * {@linkplain reference label }
+ *
+ * @since 1.8
+ */
+public interface LinkTree extends InlineTagTree {
+ ReferenceTree getReference();
+ List extends DocTree> getLabel();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java b/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java
new file mode 100644
index 00000000000..0531501fa41
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+/**
+ *
+ * A tree node for an @literal or @code inline tag.
+ *
+ *
+ * {@literal text}
+ *
+ * @since 1.8
+ */
+public interface LiteralTree extends InlineTagTree {
+ TextTree getBody();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java b/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java
new file mode 100644
index 00000000000..a7dcf6a6aac
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @param block tag.
+ *
+ *
+ * @param parameter-name description
+ *
+ * @since 1.8
+ */
+public interface ParamTree extends BlockTagTree {
+ boolean isTypeParameter();
+ IdentifierTree getName();
+ List extends DocTree> getDescription();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java b/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java
new file mode 100644
index 00000000000..1ab12de2498
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+/**
+ * A tree node to a reference to a Java language element.
+ *
+ *
+ * package.class#field
+ *
+ * @since 1.8
+ */
+public interface ReferenceTree extends DocTree {
+ String getSignature();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java b/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java
new file mode 100644
index 00000000000..5b0fe313ac7
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @return block tag.
+ *
+ *
+ * @return description
+ *
+ * @since 1.8
+ */
+public interface ReturnTree extends BlockTagTree {
+ List extends DocTree> getDescription();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java b/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java
new file mode 100644
index 00000000000..6d70194aacb
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ *
+ * A tree node for an @see block tag.
+ *
+ *
+ * @see "string"
+ * @see <a href="URL#value"> label </a>
+ * @see reference
+ *
+ * @since 1.8
+ */
+public interface SeeTree extends BlockTagTree {
+ List extends DocTree> getReference();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java
new file mode 100644
index 00000000000..02c2f26c943
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @serialData block tag.
+ *
+ *
+ * @serialData data-description
+ *
+ * @since 1.8
+ */
+public interface SerialDataTree extends BlockTagTree {
+ List extends DocTree> getDescription();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java
new file mode 100644
index 00000000000..eb47017c331
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @serialData block tag.
+ *
+ *
+ * @serialField field-name field-type field-description
+ *
+ * @since 1.8
+ */
+public interface SerialFieldTree extends BlockTagTree {
+ IdentifierTree getName();
+ ReferenceTree getType();
+ List extends DocTree> getDescription();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java
new file mode 100644
index 00000000000..5f5f6ccaa92
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @serial block tag.
+ *
+ *
+ * @serial field-description | include | exclude
+ *
+ * @since 1.8
+ */
+public interface SerialTree extends BlockTagTree {
+ List extends DocTree> getDescription();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java b/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java
new file mode 100644
index 00000000000..60090967e10
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @since block tag.
+ *
+ *
+ * @since since-text
+ *
+ * @since 1.8
+ */
+public interface SinceTree extends BlockTagTree {
+ List extends DocTree> getBody();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java b/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java
new file mode 100644
index 00000000000..f3d4f28ddbe
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for the start of an HTML element.
+ *
+ *
+ * < name [attributes] [/]>
+ *
+ * @since 1.8
+ */
+public interface StartElementTree extends DocTree {
+ Name getName();
+ List extends DocTree> getAttributes();
+ boolean isSelfClosing();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/TextTree.java b/langtools/src/share/classes/com/sun/source/doctree/TextTree.java
new file mode 100644
index 00000000000..5db02702a10
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/TextTree.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+/**
+ * A tree node for plain text.
+ *
+ * @since 1.8
+ */
+public interface TextTree extends DocTree {
+ String getBody();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java b/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java
new file mode 100644
index 00000000000..795d3a38f62
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ *
+ * A tree node for an @exception or @throws block tag.
+ * @exception is a synonym for @throws.
+ *
+ *
+ * @exception class-name description
+ * @throws class-name description
+ *
+ * @since 1.8
+ */
+public interface ThrowsTree extends BlockTagTree {
+ ReferenceTree getExceptionName();
+ List extends DocTree> getDescription();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java
new file mode 100644
index 00000000000..f985dc39d12
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an unrecognized inline tag.
+ *
+ *
+ * @name content
+ *
+ * @since 1.8
+ *
+ */
+public interface UnknownBlockTagTree extends BlockTagTree {
+ List extends DocTree> getContent();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java
new file mode 100644
index 00000000000..9ab78173592
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an unrecognized inline tag.
+ *
+ *
+ * {@name content}
+ *
+ * @since 1.8
+ *
+ */
+public interface UnknownInlineTagTree extends InlineTagTree {
+ List extends DocTree> getContent();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java b/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java
new file mode 100644
index 00000000000..3f61f2519b4
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+/**
+ * A tree node for an @value inline tag.
+ *
+ *
+ * { @value reference }
+ *
+ * @since 1.8
+ */
+public interface ValueTree extends InlineTagTree {
+ ReferenceTree getReference();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java b/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java
new file mode 100644
index 00000000000..4595ec04a5e
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ *
+ * A tree node for an @version block tag.
+ *
+ *
+ * @version version-text
+ *
+ * @since 1.8
+ */
+public interface VersionTree extends BlockTagTree {
+ List extends DocTree> getBody();
+}
diff --git a/langtools/src/share/classes/com/sun/source/doctree/package-info.java b/langtools/src/share/classes/com/sun/source/doctree/package-info.java
new file mode 100644
index 00000000000..8b84ed3ec71
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/doctree/package-info.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+/**
+ * Provides interfaces to represent documentation comments as abstract syntax
+ * trees (AST).
+ *
+ * @author Jonathan Gibbons
+ * @since 1.8
+ * @see http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags
+ */
+package com.sun.source.doctree;
diff --git a/langtools/src/share/classes/com/sun/source/tree/Tree.java b/langtools/src/share/classes/com/sun/source/tree/Tree.java
index a558e9e5999..4693b84b52b 100644
--- a/langtools/src/share/classes/com/sun/source/tree/Tree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, 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
@@ -610,7 +610,7 @@ public interface Tree {
* visitor pattern is used to implement operations on trees.
*
* @param result type of this operation.
- * @param type of additonal data.
+ * @param type of additional data.
*/
R accept(TreeVisitor visitor, D data);
}
diff --git a/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java
new file mode 100644
index 00000000000..4d23b2266be
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.util;
+
+import com.sun.source.doctree.*;
+
+
+/**
+ * A TreeVisitor that visits all the child tree nodes.
+ * To visit nodes of a particular type, just override the
+ * corresponding visitXYZ method.
+ * Inside your method, call super.visitXYZ to visit descendant
+ * nodes.
+ *
+ *
The default implementation of the visitXYZ methods will determine
+ * a result as follows:
+ *
+ *
If the node being visited has no children, the result will be null.
+ *
If the node being visited has one child, the result will be the
+ * result of calling {@code scan} on that child. The child may be a simple node
+ * or itself a list of nodes.
+ *
If the node being visited has more than one child, the result will
+ * be determined by calling {@code scan} each child in turn, and then combining the
+ * result of each scan after the first with the cumulative result
+ * so far, as determined by the {@link #reduce} method. Each child may be either
+ * a simple node of a list of nodes. The default behavior of the {@code reduce}
+ * method is such that the result of the visitXYZ method will be the result of
+ * the last child scanned.
+ *
+ *
+ *
Here is an example to count the number of erroneous nodes in a tree:
+ *
+ *
+ * @since 1.8
+ */
+public class DocTreeScanner implements DocTreeVisitor {
+
+ /**
+ * Scan a single node.
+ */
+ public R scan(DocTree node, P p) {
+ return (node == null) ? null : node.accept(this, p);
+ }
+
+ private R scanAndReduce(DocTree node, P p, R r) {
+ return reduce(scan(node, p), r);
+ }
+
+ /**
+ * Scan a list of nodes.
+ */
+ public R scan(Iterable extends DocTree> nodes, P p) {
+ R r = null;
+ if (nodes != null) {
+ boolean first = true;
+ for (DocTree node : nodes) {
+ r = (first ? scan(node, p) : scanAndReduce(node, p, r));
+ first = false;
+ }
+ }
+ return r;
+ }
+
+ private R scanAndReduce(Iterable extends DocTree> nodes, P p, R r) {
+ return reduce(scan(nodes, p), r);
+ }
+
+ /**
+ * Reduces two results into a combined result.
+ * The default implementation is to return the first parameter.
+ * The general contract of the method is that it may take any action whatsoever.
+ */
+ public R reduce(R r1, R r2) {
+ return r1;
+ }
+
+
+/* ***************************************************************************
+ * Visitor methods
+ ****************************************************************************/
+
+ @Override
+ public R visitAttribute(AttributeTree node, P p) {
+ return null;
+ }
+
+ @Override
+ public R visitAuthor(AuthorTree node, P p) {
+ return scan(node.getName(), p);
+ }
+
+ @Override
+ public R visitComment(CommentTree node, P p) {
+ return null;
+ }
+
+ @Override
+ public R visitDeprecated(DeprecatedTree node, P p) {
+ return scan(node.getBody(), p);
+ }
+
+ @Override
+ public R visitDocComment(DocCommentTree node, P p) {
+ R r = scan(node.getFirstSentence(), p);
+ r = scanAndReduce(node.getBody(), p, r);
+ r = scanAndReduce(node.getBlockTags(), p, r);
+ return r;
+ }
+
+ @Override
+ public R visitDocRoot(DocRootTree node, P p) {
+ return null;
+ }
+
+ @Override
+ public R visitEndElement(EndElementTree node, P p) {
+ return null;
+ }
+
+ @Override
+ public R visitEntity(EntityTree node, P p) {
+ return null;
+ }
+
+ @Override
+ public R visitErroneous(ErroneousTree node, P p) {
+ return null;
+ }
+
+ @Override
+ public R visitIdentifier(IdentifierTree node, P p) {
+ return null;
+ }
+
+ @Override
+ public R visitInheritDoc(InheritDocTree node, P p) {
+ return null;
+ }
+
+ @Override
+ public R visitLink(LinkTree node, P p) {
+ R r = scan(node.getReference(), p);
+ r = scanAndReduce(node.getLabel(), p, r);
+ return r;
+ }
+
+ @Override
+ public R visitLiteral(LiteralTree node, P p) {
+ return null;
+ }
+
+ @Override
+ public R visitParam(ParamTree node, P p) {
+ R r = scan(node.getName(), p);
+ r = scanAndReduce(node.getDescription(), p, r);
+ return r;
+ }
+
+ @Override
+ public R visitReference(ReferenceTree node, P p) {
+ return null;
+ }
+
+ @Override
+ public R visitReturn(ReturnTree node, P p) {
+ return scan(node.getDescription(), p);
+ }
+
+ @Override
+ public R visitSee(SeeTree node, P p) {
+ return scan(node.getReference(), p);
+ }
+
+ @Override
+ public R visitSerial(SerialTree node, P p) {
+ return scan(node.getDescription(), p);
+ }
+
+ @Override
+ public R visitSerialData(SerialDataTree node, P p) {
+ return scan(node.getDescription(), p);
+ }
+
+ @Override
+ public R visitSerialField(SerialFieldTree node, P p) {
+ R r = scan(node.getName(), p);
+ r = scanAndReduce(node.getType(), p, r);
+ r = scanAndReduce(node.getDescription(), p, r);
+ return r;
+ }
+
+ @Override
+ public R visitSince(SinceTree node, P p) {
+ return scan(node.getBody(), p);
+ }
+
+ @Override
+ public R visitStartElement(StartElementTree node, P p) {
+ return scan(node.getAttributes(), p);
+ }
+
+ @Override
+ public R visitText(TextTree node, P p) {
+ return null;
+ }
+
+ @Override
+ public R visitThrows(ThrowsTree node, P p) {
+ R r = scan(node.getExceptionName(), p);
+ r = scanAndReduce(node.getDescription(), p, r);
+ return r;
+ }
+
+ @Override
+ public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) {
+ return scan(node.getContent(), p);
+ }
+
+ @Override
+ public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) {
+ return scan(node.getContent(), p);
+ }
+
+ @Override
+ public R visitValue(ValueTree node, P p) {
+ return scan(node.getReference(), p);
+ }
+
+ @Override
+ public R visitVersion(VersionTree node, P p) {
+ return scan(node.getBody(), p);
+ }
+
+ @Override
+ public R visitOther(DocTree node, P p) {
+ return null;
+ }
+
+}
diff --git a/langtools/src/share/classes/com/sun/source/util/DocTrees.java b/langtools/src/share/classes/com/sun/source/util/DocTrees.java
new file mode 100644
index 00000000000..68abf3f5de3
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/util/DocTrees.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.util;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.Element;
+import javax.tools.JavaCompiler.CompilationTask;
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.ReferenceTree;
+import javax.tools.Diagnostic;
+
+/**
+ * Provides access to syntax trees for doc comments.
+ *
+ * @since 1.8
+ */
+public abstract class DocTrees extends Trees {
+ /**
+ * Gets a DocTrees object for a given CompilationTask.
+ * @param task the compilation task for which to get the Trees object
+ * @throws IllegalArgumentException if the task does not support the Trees API.
+ */
+ public static DocTrees instance(CompilationTask task) {
+ if (!task.getClass().getName().equals("com.sun.tools.javac.api.JavacTaskImpl"))
+ throw new IllegalArgumentException();
+ return (DocTrees) getJavacTrees(CompilationTask.class, task);
+ }
+
+ /**
+ * Gets a DocTrees object for a given ProcessingEnvironment.
+ * @param env the processing environment for which to get the Trees object
+ * @throws IllegalArgumentException if the env does not support the Trees API.
+ */
+ public static DocTrees instance(ProcessingEnvironment env) {
+ if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment"))
+ throw new IllegalArgumentException();
+ return (DocTrees) getJavacTrees(ProcessingEnvironment.class, env);
+ }
+
+ /**
+ * Gets the doc comment tree, if any, for the Tree node identified by a given TreePath.
+ * Returns null if no doc comment was found.
+ */
+ public abstract DocCommentTree getDocCommentTree(TreePath path);
+
+ /**
+ * Gets the language model element referred to by a ReferenceTree that
+ * appears on the declaration identified by the given path.
+ */
+ public abstract Element getElement(TreePath path, ReferenceTree reference);
+
+ /**
+ * Prints a message of the specified kind at the location of the
+ * tree within the provided compilation unit
+ *
+ * @param kind the kind of message
+ * @param msg the message, or an empty string if none
+ * @param t the tree to use as a position hint
+ * @param root the compilation unit that contains tree
+ */
+ public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg,
+ com.sun.source.doctree.DocTree t,
+ com.sun.source.doctree.DocCommentTree c,
+ com.sun.source.tree.CompilationUnitTree root);
+}
diff --git a/langtools/src/share/classes/com/sun/source/util/Plugin.java b/langtools/src/share/classes/com/sun/source/util/Plugin.java
new file mode 100644
index 00000000000..66886aa8dec
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/util/Plugin.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2005, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.util;
+
+import java.util.ServiceLoader;
+import javax.tools.StandardLocation;
+
+/**
+ * The interface for a javac plug-in.
+ *
+ *
The javac plug-in mechanism allows a user to specify one or more plug-ins
+ * on the javac command line, to be started soon after the compilation
+ * has begun. Plug-ins are identified by a user-friendly name. Each plug-in that
+ * is started will be passed an array of strings, which may be used to
+ * provide the plug-in with values for any desired options or other arguments.
+ *
+ *
Plug-ins are located via a {@link ServiceLoader},
+ * using the same class path as annotation processors (i.e.
+ * {@link StandardLocation#PROCESSOR_PATH PROCESSOR_PATH} or
+ * {@code -processorpath}).
+ *
+ *
It is expected that a typical plug-in will simply register a
+ * {@link TaskListener} to be informed of events during the execution
+ * of the compilation, and that the rest of the work will be done
+ * by the task listener.
+ *
+ * @since 1.8
+ */
+public interface Plugin {
+ /**
+ * Get the user-friendly name of this plug-in.
+ * @return the user-friendly name of the plug-in
+ */
+ String getName();
+
+ /**
+ * Invoke the plug-in for a given compilation task.
+ * @param task The compilation task that has just been started
+ * @param args Arguments, if any, for the plug-in
+ */
+ void call(JavacTask task, String... args);
+}
diff --git a/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java b/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
new file mode 100644
index 00000000000..a1be626b82e
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2005, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.source.util;
+
+import com.sun.source.doctree.*;
+
+/**
+ * A simple visitor for tree nodes.
+ *
+ * @since 1.8
+ */
+public class SimpleDocTreeVisitor implements DocTreeVisitor {
+ protected final R DEFAULT_VALUE;
+
+ protected SimpleDocTreeVisitor() {
+ DEFAULT_VALUE = null;
+ }
+
+ protected SimpleDocTreeVisitor(R defaultValue) {
+ DEFAULT_VALUE = defaultValue;
+ }
+
+ protected R defaultAction(DocTree node, P p) {
+ return DEFAULT_VALUE;
+ }
+
+ public final R visit(DocTree node, P p) {
+ return (node == null) ? null : node.accept(this, p);
+ }
+
+ public final R visit(Iterable extends DocTree> nodes, P p) {
+ R r = null;
+ if (nodes != null) {
+ for (DocTree node : nodes)
+ r = visit(node, p);
+ }
+ return r;
+ }
+
+ public R visitAttribute(AttributeTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitAuthor(AuthorTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitComment(CommentTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitDeprecated(DeprecatedTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitDocComment(DocCommentTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitDocRoot(DocRootTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitEndElement(EndElementTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitEntity(EntityTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitErroneous(ErroneousTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitIdentifier(IdentifierTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitInheritDoc(InheritDocTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitLink(LinkTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitLiteral(LiteralTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitParam(ParamTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitReference(ReferenceTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitReturn(ReturnTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitSee(SeeTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitSerial(SerialTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitSerialData(SerialDataTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitSerialField(SerialFieldTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitSince(SinceTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitStartElement(StartElementTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitText(TextTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitThrows(ThrowsTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitValue(ValueTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitVersion(VersionTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ public R visitOther(DocTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+}
diff --git a/langtools/src/share/classes/com/sun/source/util/Trees.java b/langtools/src/share/classes/com/sun/source/util/Trees.java
index a787061f495..7ee8b291b94 100644
--- a/langtools/src/share/classes/com/sun/source/util/Trees.java
+++ b/langtools/src/share/classes/com/sun/source/util/Trees.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, 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
@@ -26,6 +26,7 @@
package com.sun.source.util;
import java.lang.reflect.Method;
+
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
@@ -57,7 +58,9 @@ public abstract class Trees {
* @throws IllegalArgumentException if the task does not support the Trees API.
*/
public static Trees instance(CompilationTask task) {
- if (!task.getClass().getName().equals("com.sun.tools.javac.api.JavacTaskImpl"))
+ String taskClassName = task.getClass().getName();
+ if (!taskClassName.equals("com.sun.tools.javac.api.JavacTaskImpl")
+ && !taskClassName.equals("com.sun.tools.javac.api.BasicJavacTask"))
throw new IllegalArgumentException();
return getJavacTrees(CompilationTask.class, task);
}
@@ -73,7 +76,7 @@ public abstract class Trees {
return getJavacTrees(ProcessingEnvironment.class, env);
}
- private static Trees getJavacTrees(Class> argType, Object arg) {
+ static Trees getJavacTrees(Class> argType, Object arg) {
try {
ClassLoader cl = arg.getClass().getClassLoader();
Class> c = Class.forName("com.sun.tools.javac.api.JavacTrees", false, cl);
@@ -168,6 +171,7 @@ public abstract class Trees {
/**
* Gets the doc comment, if any, for the Tree node identified by a given TreePath.
* Returns null if no doc comment was found.
+ * @see DocTrees#getDocCommentTree(TreePath)
*/
public abstract String getDocComment(TreePath path);
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
index 6633b78dc82..314183dd1fa 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
@@ -45,7 +45,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
public abstract class AbstractExecutableMemberWriter extends AbstractMemberWriter {
public AbstractExecutableMemberWriter(SubWriterHolderWriter writer,
- ClassDoc classdoc) {
+ ClassDoc classdoc) {
super(writer, classdoc);
}
@@ -61,7 +61,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
* @return the display length required to write this information.
*/
protected int addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
- LinkInfoImpl linkInfo = new LinkInfoImpl(
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_MEMBER_TYPE_PARAMS, member, false);
String typeParameters = writer.getTypeParameterLinks(linkInfo);
if (linkInfo.displayLength > 0) {
@@ -129,8 +129,8 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
boolean isVarArg, Content tree) {
if (param.type() != null) {
Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
- LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, param.type(),
- isVarArg)));
+ configuration, LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM,
+ param.type(), isVarArg)));
tree.addContent(link);
}
if(param.name().length() > 0) {
@@ -161,7 +161,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
htmltree.addContent("(");
Parameter[] params = member.parameters();
String indent = makeSpace(writer.displayLength);
- if (configuration().linksource) {
+ if (configuration.linksource) {
//add spaces to offset indentation changes caused by link.
indent+= makeSpace(member.name().length());
}
@@ -212,7 +212,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
protected void addExceptions(ExecutableMemberDoc member, Content htmltree) {
Type[] exceptions = member.thrownExceptionTypes();
if(exceptions.length > 0) {
- LinkInfoImpl memberTypeParam = new LinkInfoImpl(
+ LinkInfoImpl memberTypeParam = new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_MEMBER, member, false);
int retlen = getReturnTypeLength(member);
writer.getTypeParameterLinks(memberTypeParam);
@@ -224,7 +224,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
htmltree.addContent(indent);
htmltree.addContent("throws ");
indent += " ";
- Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
+ Content link = new RawHtml(writer.getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_MEMBER, exceptions[0])));
htmltree.addContent(link);
for(int i = 1; i < exceptions.length; i++) {
@@ -232,7 +232,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
htmltree.addContent(DocletConstants.NL);
htmltree.addContent(indent);
Content exceptionLink = new RawHtml(writer.getLink(new LinkInfoImpl(
- LinkInfoImpl.CONTEXT_MEMBER, exceptions[i])));
+ configuration, LinkInfoImpl.CONTEXT_MEMBER, exceptions[i])));
htmltree.addContent(exceptionLink);
}
}
@@ -246,7 +246,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
return rettype.typeName().length() +
rettype.dimension().length();
} else {
- LinkInfoImpl linkInfo = new LinkInfoImpl(
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_MEMBER, rettype);
writer.getLink(linkInfo);
return linkInfo.displayLength;
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
index 3db480cfcdf..62dabe3ec17 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
@@ -140,7 +140,8 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
*/
protected void addDescription(ClassDoc cd, Content dlTree) {
Content link = new RawHtml(
- getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true)));
+ getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.CONTEXT_INDEX, cd, true)));
Content dt = HtmlTree.DT(link);
dt.addContent(" - ");
addClassInfo(cd, dt);
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
index df2e8af8d79..3ea59576fb6 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
@@ -49,15 +49,20 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
*/
public abstract class AbstractMemberWriter {
- protected boolean printedSummaryHeader = false;
+ protected final ConfigurationImpl configuration;
protected final SubWriterHolderWriter writer;
protected final ClassDoc classdoc;
+ protected Map typeMap = new LinkedHashMap();
+ protected Set methodTypes = EnumSet.noneOf(MethodTypes.class);
+ private int methodTypesOr = 0;
public final boolean nodepr;
- public AbstractMemberWriter(SubWriterHolderWriter writer,
- ClassDoc classdoc) {
+ protected boolean printedSummaryHeader = false;
+
+ public AbstractMemberWriter(SubWriterHolderWriter writer, ClassDoc classdoc) {
+ this.configuration = writer.configuration;
this.writer = writer;
- this.nodepr = configuration().nodeprecated;
+ this.nodepr = configuration.nodeprecated;
this.classdoc = classdoc;
}
@@ -281,11 +286,11 @@ public abstract class AbstractMemberWriter {
code.addContent(new HtmlTree(HtmlTag.BR));
}
code.addContent(new RawHtml(
- writer.getLink(new LinkInfoImpl(
+ writer.getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
} else {
code.addContent(new RawHtml(
- writer.getLink(new LinkInfoImpl(
+ writer.getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
}
@@ -305,7 +310,7 @@ public abstract class AbstractMemberWriter {
} else if (member.isPrivate()) {
code.addContent("private ");
} else if (!member.isPublic()) { // Package private
- code.addContent(configuration().getText("doclet.Package_private"));
+ code.addContent(configuration.getText("doclet.Package_private"));
code.addContent(" ");
}
if (member.isMethod() && ((MethodDoc)member).isAbstract()) {
@@ -389,7 +394,7 @@ public abstract class AbstractMemberWriter {
String tableSummary, String[] tableHeader, Content contentTree) {
if (deprmembers.size() > 0) {
Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
- writer.getTableCaption(configuration().getText(headingKey)));
+ writer.getTableCaption(configuration.getText(headingKey)));
table.addContent(writer.getSummaryTableHeader(tableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
for (int i = 0; i < deprmembers.size(); i++) {
@@ -507,8 +512,8 @@ public abstract class AbstractMemberWriter {
}
protected void serialWarning(SourcePosition pos, String key, String a1, String a2) {
- if (configuration().serialwarn) {
- ConfigurationImpl.getInstance().getDocletSpecificMsg().warning(pos, key, a1, a2);
+ if (configuration.serialwarn) {
+ configuration.getDocletSpecificMsg().warning(pos, key, a1, a2);
}
}
@@ -516,21 +521,17 @@ public abstract class AbstractMemberWriter {
return nodepr? Util.excludeDeprecatedMembers(members): members;
}
- public ConfigurationImpl configuration() {
- return writer.configuration;
- }
-
/**
* Add the member summary for the given class.
*
* @param classDoc the class that is being documented
* @param member the member being documented
* @param firstSentenceTags the first sentence tags to be added to the summary
- * @param tableTree the content tree to which the documentation will be added
- * @param counter the counter for determing style for the table row
+ * @param tableContents the list of contents to which the documentation will be added
+ * @param counter the counter for determining id and style for the table row
*/
public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
- Tag[] firstSentenceTags, Content tableTree, int counter) {
+ Tag[] firstSentenceTags, List tableContents, int counter) {
HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD);
tdSummaryType.addStyle(HtmlStyle.colFirst);
writer.addSummaryType(this, member, tdSummaryType);
@@ -540,11 +541,46 @@ public abstract class AbstractMemberWriter {
writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary);
HtmlTree tr = HtmlTree.TR(tdSummaryType);
tr.addContent(tdSummary);
+ if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) {
+ int methodType = (member.isStatic()) ? MethodTypes.STATIC.value() :
+ MethodTypes.INSTANCE.value();
+ methodType = (classdoc.isInterface() || ((MethodDoc)member).isAbstract()) ?
+ methodType | MethodTypes.ABSTRACT.value() :
+ methodType | MethodTypes.CONCRETE.value();
+ if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) {
+ methodType = methodType | MethodTypes.DEPRECATED.value();
+ }
+ methodTypesOr = methodTypesOr | methodType;
+ String tableId = "i" + counter;
+ typeMap.put(tableId, methodType);
+ tr.addAttr(HtmlAttr.ID, tableId);
+ }
if (counter%2 == 0)
tr.addStyle(HtmlStyle.altColor);
else
tr.addStyle(HtmlStyle.rowColor);
- tableTree.addContent(tr);
+ tableContents.add(tr);
+ }
+
+ /**
+ * Generate the method types set and return true if the method summary table
+ * needs to show tabs.
+ *
+ * @return true if the table should show tabs
+ */
+ public boolean showTabs() {
+ int value;
+ for (MethodTypes type : EnumSet.allOf(MethodTypes.class)) {
+ value = type.value();
+ if ((value & methodTypesOr) == value) {
+ methodTypes.add(type);
+ }
+ }
+ boolean showTabs = methodTypes.size() > 1;
+ if (showTabs) {
+ methodTypes.add(MethodTypes.ALL);
+ }
+ return showTabs;
}
/**
@@ -597,10 +633,11 @@ public abstract class AbstractMemberWriter {
* Get the summary table tree for the given class.
*
* @param classDoc the class for which the summary table is generated
+ * @param tableContents list of contents to be displayed in the summary table
* @return a content tree for the summary table
*/
- public Content getSummaryTableTree(ClassDoc classDoc) {
- return writer.getSummaryTableTree(this, classDoc);
+ public Content getSummaryTableTree(ClassDoc classDoc, List tableContents) {
+ return writer.getSummaryTableTree(this, classDoc, tableContents, showTabs());
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
index 63786f474f0..53af067c6c9 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
@@ -138,7 +138,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
for (int i = 0; i < interfaces.length; i++) {
if (parent != interfaces[i]) {
if (! (interfaces[i].isPublic() ||
- Util.isLinkable(interfaces[i], configuration()))) {
+ Util.isLinkable(interfaces[i], configuration))) {
continue;
}
if (counter == 0) {
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
index af0f4a24f81..85b8ce9791c 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
@@ -159,10 +159,11 @@ public class AllClassesFrameWriter extends HtmlDocletWriter {
String label = italicsClassName(cd, false);
Content linkContent;
if(wantFrames){
- linkContent = new RawHtml(getLink(new LinkInfoImpl(
+ linkContent = new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.ALL_CLASSES_FRAME, cd, label, "classFrame")));
} else {
- linkContent = new RawHtml(getLink(new LinkInfoImpl(cd, label)));
+ linkContent = new RawHtml(getLink(new LinkInfoImpl(
+ configuration, cd, label)));
}
Content li = HtmlTree.LI(linkContent);
content.addContent(li);
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
index 03e04e79946..cf8fba180a7 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
@@ -103,16 +103,16 @@ public class AnnotationTypeOptionalMemberWriterImpl extends
* {@inheritDoc}
*/
public String getTableSummary() {
- return configuration().getText("doclet.Member_Table_Summary",
- configuration().getText("doclet.Annotation_Type_Optional_Member_Summary"),
- configuration().getText("doclet.annotation_type_optional_members"));
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Annotation_Type_Optional_Member_Summary"),
+ configuration.getText("doclet.annotation_type_optional_members"));
}
/**
* {@inheritDoc}
*/
public String getCaption() {
- return configuration().getText("doclet.Annotation_Type_Optional_Members");
+ return configuration.getText("doclet.Annotation_Type_Optional_Members");
}
/**
@@ -121,9 +121,9 @@ public class AnnotationTypeOptionalMemberWriterImpl extends
public String[] getSummaryTableHeader(ProgramElementDoc member) {
String[] header = new String[] {
writer.getModifierTypeHeader(),
- configuration().getText("doclet.0_and_1",
- configuration().getText("doclet.Annotation_Type_Optional_Member"),
- configuration().getText("doclet.Description"))
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Annotation_Type_Optional_Member"),
+ configuration.getText("doclet.Description"))
};
return header;
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
index 2fe1f662c1e..daee94e5bf9 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
@@ -52,7 +52,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
* @param annotationType the AnnotationType that holds this member.
*/
public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer,
- AnnotationTypeDoc annotationType) {
+ AnnotationTypeDoc annotationType) {
super(writer, annotationType);
}
@@ -106,11 +106,11 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
writer.addAnnotationInfo(member, pre);
addModifiers(member, pre);
Content link = new RawHtml(
- writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
- getType(member))));
+ writer.getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.CONTEXT_MEMBER, getType(member))));
pre.addContent(link);
pre.addContent(writer.getSpace());
- if (configuration().linksource) {
+ if (configuration.linksource) {
Content memberName = new StringContent(member.name());
writer.addSrcLink(member, memberName, pre);
} else {
@@ -175,16 +175,16 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
* {@inheritDoc}
*/
public String getTableSummary() {
- return configuration().getText("doclet.Member_Table_Summary",
- configuration().getText("doclet.Annotation_Type_Required_Member_Summary"),
- configuration().getText("doclet.annotation_type_required_members"));
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Annotation_Type_Required_Member_Summary"),
+ configuration.getText("doclet.annotation_type_required_members"));
}
/**
* {@inheritDoc}
*/
public String getCaption() {
- return configuration().getText("doclet.Annotation_Type_Required_Members");
+ return configuration.getText("doclet.Annotation_Type_Required_Members");
}
/**
@@ -193,9 +193,9 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
public String[] getSummaryTableHeader(ProgramElementDoc member) {
String[] header = new String[] {
writer.getModifierTypeHeader(),
- configuration().getText("doclet.0_and_1",
- configuration().getText("doclet.Annotation_Type_Required_Member"),
- configuration().getText("doclet.Description"))
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Annotation_Type_Required_Member"),
+ configuration.getText("doclet.Description"))
};
return header;
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
index 636522e0cc3..a86312e7660 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
@@ -65,10 +65,10 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
* @param prevType the previous class that was documented.
* @param nextType the next class being documented.
*/
- public AnnotationTypeWriterImpl(AnnotationTypeDoc annotationType,
- Type prevType, Type nextType)
+ public AnnotationTypeWriterImpl(ConfigurationImpl configuration,
+ AnnotationTypeDoc annotationType, Type prevType, Type nextType)
throws Exception {
- super(ConfigurationImpl.getInstance(), DocPath.forClass(annotationType));
+ super(configuration, DocPath.forClass(annotationType));
this.annotationType = annotationType;
configuration.currentcd = annotationType.asClassDoc();
this.prev = prevType;
@@ -116,7 +116,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
public Content getNavLinkPrevious() {
Content li;
if (prev != null) {
- Content prevLink = new RawHtml(getLink(new LinkInfoImpl(
+ Content prevLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CLASS, prev.asClassDoc(), "",
configuration.getText("doclet.Prev_Class"), true)));
li = HtmlTree.LI(prevLink);
@@ -134,7 +134,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
public Content getNavLinkNext() {
Content li;
if (next != null) {
- Content nextLink = new RawHtml(getLink(new LinkInfoImpl(
+ Content nextLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CLASS, next.asClassDoc(), "",
configuration.getText("doclet.Next_Class"), true)));
li = HtmlTree.LI(nextLink);
@@ -162,7 +162,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
div.addContent(pkgNameDiv);
}
- LinkInfoImpl linkInfo = new LinkInfoImpl(
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CLASS_HEADER, annotationType, false);
Content headerContent = new StringContent(header);
Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
@@ -219,11 +219,11 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
Content pre = new HtmlTree(HtmlTag.PRE);
addAnnotationInfo(annotationType, pre);
pre.addContent(modifiers);
- LinkInfoImpl linkInfo = new LinkInfoImpl(
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false);
Content annotationName = new StringContent(annotationType.name());
Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo));
- if (configuration().linksource) {
+ if (configuration.linksource) {
addSrcLink(annotationType, annotationName, pre);
pre.addContent(parameterLinks);
} else {
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
index 5f8001b6fb4..8e2e14fceb4 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
@@ -256,9 +256,9 @@ public class ClassUseWriter extends SubWriterHolderWriter {
*/
protected void addPackageList(Content contentTree) throws IOException {
Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
- getTableCaption(configuration().getText(
+ getTableCaption(configuration.getText(
"doclet.ClassUse_Packages.that.use.0",
- getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
+ getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
false)))));
table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
@@ -287,14 +287,14 @@ public class ClassUseWriter extends SubWriterHolderWriter {
protected void addPackageAnnotationList(Content contentTree) throws IOException {
if ((!classdoc.isAnnotationType()) ||
pkgToPackageAnnotations == null ||
- pkgToPackageAnnotations.size() == 0) {
+ pkgToPackageAnnotations.isEmpty()) {
return;
}
Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
- getTableCaption(configuration().getText(
+ getTableCaption(configuration.getText(
"doclet.ClassUse_PackageAnnotation",
- getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
- false)))));
+ getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false)))));
table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
Iterator it = pkgToPackageAnnotations.iterator();
@@ -333,7 +333,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(pkg.name()));
Content link = new RawHtml(
configuration.getText("doclet.ClassUse_Uses.of.0.in.1",
- getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER,
+ getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER,
classdoc, false)),
getPackageLinkString(pkg, Util.getPackageName(pkg), false)));
Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
@@ -368,7 +368,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
* @param contentTree the content tree to which the class use information will be added
*/
protected void addClassUse(PackageDoc pkg, Content contentTree) throws IOException {
- String classLink = getLink(new LinkInfoImpl(
+ String classLink = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false));
String pkgLink = getPackageLinkString(pkg, Util.getPackageName(pkg), false);
classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg.name()),
@@ -477,8 +477,8 @@ public class ClassUseWriter extends SubWriterHolderWriter {
*/
protected Content getNavLinkClass() {
Content linkContent = new RawHtml(getLink(new LinkInfoImpl(
- LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, "",
- configuration.getText("doclet.Class"), false)));
+ configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
+ "", configuration.getText("doclet.Class"), false)));
Content li = HtmlTree.LI(linkContent);
return li;
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
index 78d8ca88b2c..06ac230dc27 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
@@ -34,6 +34,7 @@ import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.builders.*;
import com.sun.tools.doclets.internal.toolkit.taglets.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
+import java.io.IOException;
/**
* Generate the Class Information Page.
@@ -56,24 +57,25 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
public class ClassWriterImpl extends SubWriterHolderWriter
implements ClassWriter {
- protected ClassDoc classDoc;
+ protected final ClassDoc classDoc;
- protected ClassTree classtree;
+ protected final ClassTree classtree;
- protected ClassDoc prev;
+ protected final ClassDoc prev;
- protected ClassDoc next;
+ protected final ClassDoc next;
/**
+ * @param configuration the configuration data for the doclet
* @param classDoc the class being documented.
* @param prevClass the previous class that was documented.
* @param nextClass the next class being documented.
* @param classTree the class tree for the given class.
*/
- public ClassWriterImpl (ClassDoc classDoc,
+ public ClassWriterImpl (ConfigurationImpl configuration, ClassDoc classDoc,
ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
- throws Exception {
- super(ConfigurationImpl.getInstance(), DocPath.forClass(classDoc));
+ throws IOException {
+ super(configuration, DocPath.forClass(classDoc));
this.classDoc = classDoc;
configuration.currentcd = classDoc;
this.classtree = classTree;
@@ -122,7 +124,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
public Content getNavLinkPrevious() {
Content li;
if (prev != null) {
- Content prevLink = new RawHtml(getLink(new LinkInfoImpl(
+ Content prevLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CLASS, prev, "",
configuration.getText("doclet.Prev_Class"), true)));
li = HtmlTree.LI(prevLink);
@@ -140,7 +142,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
public Content getNavLinkNext() {
Content li;
if (next != null) {
- Content nextLink = new RawHtml(getLink(new LinkInfoImpl(
+ Content nextLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CLASS, next, "",
configuration.getText("doclet.Next_Class"), true)));
li = HtmlTree.LI(nextLink);
@@ -168,8 +170,8 @@ public class ClassWriterImpl extends SubWriterHolderWriter
Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
div.addContent(pkgNameDiv);
}
- LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_HEADER,
- classDoc, false);
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+ LinkInfoImpl.CONTEXT_CLASS_HEADER, classDoc, false);
//Let's not link to ourselves in the header.
linkInfo.linkToSelf = false;
Content headerContent = new StringContent(header);
@@ -228,13 +230,13 @@ public class ClassWriterImpl extends SubWriterHolderWriter
Content pre = new HtmlTree(HtmlTag.PRE);
addAnnotationInfo(classDoc, pre);
pre.addContent(modifiers);
- LinkInfoImpl linkInfo = new LinkInfoImpl(
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false);
//Let's not link to ourselves in the signature.
linkInfo.linkToSelf = false;
Content className = new StringContent(classDoc.name());
Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo));
- if (configuration().linksource) {
+ if (configuration.linksource) {
addSrcLink(classDoc, className, pre);
pre.addContent(parameterLinks);
} else {
@@ -244,11 +246,11 @@ public class ClassWriterImpl extends SubWriterHolderWriter
}
if (!isInterface) {
Type superclass = Util.getFirstVisibleSuperClass(classDoc,
- configuration());
+ configuration);
if (superclass != null) {
pre.addContent(DocletConstants.NL);
pre.addContent("extends ");
- Content link = new RawHtml(getLink(new LinkInfoImpl(
+ Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
superclass)));
pre.addContent(link);
@@ -260,7 +262,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
for (int i = 0; i < implIntfacs.length; i++) {
ClassDoc classDoc = implIntfacs[i].asClassDoc();
if (! (classDoc.isPublic() ||
- Util.isLinkable(classDoc, configuration()))) {
+ Util.isLinkable(classDoc, configuration))) {
continue;
}
if (counter == 0) {
@@ -269,7 +271,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
} else {
pre.addContent(", ");
}
- Content link = new RawHtml(getLink(new LinkInfoImpl(
+ Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
implIntfacs[i])));
pre.addContent(link);
@@ -315,7 +317,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
do {
sup = Util.getFirstVisibleSuperClass(
type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(),
- configuration());
+ configuration);
if (sup != null) {
HtmlTree ul = new HtmlTree(HtmlTag.UL);
ul.addStyle(HtmlStyle.inheritance);
@@ -345,7 +347,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
Content li = new HtmlTree(HtmlTag.LI);
if (type.equals(classDoc)) {
String typeParameters = getTypeParameterLinks(
- new LinkInfoImpl(LinkInfoImpl.CONTEXT_TREE,
+ new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_TREE,
classDoc, false));
if (configuration.shouldExcludeQualifier(
classDoc.containingPackage().name())) {
@@ -356,7 +358,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
li.addContent(new RawHtml(typeParameters));
}
} else {
- Content link = new RawHtml(getLink(new LinkInfoImpl(
+ Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT,
type instanceof ClassDoc ? (ClassDoc) type : type,
configuration.getClassName(type.asClassDoc()), false)));
@@ -504,8 +506,8 @@ public class ClassWriterImpl extends SubWriterHolderWriter
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
Content dd = new HtmlTree(HtmlTag.DD);
- dd.addContent(new RawHtml(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
- false))));
+ dd.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.CONTEXT_CLASS, outerClass, false))));
dl.addContent(dd);
classInfoTree.addContent(dl);
}
@@ -549,11 +551,11 @@ public class ClassWriterImpl extends SubWriterHolderWriter
}
if (typeList[i] instanceof ClassDoc) {
Content link = new RawHtml(getLink(
- new LinkInfoImpl(context, (ClassDoc)(typeList[i]))));
+ new LinkInfoImpl(configuration, context, (ClassDoc)(typeList[i]))));
dd.addContent(link);
} else {
Content link = new RawHtml(getLink(
- new LinkInfoImpl(context, (Type)(typeList[i]))));
+ new LinkInfoImpl(configuration, context, (Type)(typeList[i]))));
dd.addContent(link);
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
index fb6966b890a..a6244a0335f 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
@@ -28,9 +28,13 @@ package com.sun.tools.doclets.formats.html;
import java.net.*;
import java.util.*;
+import javax.tools.JavaFileManager;
+
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.Context;
/**
* Configure the output based on the command line options.
@@ -57,8 +61,6 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
*/
public class ConfigurationImpl extends Configuration {
- private static ConfigurationImpl instance = new ConfigurationImpl();
-
/**
* The build date. Note: For now, we will use
* a version number instead of a date.
@@ -183,34 +185,21 @@ public class ConfigurationImpl extends Configuration {
/**
* The classdoc for the class file getting generated.
*/
- public ClassDoc currentcd = null; // Set this classdoc in the
- // ClassWriter.
+ public ClassDoc currentcd = null; // Set this classdoc in the ClassWriter.
/**
* Constructor. Initializes resource for the
* {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}.
*/
- private ConfigurationImpl() {
+ public ConfigurationImpl() {
standardmessage = new MessageRetriever(this,
"com.sun.tools.doclets.formats.html.resources.standard");
}
- /**
- * Reset to a fresh new ConfigurationImpl, to allow multiple invocations
- * of javadoc within a single VM. It would be better not to be using
- * static fields at all, but .... (sigh).
- */
- public static void reset() {
- instance = new ConfigurationImpl();
- }
-
- public static ConfigurationImpl getInstance() {
- return instance;
- }
-
/**
* Return the build date for the doclet.
*/
+ @Override
public String getDocletSpecificBuildDate() {
return BUILD_DATE;
}
@@ -221,6 +210,7 @@ public class ConfigurationImpl extends Configuration {
*
* @param options The array of option names and values.
*/
+ @Override
public void setSpecificDocletOptions(String[][] options) {
for (int oi = 0; oi < options.length; ++oi) {
String[] os = options[oi];
@@ -339,6 +329,7 @@ public class ConfigurationImpl extends Configuration {
/**
* {@inheritDoc}
*/
+ @Override
public boolean validOptions(String options[][],
DocErrorReporter reporter) {
boolean helpfile = false;
@@ -427,6 +418,7 @@ public class ConfigurationImpl extends Configuration {
/**
* {@inheritDoc}
*/
+ @Override
public MessageRetriever getDocletSpecificMsg() {
return standardmessage;
}
@@ -496,6 +488,7 @@ public class ConfigurationImpl extends Configuration {
/**
* {@inheritDoc}
*/
+ @Override
public WriterFactory getWriterFactory() {
return new WriterFactoryImpl(this);
}
@@ -503,6 +496,7 @@ public class ConfigurationImpl extends Configuration {
/**
* {@inheritDoc}
*/
+ @Override
public Comparator getMemberComparator() {
return null;
}
@@ -510,10 +504,27 @@ public class ConfigurationImpl extends Configuration {
/**
* {@inheritDoc}
*/
+ @Override
public Locale getLocale() {
if (root instanceof com.sun.tools.javadoc.RootDocImpl)
return ((com.sun.tools.javadoc.RootDocImpl)root).getLocale();
else
return Locale.getDefault();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public JavaFileManager getFileManager() {
+ if (fileManager == null) {
+ if (root instanceof com.sun.tools.javadoc.RootDocImpl)
+ fileManager = ((com.sun.tools.javadoc.RootDocImpl)root).getFileManager();
+ else
+ fileManager = new JavacFileManager(new Context(), false, null);
+ }
+ return fileManager;
+ }
+
+ private JavaFileManager fileManager;
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
index ec98f180410..afc0aeb2d6f 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
@@ -184,9 +184,9 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
*/
public Content getConstantMembersHeader(ClassDoc cd) {
//generate links backward only to public classes.
- String classlink = (cd.isPublic() || cd.isProtected())?
- getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd,
- false)) :
+ String classlink = (cd.isPublic() || cd.isProtected()) ?
+ getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd, false)) :
cd.qualifiedName();
String name = cd.containingPackage().name();
if (name.length() > 0) {
@@ -260,7 +260,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
code.addContent(modifier);
code.addContent(getSpace());
}
- Content type = new RawHtml(getLink(new LinkInfoImpl(
+ Content type = new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member.type())));
code.addContent(type);
tdType.addContent(code);
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
index 6e2a5ec5284..0725f1677ca 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
@@ -60,7 +60,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
ClassDoc classDoc) {
super(writer, classDoc);
VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc,
- VisibleMemberMap.CONSTRUCTORS, configuration().nodeprecated);
+ VisibleMemberMap.CONSTRUCTORS, configuration.nodeprecated);
List constructors = new ArrayList(visibleMemberMap.getMembersFor(classDoc));
for (int i = 0; i < constructors.size(); i++) {
if ((constructors.get(i)).isProtected() ||
@@ -130,7 +130,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(constructor, pre);
addModifiers(constructor, pre);
- if (configuration().linksource) {
+ if (configuration.linksource) {
Content constructorName = new StringContent(constructor.name());
writer.addSrcLink(constructor, constructorName, pre);
} else {
@@ -217,16 +217,16 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
* {@inheritDoc}
*/
public String getTableSummary() {
- return configuration().getText("doclet.Member_Table_Summary",
- configuration().getText("doclet.Constructor_Summary"),
- configuration().getText("doclet.constructors"));
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Constructor_Summary"),
+ configuration.getText("doclet.constructors"));
}
/**
* {@inheritDoc}
*/
public String getCaption() {
- return configuration().getText("doclet.Constructors");
+ return configuration.getText("doclet.Constructors");
}
/**
@@ -236,17 +236,17 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
String[] header;
if (foundNonPubConstructor) {
header = new String[] {
- configuration().getText("doclet.Modifier"),
- configuration().getText("doclet.0_and_1",
- configuration().getText("doclet.Constructor"),
- configuration().getText("doclet.Description"))
+ configuration.getText("doclet.Modifier"),
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Constructor"),
+ configuration.getText("doclet.Description"))
};
}
else {
header = new String[] {
- configuration().getText("doclet.0_and_1",
- configuration().getText("doclet.Constructor"),
- configuration().getText("doclet.Description"))
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Constructor"),
+ configuration.getText("doclet.Description"))
};
}
return header;
@@ -313,7 +313,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
code.addContent(writer.getSpace());
} else {
code.addContent(
- configuration().getText("doclet.Package_private"));
+ configuration.getText("doclet.Package_private"));
}
tdSummaryType.addContent(code);
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
index b06255ad9a6..a37d8be9e5c 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
@@ -101,11 +101,11 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(enumConstant, pre);
addModifiers(enumConstant, pre);
- Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
- enumConstant.type())));
+ Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(
+ configuration, LinkInfoImpl.CONTEXT_MEMBER, enumConstant.type())));
pre.addContent(enumConstantLink);
pre.addContent(" ");
- if (configuration().linksource) {
+ if (configuration.linksource) {
Content enumConstantName = new StringContent(enumConstant.name());
writer.addSrcLink(enumConstant, enumConstantName, pre);
} else {
@@ -174,16 +174,16 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
* {@inheritDoc}
*/
public String getTableSummary() {
- return configuration().getText("doclet.Member_Table_Summary",
- configuration().getText("doclet.Enum_Constant_Summary"),
- configuration().getText("doclet.enum_constants"));
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Enum_Constant_Summary"),
+ configuration.getText("doclet.enum_constants"));
}
/**
* {@inheritDoc}
*/
public String getCaption() {
- return configuration().getText("doclet.Enum_Constants");
+ return configuration.getText("doclet.Enum_Constants");
}
/**
@@ -191,9 +191,9 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
*/
public String[] getSummaryTableHeader(ProgramElementDoc member) {
String[] header = new String[] {
- configuration().getText("doclet.0_and_1",
- configuration().getText("doclet.Enum_Constant"),
- configuration().getText("doclet.Description"))
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Enum_Constant"),
+ configuration.getText("doclet.Description"))
};
return header;
}
@@ -266,7 +266,7 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
return writer.getHyperLink((cd == null)?
"enum_constant_summary":
"enum_constants_inherited_from_class_" +
- configuration().getClassName(cd),
+ configuration.getClassName(cd),
writer.getResource("doclet.navEnum"));
} else {
return writer.getResource("doclet.navEnum");
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
index 10f076a08af..dc5515882bc 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
@@ -102,11 +102,11 @@ public class FieldWriterImpl extends AbstractMemberWriter
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(field, pre);
addModifiers(field, pre);
- Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
- field.type())));
+ Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(
+ configuration, LinkInfoImpl.CONTEXT_MEMBER, field.type())));
pre.addContent(fieldlink);
pre.addContent(" ");
- if (configuration().linksource) {
+ if (configuration.linksource) {
Content fieldName = new StringContent(field.name());
writer.addSrcLink(field, fieldName, pre);
} else {
@@ -129,7 +129,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
ClassDoc holder = field.containingClass();
if (field.inlineTags().length > 0) {
if (holder.equals(classdoc) ||
- (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
+ (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
writer.addInlineComment(field, fieldDocTree);
} else {
Content link = new RawHtml(
@@ -195,16 +195,16 @@ public class FieldWriterImpl extends AbstractMemberWriter
* {@inheritDoc}
*/
public String getTableSummary() {
- return configuration().getText("doclet.Member_Table_Summary",
- configuration().getText("doclet.Field_Summary"),
- configuration().getText("doclet.fields"));
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Field_Summary"),
+ configuration.getText("doclet.fields"));
}
/**
* {@inheritDoc}
*/
public String getCaption() {
- return configuration().getText("doclet.Fields");
+ return configuration.getText("doclet.Fields");
}
/**
@@ -213,9 +213,9 @@ public class FieldWriterImpl extends AbstractMemberWriter
public String[] getSummaryTableHeader(ProgramElementDoc member) {
String[] header = new String[] {
writer.getModifierTypeHeader(),
- configuration().getText("doclet.0_and_1",
- configuration().getText("doclet.Field"),
- configuration().getText("doclet.Description"))
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Field"),
+ configuration.getText("doclet.Description"))
};
return header;
}
@@ -232,7 +232,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
*/
public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
inheritedTree.addContent(writer.getMarkerAnchor(
- "fields_inherited_from_class_" + configuration().getClassName(cd)));
+ "fields_inherited_from_class_" + configuration.getClassName(cd)));
}
/**
@@ -242,8 +242,8 @@ public class FieldWriterImpl extends AbstractMemberWriter
Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
LinkInfoImpl.CONTEXT_MEMBER, cd, false));
Content label = new StringContent(cd.isClass() ?
- configuration().getText("doclet.Fields_Inherited_From_Class") :
- configuration().getText("doclet.Fields_Inherited_From_Interface"));
+ configuration.getText("doclet.Fields_Inherited_From_Class") :
+ configuration.getText("doclet.Fields_Inherited_From_Interface"));
Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
label);
labelHeading.addContent(writer.getSpace());
@@ -296,7 +296,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
return writer.getHyperLink((cd == null)?
"field_summary":
"fields_inherited_from_class_" +
- configuration().getClassName(cd),
+ configuration.getClassName(cd),
writer.getResource("doclet.navField"));
} else {
return writer.getResource("doclet.navField");
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
index 6a9f691cedd..45453823fe3 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
@@ -46,14 +46,17 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
*
*/
public class HtmlDoclet extends AbstractDoclet {
+ // An instance will be created by validOptions, and used by start.
+ private static HtmlDoclet docletToStart = null;
+
public HtmlDoclet() {
- configuration = (ConfigurationImpl) configuration();
+ configuration = new ConfigurationImpl();
}
/**
* The global configuration information for this run.
*/
- public ConfigurationImpl configuration;
+ public final ConfigurationImpl configuration;
/**
* The "start" method as required by Javadoc.
@@ -63,12 +66,16 @@ public class HtmlDoclet extends AbstractDoclet {
* @return true if the doclet ran without encountering any errors.
*/
public static boolean start(RootDoc root) {
- try {
- HtmlDoclet doclet = new HtmlDoclet();
- return doclet.start(doclet, root);
- } finally {
- ConfigurationImpl.reset();
+ // In typical use, options will have been set up by calling validOptions,
+ // which will create an HtmlDoclet for use here.
+ HtmlDoclet doclet;
+ if (docletToStart != null) {
+ doclet = docletToStart;
+ docletToStart = null;
+ } else {
+ doclet = new HtmlDoclet();
}
+ return doclet.start(doclet, root);
}
/**
@@ -77,7 +84,7 @@ public class HtmlDoclet extends AbstractDoclet {
* configuration.
*/
public Configuration configuration() {
- return ConfigurationImpl.getInstance();
+ return configuration;
}
/**
@@ -110,6 +117,8 @@ public class HtmlDoclet extends AbstractDoclet {
copyResourceFile("tab.gif");
copyResourceFile("titlebar.gif");
copyResourceFile("titlebar_end.gif");
+ copyResourceFile("activetitlebar.gif");
+ copyResourceFile("activetitlebar_end.gif");
// do early to reduce memory footprint
if (configuration.classuse) {
ClassUseWriter.generate(configuration, classtree);
@@ -145,10 +154,13 @@ public class HtmlDoclet extends AbstractDoclet {
}
// If a stylesheet file is not specified, copy the default stylesheet
// and replace newline with platform-specific newline.
+ DocFile f;
if (configuration.stylesheetfile.length() == 0) {
- DocFile f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET);
+ f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET);
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), false, true);
}
+ f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT);
+ f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true);
}
/**
@@ -220,6 +232,9 @@ public class HtmlDoclet extends AbstractDoclet {
}
}
+ public static final ConfigurationImpl sharedInstanceForOptions =
+ new ConfigurationImpl();
+
/**
* Check for doclet added options here.
*
@@ -228,7 +243,7 @@ public class HtmlDoclet extends AbstractDoclet {
*/
public static int optionLength(String option) {
// Construct temporary configuration for check
- return (ConfigurationImpl.getInstance()).optionLength(option);
+ return sharedInstanceForOptions.optionLength(option);
}
/**
@@ -244,8 +259,8 @@ public class HtmlDoclet extends AbstractDoclet {
*/
public static boolean validOptions(String options[][],
DocErrorReporter reporter) {
- // Construct temporary configuration for check
- return (ConfigurationImpl.getInstance()).validOptions(options, reporter);
+ docletToStart = new HtmlDoclet();
+ return docletToStart.configuration.validOptions(options, reporter);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
index 0531db15abd..57609a10b48 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
@@ -82,7 +82,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
/**
* The global configuration information for this run.
*/
- public ConfigurationImpl configuration;
+ public final ConfigurationImpl configuration;
/**
* To check whether annotation heading is printed or not.
@@ -302,7 +302,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
*/
public void printHtmlDocument(String[] metakeywords, boolean includeScript,
Content body) throws IOException {
- Content htmlDocType = DocType.Transitional();
+ Content htmlDocType = DocType.TRANSITIONAL;
Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
Content head = new HtmlTree(HtmlTag.HEAD);
if (!configuration.notimestamp) {
@@ -327,6 +327,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
}
}
head.addContent(getStyleSheetProperties());
+ head.addContent(getScriptProperties());
Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
head, body);
Content htmlDocument = new HtmlDocument(htmlDocType,
@@ -835,7 +836,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
String tableSummary, String[] tableHeader, Content contentTree) {
if (deprPkgs.size() > 0) {
Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
- getTableCaption(configuration().getText(headingKey)));
+ getTableCaption(configuration.getText(headingKey)));
table.addContent(getSummaryTableHeader(tableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
for (int i = 0; i < deprPkgs.size(); i++) {
@@ -1079,7 +1080,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
* @return a content tree for the link
*/
public Content getQualifiedClassLink(int context, ClassDoc cd) {
- return new RawHtml(getLink(new LinkInfoImpl(context, cd,
+ return new RawHtml(getLink(new LinkInfoImpl(configuration, context, cd,
configuration.getClassName(cd), "")));
}
@@ -1110,7 +1111,8 @@ public class HtmlDocletWriter extends HtmlDocWriter {
if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
classlink = getPkgName(cd);
}
- classlink += getLink(new LinkInfoImpl(context, cd, cd.name(), isStrong));
+ classlink += getLink(new LinkInfoImpl(configuration,
+ context, cd, cd.name(), isStrong));
return classlink;
}
@@ -1130,7 +1132,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
contentTree.addContent(getPkgName(cd));
}
- contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(
+ contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration,
context, cd, cd.name(), isStrong))));
}
@@ -1187,14 +1189,14 @@ public class HtmlDocletWriter extends HtmlDocWriter {
public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
String label, boolean strong) {
if (! (doc.isIncluded() ||
- Util.isLinkable(classDoc, configuration()))) {
+ Util.isLinkable(classDoc, configuration))) {
return label;
} else if (doc instanceof ExecutableMemberDoc) {
ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
- return getLink(new LinkInfoImpl(context, classDoc,
+ return getLink(new LinkInfoImpl(configuration, context, classDoc,
getAnchor(emd), label, strong));
} else if (doc instanceof MemberDoc) {
- return getLink(new LinkInfoImpl(context, classDoc,
+ return getLink(new LinkInfoImpl(configuration, context, classDoc,
doc.name(), label, strong));
} else {
return label;
@@ -1215,14 +1217,14 @@ public class HtmlDocletWriter extends HtmlDocWriter {
public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
String label) {
if (! (doc.isIncluded() ||
- Util.isLinkable(classDoc, configuration()))) {
+ Util.isLinkable(classDoc, configuration))) {
return new StringContent(label);
} else if (doc instanceof ExecutableMemberDoc) {
ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
- return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
+ return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc,
getAnchor(emd), label, false)));
} else if (doc instanceof MemberDoc) {
- return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
+ return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc,
doc.name(), label, false)));
} else {
return new StringContent(label);
@@ -1302,7 +1304,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
if (label.isEmpty()) {
label = plainOrCodeText(plain, refClass.name());
}
- return getLink(new LinkInfoImpl(refClass, label));
+ return getLink(new LinkInfoImpl(configuration, refClass, label));
} else if (refMem == null) {
// Must be a member reference since refClass is not null and refMemName is not null.
// However, refMem is null, so this referenced member does not exist.
@@ -1313,7 +1315,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
ClassDoc containing = refMem.containingClass();
if (see.text().trim().startsWith("#") &&
! (containing.isPublic() ||
- Util.isLinkable(containing, configuration()))) {
+ Util.isLinkable(containing, configuration))) {
// Since the link is relative and the holder is not even being
// documented, this must be an inherited link. Redirect it.
// The current class either overrides the referenced member or
@@ -1502,7 +1504,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
StringBuilder textBuff = new StringBuilder();
while (lines.hasMoreTokens()) {
StringBuilder line = new StringBuilder(lines.nextToken());
- Util.replaceTabs(configuration.sourcetab, line);
+ Util.replaceTabs(configuration, line);
textBuff.append(line.toString());
}
result.append(textBuff);
@@ -1686,6 +1688,17 @@ public class HtmlDocletWriter extends HtmlDocWriter {
return link;
}
+ /**
+ * Returns a link to the JavaScript file.
+ *
+ * @return an HtmlTree for the Script tag which provides the JavaScript location
+ */
+ public HtmlTree getScriptProperties() {
+ HtmlTree script = HtmlTree.SCRIPT("text/javascript",
+ pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath());
+ return script;
+ }
+
/**
* According to
* The Java™ Language Specification,
@@ -1784,7 +1797,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
continue;
}
annotation = new StringBuilder();
- LinkInfoImpl linkInfo = new LinkInfoImpl(
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc);
linkInfo.label = "@" + annotationDoc.name();
annotation.append(getLink(linkInfo));
@@ -1835,7 +1848,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
if (annotationValue.value() instanceof Type) {
Type type = (Type) annotationValue.value();
if (type.asClassDoc() != null) {
- LinkInfoImpl linkInfo = new LinkInfoImpl(
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_ANNOTATION, type);
linkInfo.label = (type.asClassDoc().isIncluded() ?
type.typeName() :
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
index b735b01f72f..bc0e1deb68d 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
@@ -130,7 +130,7 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
pre.addContent(fieldTypeStr);
} else {
Content fieldContent = new RawHtml(writer.getLink(new LinkInfoImpl(
- LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType)));
+ configuration, LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType)));
pre.addContent(fieldContent);
}
pre.addContent(fieldDimensions + " ");
@@ -187,8 +187,8 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
*/
public void addMemberTags(FieldDoc field, Content contentTree) {
TagletOutputImpl output = new TagletOutputImpl("");
- TagletWriter.genTagOuput(configuration().tagletManager, field,
- configuration().tagletManager.getCustomTags(field),
+ TagletWriter.genTagOuput(configuration.tagletManager, field,
+ configuration.tagletManager.getCustomTags(field),
writer.getTagletWriterInstance(false), output);
String outputString = output.toString().trim();
Content dlTags = new HtmlTree(HtmlTag.DL);
@@ -208,7 +208,7 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
* @return true if overview details need to be printed
*/
public boolean shouldPrintOverview(FieldDoc field) {
- if (!configuration().nocomment) {
+ if (!configuration.nocomment) {
if(!field.commentText().isEmpty() ||
writer.hasSerializationOverviewTags(field))
return true;
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
index 2b5bdcfe3a4..d71b4370cc6 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
@@ -148,7 +148,7 @@ public class HtmlSerialMethodWriter extends MethodWriterImpl implements
public void addMemberTags(MethodDoc member, Content methodsContentTree) {
TagletOutputImpl output = new TagletOutputImpl("");
TagletManager tagletManager =
- ConfigurationImpl.getInstance().tagletManager;
+ configuration.tagletManager;
TagletWriter.genTagOuput(tagletManager, member,
tagletManager.getSerializedFormTags(),
writer.getTagletWriterInstance(false), output);
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
index f0d0707be0d..00451159ccd 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
@@ -74,7 +74,7 @@ public class LinkFactoryImpl extends LinkFactory {
StringBuilder label = new StringBuilder(
classLinkInfo.getClassLinkLabel(m_writer.configuration));
classLinkInfo.displayLength += label.length();
- Configuration configuration = ConfigurationImpl.getInstance();
+ Configuration configuration = m_writer.configuration;
LinkOutputImpl linkOutput = new LinkOutputImpl();
if (classDoc.isIncluded()) {
if (configuration.isGeneratedDoc(classDoc)) {
@@ -118,8 +118,8 @@ public class LinkFactoryImpl extends LinkFactory {
*/
protected LinkOutput getTypeParameterLink(LinkInfo linkInfo,
Type typeParam) {
- LinkInfoImpl typeLinkInfo = new LinkInfoImpl(linkInfo.getContext(),
- typeParam);
+ LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration,
+ linkInfo.getContext(), typeParam);
typeLinkInfo.excludeTypeBounds = linkInfo.excludeTypeBounds;
typeLinkInfo.excludeTypeParameterLinks = linkInfo.excludeTypeParameterLinks;
typeLinkInfo.linkToSelf = linkInfo.linkToSelf;
@@ -135,10 +135,10 @@ public class LinkFactoryImpl extends LinkFactory {
* @return the tool tip for the appropriate class.
*/
private String getClassToolTip(ClassDoc classDoc, boolean isTypeLink) {
- Configuration configuration = ConfigurationImpl.getInstance();
+ Configuration configuration = m_writer.configuration;
if (isTypeLink) {
return configuration.getText("doclet.Href_Type_Param_Title",
- classDoc.name());
+ classDoc.name());
} else if (classDoc.isInterface()){
return configuration.getText("doclet.Href_Interface_Title",
Util.getPackageName(classDoc.containingPackage()));
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java
index ef5f38f5735..790543d32fd 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java
@@ -198,6 +198,8 @@ public class LinkInfoImpl extends LinkInfo {
*/
public static final int CONTEXT_CLASS_USE_HEADER = 33;
+ public final ConfigurationImpl configuration;
+
/**
* The integer indicating the location of the link.
*/
@@ -214,20 +216,22 @@ public class LinkInfoImpl extends LinkInfo {
public String styleName ="";
/**
- * The valueof the target.
+ * The value of the target.
*/
public String target = "";
/**
* Construct a LinkInfo object.
*
+ * @param configuration the configuration data for the doclet
* @param context the context of the link.
* @param classDoc the class to link to.
* @param label the label for the link.
* @param target the value of the target attribute.
*/
- public LinkInfoImpl (int context, ClassDoc classDoc, String label,
- String target){
+ public LinkInfoImpl(ConfigurationImpl configuration,
+ int context, ClassDoc classDoc, String label, String target) {
+ this.configuration = configuration;
this.classDoc = classDoc;
this.label = label;
this.target = target;
@@ -237,6 +241,7 @@ public class LinkInfoImpl extends LinkInfo {
/**
* Construct a LinkInfo object.
*
+ * @param configuration the configuration data for the doclet
* @param context the context of the link.
* @param classDoc the class to link to.
* @param where the value of the marker #.
@@ -244,8 +249,10 @@ public class LinkInfoImpl extends LinkInfo {
* @param isStrong true if the link should be strong.
* @param styleName String style of text defined in style sheet.
*/
- public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
- boolean isStrong, String styleName){
+ public LinkInfoImpl(ConfigurationImpl configuration,
+ int context, ClassDoc classDoc, String where, String label,
+ boolean isStrong, String styleName) {
+ this.configuration = configuration;
this.classDoc = classDoc;
this.where = where;
this.label = label;
@@ -257,14 +264,17 @@ public class LinkInfoImpl extends LinkInfo {
/**
* Construct a LinkInfo object.
*
+ * @param configuration the configuration data for the doclet
* @param context the context of the link.
* @param classDoc the class to link to.
* @param where the value of the marker #.
* @param label the label for the link.
* @param isStrong true if the link should be strong.
*/
- public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
- boolean isStrong){
+ public LinkInfoImpl(ConfigurationImpl configuration,
+ int context, ClassDoc classDoc, String where, String label,
+ boolean isStrong) {
+ this.configuration = configuration;
this.classDoc = classDoc;
this.where = where;
this.label = label;
@@ -275,10 +285,13 @@ public class LinkInfoImpl extends LinkInfo {
/**
* Construct a LinkInfo object.
*
+ * @param configuration the configuration data for the doclet
* @param classDoc the class to link to.
* @param label the label for the link.
*/
- public LinkInfoImpl (ClassDoc classDoc, String label){
+ public LinkInfoImpl(ConfigurationImpl configuration,
+ ClassDoc classDoc, String label) {
+ this.configuration = configuration;
this.classDoc = classDoc;
this.label = label;
setContext(context);
@@ -287,12 +300,15 @@ public class LinkInfoImpl extends LinkInfo {
/**
* Construct a LinkInfo object.
*
+ * @param configuration the configuration data for the doclet
* @param context the context of the link.
* @param executableMemberDoc the member to link to.
* @param isStrong true if the link should be strong.
*/
- public LinkInfoImpl (int context, ExecutableMemberDoc executableMemberDoc,
- boolean isStrong){
+ public LinkInfoImpl(ConfigurationImpl configuration,
+ int context, ExecutableMemberDoc executableMemberDoc,
+ boolean isStrong) {
+ this.configuration = configuration;
this.executableMemberDoc = executableMemberDoc;
this.isStrong = isStrong;
setContext(context);
@@ -301,11 +317,14 @@ public class LinkInfoImpl extends LinkInfo {
/**
* Construct a LinkInfo object.
*
+ * @param configuration the configuration data for the doclet
* @param context the context of the link.
* @param classDoc the class to link to.
* @param isStrong true if the link should be strong.
*/
- public LinkInfoImpl (int context, ClassDoc classDoc, boolean isStrong){
+ public LinkInfoImpl(ConfigurationImpl configuration,
+ int context, ClassDoc classDoc, boolean isStrong) {
+ this.configuration = configuration;
this.classDoc = classDoc;
this.isStrong = isStrong;
setContext(context);
@@ -314,10 +333,13 @@ public class LinkInfoImpl extends LinkInfo {
/**
* Construct a LinkInfo object.
*
+ * @param configuration the configuration data for the doclet
* @param context the context of the link.
* @param type the class to link to.
*/
- public LinkInfoImpl (int context, Type type){
+ public LinkInfoImpl(ConfigurationImpl configuration,
+ int context, Type type) {
+ this.configuration = configuration;
this.type = type;
setContext(context);
}
@@ -325,11 +347,14 @@ public class LinkInfoImpl extends LinkInfo {
/**
* Construct a LinkInfo object.
*
+ * @param configuration the configuration data for the doclet
* @param context the context of the link.
* @param type the class to link to.
* @param isVarArg true if this is a link to a var arg.
*/
- public LinkInfoImpl (int context, Type type, boolean isVarArg){
+ public LinkInfoImpl(ConfigurationImpl configuration,
+ int context, Type type, boolean isVarArg) {
+ this.configuration = configuration;
this.type = type;
this.isVarArg = isVarArg;
setContext(context);
@@ -338,13 +363,16 @@ public class LinkInfoImpl extends LinkInfo {
/**
* Construct a LinkInfo object.
*
+ * @param configuration the configuration data for the doclet
* @param context the context of the link.
* @param type the class to link to.
* @param label the label for the link.
* @param isStrong true if the link should be strong.
*/
- public LinkInfoImpl (int context, Type type, String label,
- boolean isStrong){
+ public LinkInfoImpl(ConfigurationImpl configuration,
+ int context, Type type, String label,
+ boolean isStrong) {
+ this.configuration = configuration;
this.type = type;
this.label = label;
this.isStrong = isStrong;
@@ -354,13 +382,16 @@ public class LinkInfoImpl extends LinkInfo {
/**
* Construct a LinkInfo object.
*
+ * @param configuration the configuration data for the doclet
* @param context the context of the link.
* @param classDoc the class to link to.
* @param label the label for the link.
* @param isStrong true if the link should be strong.
*/
- public LinkInfoImpl (int context, ClassDoc classDoc, String label,
- boolean isStrong){
+ public LinkInfoImpl(ConfigurationImpl configuration,
+ int context, ClassDoc classDoc, String label,
+ boolean isStrong) {
+ this.configuration = configuration;
this.classDoc = classDoc;
this.label = label;
this.isStrong = isStrong;
@@ -448,6 +479,6 @@ public class LinkInfoImpl extends LinkInfo {
* desired place.
*/
public boolean isLinkable() {
- return Util.isLinkable(classDoc, ConfigurationImpl.getInstance());
+ return Util.isLinkable(classDoc, configuration);
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
index 6b9ff239511..38b4dc0daa2 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
@@ -123,7 +123,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
addModifiers(method, pre);
addTypeParameters(method, pre);
addReturnType(method, pre);
- if (configuration().linksource) {
+ if (configuration.linksource) {
Content methodName = new StringContent(method.name());
writer.addSrcLink(method, methodName, pre);
} else {
@@ -149,7 +149,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
if (method.inlineTags().length > 0) {
if (holder.asClassDoc().equals(classdoc) ||
(! (holderClassDoc.isPublic() ||
- Util.isLinkable(holderClassDoc, configuration())))) {
+ Util.isLinkable(holderClassDoc, configuration)))) {
writer.addInlineComment(method, methodDocTree);
} else {
Content link = new RawHtml(
@@ -215,16 +215,16 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
* {@inheritDoc}
*/
public String getTableSummary() {
- return configuration().getText("doclet.Member_Table_Summary",
- configuration().getText("doclet.Method_Summary"),
- configuration().getText("doclet.methods"));
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Method_Summary"),
+ configuration.getText("doclet.methods"));
}
/**
* {@inheritDoc}
*/
public String getCaption() {
- return configuration().getText("doclet.Methods");
+ return configuration.getText("doclet.Methods");
}
/**
@@ -233,9 +233,9 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
public String[] getSummaryTableHeader(ProgramElementDoc member) {
String[] header = new String[] {
writer.getModifierTypeHeader(),
- configuration().getText("doclet.0_and_1",
- configuration().getText("doclet.Method"),
- configuration().getText("doclet.Description"))
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Method"),
+ configuration.getText("doclet.Description"))
};
return header;
}
@@ -253,7 +253,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
inheritedTree.addContent(writer.getMarkerAnchor(
"methods_inherited_from_class_" +
- configuration().getClassName(cd)));
+ configuration.getClassName(cd)));
}
/**
@@ -263,8 +263,8 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
LinkInfoImpl.CONTEXT_MEMBER, cd, false));
Content label = new StringContent(cd.isClass() ?
- configuration().getText("doclet.Methods_Inherited_From_Class") :
- configuration().getText("doclet.Methods_Inherited_From_Interface"));
+ configuration.getText("doclet.Methods_Inherited_From_Class") :
+ configuration.getText("doclet.Methods_Inherited_From_Interface"));
Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
label);
labelHeading.addContent(writer.getSpace());
@@ -285,12 +285,12 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
*/
protected static void addOverridden(HtmlDocletWriter writer,
Type overriddenType, MethodDoc method, Content dl) {
- if(writer.configuration.nocomment){
+ if (writer.configuration.nocomment) {
return;
}
ClassDoc holderClassDoc = overriddenType.asClassDoc();
if (! (holderClassDoc.isPublic() ||
- Util.isLinkable(holderClassDoc, writer.configuration()))) {
+ Util.isLinkable(holderClassDoc, writer.configuration))) {
//This is an implementation detail that should not be documented.
return;
}
@@ -303,7 +303,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
int context = LinkInfoImpl.CONTEXT_METHOD_OVERRIDES;
if (method != null) {
- if(overriddenType.asClassDoc().isAbstract() && method.isAbstract()){
+ if (overriddenType.asClassDoc().isAbstract() && method.isAbstract()){
//Abstract method is implemented from abstract class,
//not overridden
label = writer.specifiedByLabel;
@@ -312,11 +312,11 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
Content dt = HtmlTree.DT(HtmlTree.STRONG(label));
dl.addContent(dt);
Content overriddenTypeLink = new RawHtml(
- writer.getLink(new LinkInfoImpl(context, overriddenType)));
+ writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType)));
Content codeOverridenTypeLink = HtmlTree.CODE(overriddenTypeLink);
String name = method.name();
Content methlink = new RawHtml(writer.getLink(
- new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+ new LinkInfoImpl(writer.configuration, LinkInfoImpl.CONTEXT_MEMBER,
overriddenType.asClassDoc(),
writer.getAnchor(method), name, false)));
Content codeMethLink = HtmlTree.CODE(methlink);
@@ -362,7 +362,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
MethodDoc implementedMeth = implementedMethods[i];
Type intfac = implementedMethodsFinder.getMethodHolder(implementedMeth);
Content intfaclink = new RawHtml(writer.getLink(new LinkInfoImpl(
- LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac)));
+ writer.configuration, LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac)));
Content codeIntfacLink = HtmlTree.CODE(intfaclink);
Content dt = HtmlTree.DT(HtmlTree.STRONG(writer.specifiedByLabel));
dl.addContent(dt);
@@ -389,7 +389,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
Type type = method.returnType();
if (type != null) {
Content linkContent = new RawHtml(writer.getLink(
- new LinkInfoImpl(LinkInfoImpl.CONTEXT_RETURN_TYPE, type)));
+ new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_RETURN_TYPE, type)));
htmltree.addContent(linkContent);
htmltree.addContent(writer.getSpace());
}
@@ -403,7 +403,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
return writer.getHyperLink((cd == null)?
"method_summary":
"methods_inherited_from_class_" +
- configuration().getClassName(cd),
+ configuration.getClassName(cd),
writer.getResource("doclet.navMethod"));
} else {
return writer.getResource("doclet.navMethod");
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
index 5b9cda91b33..6ce42e57091 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
@@ -93,16 +93,16 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
* {@inheritDoc}
*/
public String getTableSummary() {
- return configuration().getText("doclet.Member_Table_Summary",
- configuration().getText("doclet.Nested_Class_Summary"),
- configuration().getText("doclet.nested_classes"));
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Nested_Class_Summary"),
+ configuration.getText("doclet.nested_classes"));
}
/**
* {@inheritDoc}
*/
public String getCaption() {
- return configuration().getText("doclet.Nested_Classes");
+ return configuration.getText("doclet.Nested_Classes");
}
/**
@@ -113,17 +113,17 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
if (member.isInterface()) {
header = new String[] {
writer.getModifierTypeHeader(),
- configuration().getText("doclet.0_and_1",
- configuration().getText("doclet.Interface"),
- configuration().getText("doclet.Description"))
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Interface"),
+ configuration.getText("doclet.Description"))
};
}
else {
header = new String[] {
writer.getModifierTypeHeader(),
- configuration().getText("doclet.0_and_1",
- configuration().getText("doclet.Class"),
- configuration().getText("doclet.Description"))
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Class"),
+ configuration.getText("doclet.Description"))
};
}
return header;
@@ -151,8 +151,8 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
LinkInfoImpl.CONTEXT_MEMBER, cd, false));
Content label = new StringContent(cd.isInterface() ?
- configuration().getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") :
- configuration().getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
+ configuration.getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") :
+ configuration.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
label);
labelHeading.addContent(writer.getSpace());
@@ -166,7 +166,7 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
Content tdSummary) {
Content strong = HtmlTree.STRONG(new RawHtml(
- writer.getLink(new LinkInfoImpl(context, (ClassDoc)member, false))));
+ writer.getLink(new LinkInfoImpl(configuration, context, (ClassDoc)member, false))));
Content code = HtmlTree.CODE(strong);
tdSummary.addContent(code);
}
@@ -177,7 +177,7 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
protected void addInheritedSummaryLink(ClassDoc cd,
ProgramElementDoc member, Content linksTree) {
linksTree.addContent(new RawHtml(
- writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+ writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER,
(ClassDoc)member, false))));
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
index e218a273d47..4535afaf55c 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
@@ -121,7 +121,7 @@ public class PackageFrameWriter extends HtmlDocletWriter {
* @param contentTree the content tree to which the listing will be added
*/
protected void addClassListing(Content contentTree) {
- Configuration config = configuration();
+ Configuration config = configuration;
if (packageDoc.isIncluded()) {
addClassKindListing(packageDoc.interfaces(),
getResource("doclet.Interfaces"), contentTree);
@@ -181,7 +181,7 @@ public class PackageFrameWriter extends HtmlDocletWriter {
contentTree.addContent(heading);
printedHeader = true;
}
- Content link = new RawHtml (getLink(new LinkInfoImpl(
+ Content link = new RawHtml (getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.PACKAGE_FRAME, arr[i],
(arr[i].isInterface() ? italicsText(arr[i].name()) :
arr[i].name()),"classFrame")));
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
index 4545484e451..b8369ce6255 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
@@ -152,7 +152,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
*/
protected void addPackageList(Content contentTree) throws IOException {
Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
- getTableCaption(configuration().getText(
+ getTableCaption(configuration.getText(
"doclet.ClassUse_Packages.that.use.0",
getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false))));
table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
@@ -197,7 +197,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
String tableSummary = configuration.getText("doclet.Use_Table_Summary",
configuration.getText("doclet.classes"));
Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
- getTableCaption(configuration().getText(
+ getTableCaption(configuration.getText(
"doclet.ClassUse_Classes.in.0.used.by.1",
getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false),
getPackageLinkString(usingPackage,Util.getPackageName(usingPackage), false))));
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
index 64f367e62e3..c1fcebf5f74 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
@@ -179,7 +179,8 @@ public class PackageWriterImpl extends HtmlDocletWriter
continue;
}
Content classContent = new RawHtml(getLink(new LinkInfoImpl(
- LinkInfoImpl.CONTEXT_PACKAGE, classes[i], false)));
+ configuration, LinkInfoImpl.CONTEXT_PACKAGE, classes[i],
+ false)));
Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
HtmlTree tr = HtmlTree.TR(tdClass);
if (i%2 == 0)
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
index c1df94a8728..665d15c17bf 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
@@ -46,11 +46,13 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter
implements SerializedFormWriter {
/**
+ * @param configuration the configuration data for the doclet
* @throws IOException
* @throws DocletAbortException
*/
- public SerializedFormWriterImpl() throws IOException {
- super(ConfigurationImpl.getInstance(), DocPaths.SERIALIZED_FORM);
+ public SerializedFormWriterImpl(ConfigurationImpl configuration)
+ throws IOException {
+ super(configuration, DocPaths.SERIALIZED_FORM);
}
/**
@@ -126,15 +128,16 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter
*/
public Content getClassHeader(ClassDoc classDoc) {
String classLink = (classDoc.isPublic() || classDoc.isProtected())?
- getLink(new LinkInfoImpl(classDoc,
+ getLink(new LinkInfoImpl(configuration, classDoc,
configuration.getClassName(classDoc))):
classDoc.qualifiedName();
Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
classDoc.qualifiedName()));
String superClassLink =
classDoc.superclassType() != null ?
- getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIALIZED_FORM,
- classDoc.superclassType())) :
+ getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.CONTEXT_SERIALIZED_FORM,
+ classDoc.superclassType())) :
null;
//Print the heading.
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
index 299f4f53313..c151c3ad228 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
@@ -60,16 +60,24 @@ public class SourceToHTMLConverter {
*/
private static final Content NEW_LINE = new RawHtml(DocletConstants.NL);
+ private final ConfigurationImpl configuration;
+
+ private final RootDoc rootDoc;
+
+ private DocPath outputdir;
+
/**
* Relative path from the documentation root to the file that is being
* generated.
*/
- private static DocPath relativePath = DocPath.empty;
+ private DocPath relativePath = DocPath.empty;
- /**
- * Source is converted to HTML using static methods below.
- */
- private SourceToHTMLConverter() {}
+ private SourceToHTMLConverter(ConfigurationImpl configuration, RootDoc rd,
+ DocPath outputdir) {
+ this.configuration = configuration;
+ this.rootDoc = rd;
+ this.outputdir = outputdir;
+ }
/**
* Convert the Classes in the given RootDoc to an HTML.
@@ -80,36 +88,38 @@ public class SourceToHTMLConverter {
*/
public static void convertRoot(ConfigurationImpl configuration, RootDoc rd,
DocPath outputdir) {
- if (rd == null || outputdir == null) {
+ new SourceToHTMLConverter(configuration, rd, outputdir).generate();
+ }
+
+ void generate() {
+ if (rootDoc == null || outputdir == null) {
return;
}
- PackageDoc[] pds = rd.specifiedPackages();
+ PackageDoc[] pds = rootDoc.specifiedPackages();
for (int i = 0; i < pds.length; i++) {
// If -nodeprecated option is set and the package is marked as deprecated,
// do not convert the package files to HTML.
if (!(configuration.nodeprecated && Util.isDeprecated(pds[i])))
- convertPackage(configuration, pds[i], outputdir);
+ convertPackage(pds[i], outputdir);
}
- ClassDoc[] cds = rd.specifiedClasses();
+ ClassDoc[] cds = rootDoc.specifiedClasses();
for (int i = 0; i < cds.length; i++) {
// If -nodeprecated option is set and the class is marked as deprecated
// or the containing package is deprecated, do not convert the
// package files to HTML.
if (!(configuration.nodeprecated &&
(Util.isDeprecated(cds[i]) || Util.isDeprecated(cds[i].containingPackage()))))
- convertClass(configuration, cds[i], outputdir);
+ convertClass(cds[i], outputdir);
}
}
/**
* Convert the Classes in the given Package to an HTML.
*
- * @param configuration the configuration.
* @param pd the Package to convert.
* @param outputdir the name of the directory to output to.
*/
- public static void convertPackage(ConfigurationImpl configuration, PackageDoc pd,
- DocPath outputdir) {
+ public void convertPackage(PackageDoc pd, DocPath outputdir) {
if (pd == null) {
return;
}
@@ -120,19 +130,17 @@ public class SourceToHTMLConverter {
// containing package deprecation since it is already check in
// the calling method above.
if (!(configuration.nodeprecated && Util.isDeprecated(cds[i])))
- convertClass(configuration, cds[i], outputdir);
+ convertClass(cds[i], outputdir);
}
}
/**
* Convert the given Class to an HTML.
*
- * @param configuration the configuration.
* @param cd the class to convert.
* @param outputdir the name of the directory to output to.
*/
- public static void convertClass(ConfigurationImpl configuration, ClassDoc cd,
- DocPath outputdir) {
+ public void convertClass(ClassDoc cd, DocPath outputdir) {
if (cd == null) {
return;
}
@@ -164,7 +172,7 @@ public class SourceToHTMLConverter {
try {
while ((line = reader.readLine()) != null) {
addLineNo(pre, lineno);
- addLine(pre, line, configuration.sourcetab, lineno);
+ addLine(pre, line, lineno);
lineno++;
}
} finally {
@@ -173,7 +181,7 @@ public class SourceToHTMLConverter {
addBlankLines(pre);
Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre);
body.addContent(div);
- writeToFile(body, outputdir.resolve(DocPath.forClass(cd)), configuration);
+ writeToFile(body, outputdir.resolve(DocPath.forClass(cd)));
} catch (IOException e) {
e.printStackTrace();
}
@@ -184,15 +192,13 @@ public class SourceToHTMLConverter {
*
* @param body the documentation content to be written to the file.
* @param path the path for the file.
- * @param configuration the Doclet configuration to pass notices to.
*/
- private static void writeToFile(Content body, DocPath path,
- ConfigurationImpl configuration) throws IOException {
- Content htmlDocType = DocType.Transitional();
+ private void writeToFile(Content body, DocPath path) throws IOException {
+ Content htmlDocType = DocType.TRANSITIONAL;
Content head = new HtmlTree(HtmlTag.HEAD);
head.addContent(HtmlTree.TITLE(new StringContent(
configuration.getText("doclet.Window_Source_title"))));
- head.addContent(getStyleSheetProperties(configuration));
+ head.addContent(getStyleSheetProperties());
Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
head, body);
Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree);
@@ -210,10 +216,9 @@ public class SourceToHTMLConverter {
/**
* Returns a link to the stylesheet file.
*
- * @param configuration the doclet configuration for the current run of javadoc
* @return an HtmlTree for the lINK tag which provides the stylesheet location
*/
- public static HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
+ public HtmlTree getStyleSheetProperties() {
String filename = configuration.stylesheetfile;
DocPath stylesheet;
if (filename.length() > 0) {
@@ -260,14 +265,13 @@ public class SourceToHTMLConverter {
*
* @param pre the content tree to which the line will be added.
* @param line the string to format.
- * @param tabLength the number of spaces for each tab.
* @param currentLineNo the current number.
*/
- private static void addLine(Content pre, String line, int tabLength,
- int currentLineNo) {
+ private void addLine(Content pre, String line, int currentLineNo) {
if (line != null) {
- StringBuilder lineBuffer = new StringBuilder(Util.escapeHtmlChars(line));
- Util.replaceTabs(tabLength, lineBuffer);
+ StringBuilder lineBuffer = new StringBuilder(line);
+ Util.replaceTabs(configuration, lineBuffer);
+ Util.escapeHtmlChars(lineBuffer);
pre.addContent(new RawHtml(lineBuffer.toString()));
Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo));
pre.addContent(anchor);
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
index 8f00a359a83..f3af8432e24 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
@@ -26,6 +26,7 @@
package com.sun.tools.doclets.formats.html;
import java.io.*;
+import java.util.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.markup.*;
@@ -77,15 +78,70 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
*
* @param mw the writer for the member being documented
* @param cd the classdoc to be documented
+ * @param tableContents list of summary table contents
+ * @param showTabs true if the table needs to show tabs
* @return the content tree for the summary table
*/
- public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) {
+ public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd,
+ List tableContents, boolean showTabs) {
+ Content caption;
+ if (showTabs) {
+ caption = getTableCaption(mw.methodTypes);
+ generateMethodTypesScript(mw.typeMap, mw.methodTypes);
+ }
+ else {
+ caption = getTableCaption(mw.getCaption());
+ }
Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0,
- mw.getTableSummary(), getTableCaption(mw.getCaption()));
+ mw.getTableSummary(), caption);
table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col"));
+ for (int i = 0; i < tableContents.size(); i++) {
+ table.addContent(tableContents.get(i));
+ }
return table;
}
+ /**
+ * Get the summary table caption.
+ *
+ * @param methodTypes set comprising of method types to show as table caption
+ * @return the caption for the summary table
+ */
+ public Content getTableCaption(Set methodTypes) {
+ Content tabbedCaption = new HtmlTree(HtmlTag.CAPTION);
+ for (MethodTypes type : methodTypes) {
+ Content captionSpan;
+ Content span;
+ if (type.isDefaultTab()) {
+ captionSpan = HtmlTree.SPAN(new StringContent(type.text()));
+ span = HtmlTree.SPAN(type.tabId(),
+ HtmlStyle.activeTableTab, captionSpan);
+ } else {
+ captionSpan = HtmlTree.SPAN(getMethodTypeLinks(type));
+ span = HtmlTree.SPAN(type.tabId(),
+ HtmlStyle.tableTab, captionSpan);
+ }
+ Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, getSpace());
+ span.addContent(tabSpan);
+ tabbedCaption.addContent(span);
+ }
+ return tabbedCaption;
+ }
+
+ /**
+ * Get the method type links for the table caption.
+ *
+ * @param methodType the method type to be displayed as link
+ * @return the content tree for the method type link
+ */
+ public Content getMethodTypeLinks(MethodTypes methodType) {
+ StringBuilder jsShow = new StringBuilder("javascript:show(");
+ jsShow.append(methodType.value()).append(");");
+ HtmlTree link = HtmlTree.A(jsShow.toString(),
+ new StringContent(methodType.text()));
+ return link;
+ }
+
/**
* Add the inherited summary header.
*
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
index ce158d443d0..6f190dab9e5 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
@@ -46,11 +46,13 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
public class TagletWriterImpl extends TagletWriter {
- private HtmlDocletWriter htmlWriter;
+ private final HtmlDocletWriter htmlWriter;
+ private final ConfigurationImpl configuration;
public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) {
+ super(isFirstSentence);
this.htmlWriter = htmlWriter;
- this.isFirstSentence = isFirstSentence;
+ configuration = htmlWriter.configuration;
}
/**
@@ -64,8 +66,8 @@ public class TagletWriterImpl extends TagletWriter {
* {@inheritDoc}
*/
public TagletOutput getDocRootOutput() {
- if (htmlWriter.configuration.docrootparent.length() > 0)
- return new TagletOutputImpl(htmlWriter.configuration.docrootparent);
+ if (configuration.docrootparent.length() > 0)
+ return new TagletOutputImpl(configuration.docrootparent);
else if (htmlWriter.pathToRoot.isEmpty())
return new TagletOutputImpl(".");
else
@@ -81,7 +83,7 @@ public class TagletWriterImpl extends TagletWriter {
if (doc instanceof ClassDoc) {
if (Util.isDeprecated((ProgramElementDoc) doc)) {
output.append("" +
- ConfigurationImpl.getInstance().
+ configuration.
getText("doclet.Deprecated") + " ");
if (deprs.length > 0) {
Tag[] commentTags = deprs[0].inlineTags();
@@ -97,7 +99,7 @@ public class TagletWriterImpl extends TagletWriter {
MemberDoc member = (MemberDoc) doc;
if (Util.isDeprecated((ProgramElementDoc) doc)) {
output.append("" +
- ConfigurationImpl.getInstance().
+ configuration.
getText("doclet.Deprecated") + " ");
if (deprs.length > 0) {
output.append("");
@@ -108,7 +110,7 @@ public class TagletWriterImpl extends TagletWriter {
} else {
if (Util.isDeprecated(member.containingClass())) {
output.append("" +
- ConfigurationImpl.getInstance().
+ configuration.
getText("doclet.Deprecated") + " ");
}
}
@@ -120,7 +122,7 @@ public class TagletWriterImpl extends TagletWriter {
* {@inheritDoc}
*/
public MessageRetriever getMsgRetriever() {
- return htmlWriter.configuration.message;
+ return configuration.message;
}
/**
@@ -147,7 +149,7 @@ public class TagletWriterImpl extends TagletWriter {
*/
public TagletOutput returnTagOutput(Tag returnTag) {
TagletOutput result = new TagletOutputImpl(DocletConstants.NL + "
");
+ configuration.getText("doclet.Throws") + "");
}
/**
@@ -245,7 +247,7 @@ public class TagletWriterImpl extends TagletWriter {
result += throwsTag.exceptionType() == null ?
htmlWriter.codeText(throwsTag.exceptionName()) :
htmlWriter.codeText(
- htmlWriter.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+ htmlWriter.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER,
throwsTag.exceptionType())));
TagletOutput text = new TagletOutputImpl(
htmlWriter.commentTagsToString(throwsTag, null,
@@ -263,7 +265,7 @@ public class TagletWriterImpl extends TagletWriter {
public TagletOutput throwsTagOutput(Type throwsType) {
return new TagletOutputImpl(DocletConstants.NL + "
" +
htmlWriter.codeText(htmlWriter.getLink(
- new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + "
");
+ new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + "");
}
/**
@@ -303,7 +305,7 @@ public class TagletWriterImpl extends TagletWriter {
* {@inheritDoc}
*/
public Configuration configuration() {
- return htmlWriter.configuration();
+ return configuration;
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java
index 573abe0462f..874e1fa486b 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java
@@ -25,6 +25,8 @@
package com.sun.tools.doclets.formats.html;
+import java.io.IOException;
+
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
@@ -42,7 +44,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
*/
public class WriterFactoryImpl implements WriterFactory {
- private ConfigurationImpl configuration;
+ private final ConfigurationImpl configuration;
public WriterFactoryImpl(ConfigurationImpl configuration) {
this.configuration = configuration;
@@ -60,7 +62,7 @@ public class WriterFactoryImpl implements WriterFactory {
*/
public PackageSummaryWriter getPackageSummaryWriter(PackageDoc packageDoc,
PackageDoc prevPkg, PackageDoc nextPkg) throws Exception {
- return new PackageWriterImpl(ConfigurationImpl.getInstance(), packageDoc,
+ return new PackageWriterImpl(configuration, packageDoc,
prevPkg, nextPkg);
}
@@ -68,9 +70,9 @@ public class WriterFactoryImpl implements WriterFactory {
* {@inheritDoc}
*/
public ClassWriter getClassWriter(ClassDoc classDoc, ClassDoc prevClass,
- ClassDoc nextClass, ClassTree classTree)
- throws Exception {
- return new ClassWriterImpl(classDoc, prevClass, nextClass, classTree);
+ ClassDoc nextClass, ClassTree classTree) throws IOException {
+ return new ClassWriterImpl(configuration, classDoc,
+ prevClass, nextClass, classTree);
}
/**
@@ -79,7 +81,8 @@ public class WriterFactoryImpl implements WriterFactory {
public AnnotationTypeWriter getAnnotationTypeWriter(
AnnotationTypeDoc annotationType, Type prevType, Type nextType)
throws Exception {
- return new AnnotationTypeWriterImpl(annotationType, prevType, nextType);
+ return new AnnotationTypeWriterImpl(configuration,
+ annotationType, prevType, nextType);
}
/**
@@ -106,7 +109,7 @@ public class WriterFactoryImpl implements WriterFactory {
/**
* {@inheritDoc}
*/
- public EnumConstantWriter getEnumConstantWriter(ClassWriter classWriter)
+ public EnumConstantWriterImpl getEnumConstantWriter(ClassWriter classWriter)
throws Exception {
return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter,
classWriter.getClassDoc());
@@ -115,7 +118,7 @@ public class WriterFactoryImpl implements WriterFactory {
/**
* {@inheritDoc}
*/
- public FieldWriter getFieldWriter(ClassWriter classWriter)
+ public FieldWriterImpl getFieldWriter(ClassWriter classWriter)
throws Exception {
return new FieldWriterImpl((SubWriterHolderWriter) classWriter,
classWriter.getClassDoc());
@@ -124,7 +127,7 @@ public class WriterFactoryImpl implements WriterFactory {
/**
* {@inheritDoc}
*/
- public MethodWriter getMethodWriter(ClassWriter classWriter)
+ public MethodWriterImpl getMethodWriter(ClassWriter classWriter)
throws Exception {
return new MethodWriterImpl((SubWriterHolderWriter) classWriter,
classWriter.getClassDoc());
@@ -133,7 +136,7 @@ public class WriterFactoryImpl implements WriterFactory {
/**
* {@inheritDoc}
*/
- public ConstructorWriter getConstructorWriter(ClassWriter classWriter)
+ public ConstructorWriterImpl getConstructorWriter(ClassWriter classWriter)
throws Exception {
return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter,
classWriter.getClassDoc());
@@ -143,20 +146,20 @@ public class WriterFactoryImpl implements WriterFactory {
* {@inheritDoc}
*/
public MemberSummaryWriter getMemberSummaryWriter(
- ClassWriter classWriter, int memberType)
- throws Exception {
+ ClassWriter classWriter, int memberType)
+ throws Exception {
switch (memberType) {
case VisibleMemberMap.CONSTRUCTORS:
- return (ConstructorWriterImpl) getConstructorWriter(classWriter);
+ return getConstructorWriter(classWriter);
case VisibleMemberMap.ENUM_CONSTANTS:
- return (EnumConstantWriterImpl) getEnumConstantWriter(classWriter);
+ return getEnumConstantWriter(classWriter);
case VisibleMemberMap.FIELDS:
- return (FieldWriterImpl) getFieldWriter(classWriter);
+ return getFieldWriter(classWriter);
case VisibleMemberMap.INNERCLASSES:
return new NestedClassWriterImpl((SubWriterHolderWriter)
classWriter, classWriter.getClassDoc());
case VisibleMemberMap.METHODS:
- return (MethodWriterImpl) getMethodWriter(classWriter);
+ return getMethodWriter(classWriter);
default:
return null;
}
@@ -184,6 +187,6 @@ public class WriterFactoryImpl implements WriterFactory {
* {@inheritDoc}
*/
public SerializedFormWriter getSerializedFormWriter() throws Exception {
- return new SerializedFormWriterImpl();
+ return new SerializedFormWriterImpl(configuration);
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java
index e923333dba2..0e586b4a4e0 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java
@@ -41,13 +41,15 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
*
* @author Bhavesh Patel
*/
-public class DocType extends Content{
+public class DocType extends Content {
private String docType;
- private static DocType transitional;
+ public static final DocType TRANSITIONAL =
+ new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd");
- private static DocType frameset;
+ public static final DocType FRAMESET =
+ new DocType("Frameset", "http://www.w3.org/TR/html4/frameset.dtd");
/**
* Constructor to construct a DocType object.
@@ -59,28 +61,6 @@ public class DocType extends Content{
"//EN\" \"" + dtd + "\">" + DocletConstants.NL;
}
- /**
- * Construct and return a HTML 4.01 transitional DocType content
- *
- * @return a content tree for transitional DocType
- */
- public static DocType Transitional() {
- if (transitional == null)
- transitional = new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd");
- return transitional;
- }
-
- /**
- * Construct and return a HTML 4.01 frameset DocType content
- *
- * @return a content tree for frameset DocType
- */
- public static DocType Frameset() {
- if (frameset == null)
- frameset = new DocType("Frameset", "http://www.w3.org/TR/html4/frameset.dtd");
- return frameset;
- }
-
/**
* This method is not supported by the class.
*
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
index 376bfdcfeb2..36b55febcff 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
@@ -31,6 +31,7 @@ import java.util.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.ConfigurationImpl;
import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.DocFile;
import com.sun.tools.doclets.internal.toolkit.util.DocLink;
import com.sun.tools.doclets.internal.toolkit.util.DocPath;
import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
@@ -63,7 +64,7 @@ public abstract class HtmlDocWriter extends HtmlWriter {
throws IOException {
super(configuration, filename);
configuration.message.notice("doclet.Generating_0",
- filename.resolveAgainst(configuration.destDirName));
+ DocFile.createFileForOutput(configuration, filename).getPath());
}
/**
@@ -254,7 +255,7 @@ public abstract class HtmlDocWriter extends HtmlWriter {
*/
public void printFramesetDocument(String title, boolean noTimeStamp,
Content frameset) throws IOException {
- Content htmlDocType = DocType.Frameset();
+ Content htmlDocType = DocType.FRAMESET;
Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
Content head = new HtmlTree(HtmlTag.HEAD);
if (! noTimeStamp) {
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java
index 61bb800cbef..a1719bbe8cf 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java
@@ -37,6 +37,7 @@ package com.sun.tools.doclets.formats.html.markup;
*/
public enum HtmlStyle {
aboutLanguage,
+ activeTableTab,
altColor,
bar,
block,
@@ -75,6 +76,7 @@ public enum HtmlStyle {
summary,
deprecatedContent,
tabEnd,
+ tableTab,
title,
topNav;
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
index 99543d1fdf0..6c761050c7a 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
@@ -493,6 +493,20 @@ public class HtmlTree extends Content {
return htmltree;
}
+ /**
+ * Generates a SCRIPT tag with the type and src attributes.
+ *
+ * @param type type of link
+ * @param src the path for the script
+ * @return an HtmlTree object for the SCRIPT tag
+ */
+ public static HtmlTree SCRIPT(String type, String src) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.SCRIPT);
+ htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type));
+ htmltree.addAttr(HtmlAttr.SRC, nullCheck(src));
+ return htmltree;
+ }
+
/**
* Generates a SMALL tag with some content.
*
@@ -539,6 +553,23 @@ public class HtmlTree extends Content {
return htmltree;
}
+ /**
+ * Generates a SPAN tag with id and style class attributes. It also encloses
+ * a content.
+ *
+ * @param id the id for the tag
+ * @param styleClass stylesheet class for the tag
+ * @param body content for the tag
+ * @return an HtmlTree object for the SPAN tag
+ */
+ public static HtmlTree SPAN(String id, HtmlStyle styleClass, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.SPAN, nullCheck(body));
+ htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
+ if (styleClass != null)
+ htmltree.addStyle(styleClass);
+ return htmltree;
+ }
+
/**
* Generates a Table tag with border, width and summary attributes and
* some content.
@@ -742,6 +773,9 @@ public class HtmlTree extends Content {
return (hasAttr(HtmlAttr.HREF) && !hasContent());
case META :
return (hasAttr(HtmlAttr.CONTENT) && !hasContent());
+ case SCRIPT :
+ return ((hasAttr(HtmlAttr.TYPE) && hasAttr(HtmlAttr.SRC) && !hasContent()) ||
+ (hasAttr(HtmlAttr.TYPE) && hasContent()));
default :
return hasContent();
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
index bd6be7a5c36..01238cfeb91 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
@@ -26,6 +26,7 @@
package com.sun.tools.doclets.formats.html.markup;
import java.io.*;
+import java.util.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
@@ -144,6 +145,8 @@ public class HtmlWriter {
private final Writer writer;
+ private Content script;
+
/**
* Constructor.
*
@@ -301,7 +304,8 @@ public class HtmlWriter {
// Don't print windowtitle script for overview-frame, allclasses-frame
// and package-frame
if (includeScript) {
- body.addContent(getWinTitleScript());
+ this.script = getWinTitleScript();
+ body.addContent(script);
Content noScript = HtmlTree.NOSCRIPT(
HtmlTree.DIV(getResource("doclet.No_Script_Message")));
body.addContent(noScript);
@@ -309,6 +313,53 @@ public class HtmlWriter {
return body;
}
+ /**
+ * Generated javascript variables for the document.
+ *
+ * @param typeMap map comprising of method and type relationship
+ * @param methodTypes set comprising of all methods types for this class
+ */
+ public void generateMethodTypesScript(Map typeMap,
+ Set methodTypes) {
+ String sep = "";
+ StringBuilder vars = new StringBuilder("var methods = {");
+ for (Map.Entry entry : typeMap.entrySet()) {
+ vars.append(sep);
+ sep = ",";
+ vars.append("\"");
+ vars.append(entry.getKey());
+ vars.append("\":");
+ vars.append(entry.getValue());
+ }
+ vars.append("};").append(DocletConstants.NL);
+ sep = "";
+ vars.append("var tabs = {");
+ for (MethodTypes entry : methodTypes) {
+ vars.append(sep);
+ sep = ",";
+ vars.append(entry.value()).append(":");
+ vars.append("[").append("\"").append(entry.tabId());
+ vars.append("\"").append(sep).append("\"").append(entry.text()).append("\"]");
+ }
+ vars.append("};").append(DocletConstants.NL);
+ addStyles(HtmlStyle.altColor, vars);
+ addStyles(HtmlStyle.rowColor, vars);
+ addStyles(HtmlStyle.tableTab, vars);
+ addStyles(HtmlStyle.activeTableTab, vars);
+ script.addContent(new RawHtml(vars.toString()));
+ }
+
+ /**
+ * Adds javascript style variables to the document.
+ *
+ * @param style style to be added as a javascript variable
+ * @param vars variable string to which the style variable will be added
+ */
+ public void addStyles(HtmlStyle style, StringBuilder vars) {
+ vars.append("var ").append(style).append(" = \"").append(style)
+ .append("\";").append(DocletConstants.NL);
+ }
+
/**
* Returns an HtmlTree for the TITLE tag.
*
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java
index 4ae4cce1722..388c07093bc 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java
@@ -51,8 +51,8 @@ public abstract class AbstractDoclet {
/**
* The only doclet that may use this toolkit is {@value}
*/
- private static final String TOOLKIT_DOCLET_NAME = new
- com.sun.tools.doclets.formats.html.HtmlDoclet().getClass().getName();
+ private static final String TOOLKIT_DOCLET_NAME =
+ com.sun.tools.doclets.formats.html.HtmlDoclet.class.getName();
/**
* Verify that the only doclet that is using this toolkit is
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
index d94b7bef826..13099d24be9 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
@@ -32,6 +32,7 @@ import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory;
import com.sun.tools.doclets.internal.toolkit.taglets.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
+import javax.tools.JavaFileManager;
/**
* Configure the output based on the options. Doclets should sub-class
@@ -77,14 +78,16 @@ public abstract class Configuration {
/**
* This is true if option "-serialwarn" is used. Defualt value is false to
- * supress excessive warnings about serial tag.
+ * suppress excessive warnings about serial tag.
*/
public boolean serialwarn = false;
/**
* The specified amount of space between tab stops.
*/
- public int sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
+ public int sourcetab;
+
+ public String tabSpaces;
/**
* True if we should generate browsable sources.
@@ -259,6 +262,7 @@ public abstract class Configuration {
"com.sun.tools.doclets.internal.toolkit.resources.doclets");
excludedDocFileDirs = new HashSet();
excludedQualifiers = new HashSet();
+ setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
}
/**
@@ -382,7 +386,7 @@ public abstract class Configuration {
} else if (opt.equals("-sourcetab")) {
linksource = true;
try {
- sourcetab = Integer.parseInt(os[1]);
+ setTabWidth(Integer.parseInt(os[1]));
} catch (NumberFormatException e) {
//Set to -1 so that warning will be printed
//to indicate what is valid argument.
@@ -390,7 +394,7 @@ public abstract class Configuration {
}
if (sourcetab <= 0) {
message.warning("doclet.sourcetab_warning");
- sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
+ setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
}
} else if (opt.equals("-notimestamp")) {
notimestamp = true;
@@ -442,7 +446,7 @@ public abstract class Configuration {
/**
* Initialize the taglet manager. The strings to initialize the simple custom tags should
* be in the following format: "[tag name]:[location str]:[heading]".
- * @param customTagStrs the set two dimentional arrays of strings. These arrays contain
+ * @param customTagStrs the set two dimensional arrays of strings. These arrays contain
* either -tag or -taglet arguments.
*/
private void initTagletManager(Set customTagStrs) {
@@ -453,11 +457,11 @@ public abstract class Configuration {
for (Iterator it = customTagStrs.iterator(); it.hasNext(); ) {
args = it.next();
if (args[0].equals("-taglet")) {
- tagletManager.addCustomTag(args[1], tagletpath);
+ tagletManager.addCustomTag(args[1], getFileManager(), tagletpath);
continue;
}
String[] tokens = tokenize(args[1],
- TagletManager.SIMPLE_TAGLET_OPT_SEPERATOR, 3);
+ TagletManager.SIMPLE_TAGLET_OPT_SEPARATOR, 3);
if (tokens.length == 1) {
String tagName = args[1];
if (tagletManager.isKnownCustomTag(tagName)) {
@@ -749,7 +753,7 @@ public abstract class Configuration {
* @return the input steam to the builder XML.
* @throws FileNotFoundException when the given XML file cannot be found.
*/
- public InputStream getBuilderXML() throws FileNotFoundException {
+ public InputStream getBuilderXML() throws IOException {
return builderXMLPath == null ?
Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) :
DocFile.createFileForInput(this, builderXMLPath).openInputStream();
@@ -760,6 +764,11 @@ public abstract class Configuration {
*/
public abstract Locale getLocale();
+ /**
+ * Return the current file manager.
+ */
+ public abstract JavaFileManager getFileManager();
+
/**
* Return the comparator that will be used to sort member documentation.
* To no do any sorting, return null.
@@ -767,4 +776,9 @@ public abstract class Configuration {
* @return the {@link java.util.Comparator} used to sort members.
*/
public abstract Comparator getMemberComparator();
+
+ private void setTabWidth(int n) {
+ sourcetab = n;
+ tabSpaces = String.format("%" + n + "s", "");
+ }
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java
index 53e0b5b260f..79ec354448d 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java
@@ -58,9 +58,11 @@ public interface MemberSummaryWriter {
* Get the summary table for the given class.
*
* @param classDoc the class the summary table belongs to
+ * @param tableContents list of contents that will be added to the summary table
* @return a content tree for the member summary table
*/
- public Content getSummaryTableTree(ClassDoc classDoc);
+ public Content getSummaryTableTree(ClassDoc classDoc,
+ List tableContents);
/**
* Add the member summary for the given class and member.
@@ -68,11 +70,11 @@ public interface MemberSummaryWriter {
* @param classDoc the class the summary belongs to
* @param member the member that is documented
* @param firstSentenceTags the tags for the sentence being documented
- * @param tableTree the content treeto which the information will be added
- * @param counter the counter for determing style for the table row
+ * @param tableContents list of contents to which the summary will be added
+ * @param counter the counter for determining id and style for the table row
*/
public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
- Tag[] firstSentenceTags, Content tableTree, int counter);
+ Tag[] firstSentenceTags, List tableContents, int counter);
/**
* Get the inherited member summary header for the given class.
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
index ef7b0d99ee3..56676ec86b8 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
@@ -52,18 +52,46 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
*/
public abstract class AbstractBuilder {
+ public static class Context {
+ /**
+ * The configuration used in this run of the doclet.
+ */
+ final Configuration configuration;
+
+ /**
+ * Keep track of which packages we have seen for
+ * efficiency purposes. We don't want to copy the
+ * doc files multiple times for a single package.
+ */
+ final Set containingPackagesSeen;
+
+ /**
+ * Shared parser for the builder XML file
+ */
+ final LayoutParser layoutParser;
+
+ Context(Configuration configuration,
+ Set containingPackagesSeen,
+ LayoutParser layoutParser) {
+ this.configuration = configuration;
+ this.containingPackagesSeen = containingPackagesSeen;
+ this.layoutParser = layoutParser;
+ }
+ }
/**
* The configuration used in this run of the doclet.
*/
- protected Configuration configuration;
+ protected final Configuration configuration;
/**
* Keep track of which packages we have seen for
* efficiency purposes. We don't want to copy the
* doc files multiple times for a single package.
*/
- protected static Set containingPackagesSeen;
+ protected final Set containingPackagesSeen;
+
+ protected final LayoutParser layoutParser;
/**
* True if we want to print debug output.
@@ -75,8 +103,10 @@ public abstract class AbstractBuilder {
* @param configuration the configuration used in this run
* of the doclet.
*/
- public AbstractBuilder(Configuration configuration) {
- this.configuration = configuration;
+ public AbstractBuilder(Context c) {
+ this.configuration = c.configuration;
+ this.containingPackagesSeen = c.containingPackagesSeen;
+ this.layoutParser = c.layoutParser;
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
index b7454d96879..5313f4f80b5 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
@@ -25,6 +25,8 @@
package com.sun.tools.doclets.internal.toolkit.builders;
+import java.util.Set;
+
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
@@ -48,8 +50,8 @@ public abstract class AbstractMemberBuilder extends AbstractBuilder {
* @param configuration the configuration used in this run
* of the doclet.
*/
- public AbstractMemberBuilder(Configuration configuration) {
- super(configuration);
+ public AbstractMemberBuilder(Context context) {
+ super(context);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
index acde3af8d2f..1a9dec1f757 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
@@ -54,12 +54,12 @@ public class AnnotationTypeBuilder extends AbstractBuilder {
/**
* The annotation type being documented.
*/
- private AnnotationTypeDoc annotationTypeDoc;
+ private final AnnotationTypeDoc annotationTypeDoc;
/**
* The doclet specific writer.
*/
- private AnnotationTypeWriter writer;
+ private final AnnotationTypeWriter writer;
/**
* The content tree for the annotation documentation.
@@ -69,38 +69,37 @@ public class AnnotationTypeBuilder extends AbstractBuilder {
/**
* Construct a new ClassBuilder.
*
- * @param configuration the current configuration of the
- * doclet.
+ * @param context the build context.
+ * @param annotationTypeDoc the class being documented.
+ * @param writer the doclet specific writer.
*/
- private AnnotationTypeBuilder(Configuration configuration) {
- super(configuration);
+ private AnnotationTypeBuilder(Context context,
+ AnnotationTypeDoc annotationTypeDoc,
+ AnnotationTypeWriter writer) {
+ super(context);
+ this.annotationTypeDoc = annotationTypeDoc;
+ this.writer = writer;
}
/**
* Construct a new ClassBuilder.
*
- * @param configuration the current configuration of the doclet.
+ * @param context the build context.
* @param annotationTypeDoc the class being documented.
* @param writer the doclet specific writer.
*/
- public static AnnotationTypeBuilder getInstance(Configuration configuration,
- AnnotationTypeDoc annotationTypeDoc, AnnotationTypeWriter writer)
- throws Exception {
- AnnotationTypeBuilder builder = new AnnotationTypeBuilder(configuration);
- builder.configuration = configuration;
- builder.annotationTypeDoc = annotationTypeDoc;
- builder.writer = writer;
- if(containingPackagesSeen == null) {
- containingPackagesSeen = new HashSet();
- }
- return builder;
+ public static AnnotationTypeBuilder getInstance(Context context,
+ AnnotationTypeDoc annotationTypeDoc,
+ AnnotationTypeWriter writer)
+ throws Exception {
+ return new AnnotationTypeBuilder(context, annotationTypeDoc, writer);
}
/**
* {@inheritDoc}
*/
public void build() throws IOException {
- build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+ build(layoutParser.parseXML(ROOT), contentTree);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
index edcfbe2094f..9c28e9eae4d 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
@@ -25,8 +25,6 @@
package com.sun.tools.doclets.internal.toolkit.builders;
-import java.util.*;
-
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
@@ -44,43 +42,36 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
* @since 1.5
*/
public class AnnotationTypeOptionalMemberBuilder extends
- AnnotationTypeRequiredMemberBuilder {
+ AnnotationTypeRequiredMemberBuilder {
/**
* Construct a new AnnotationTypeMemberBuilder.
*
- * @param configuration the current configuration of the
- * doclet.
+ * @param context the build context.
+ * @param classDoc the class whose members are being documented.
+ * @param writer the doclet specific writer.
*/
- private AnnotationTypeOptionalMemberBuilder(Configuration configuration) {
- super(configuration);
+ private AnnotationTypeOptionalMemberBuilder(Context context,
+ ClassDoc classDoc,
+ AnnotationTypeOptionalMemberWriter writer) {
+ super(context, classDoc, writer,
+ VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL);
}
/**
* Construct a new AnnotationTypeMemberBuilder.
*
- * @param configuration the current configuration of the doclet.
- * @param classDoc the class whoses members are being documented.
+ * @param context the build context.
+ * @param classDoc the class whose members are being documented.
* @param writer the doclet specific writer.
*/
public static AnnotationTypeOptionalMemberBuilder getInstance(
- Configuration configuration, ClassDoc classDoc,
+ Context context, ClassDoc classDoc,
AnnotationTypeOptionalMemberWriter writer) {
- AnnotationTypeOptionalMemberBuilder builder =
- new AnnotationTypeOptionalMemberBuilder(configuration);
- builder.classDoc = classDoc;
- builder.writer = writer;
- builder.visibleMemberMap = new VisibleMemberMap(classDoc,
- VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, configuration.nodeprecated);
- builder.members = new ArrayList(
- builder.visibleMemberMap.getMembersFor(classDoc));
- if (configuration.getMemberComparator() != null) {
- Collections.sort(builder.members,
- configuration.getMemberComparator());
- }
- return builder;
+ return new AnnotationTypeOptionalMemberBuilder(context,
+ classDoc, writer);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
index 733eac39aa7..b44161dab81 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
@@ -74,37 +74,40 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
/**
* Construct a new AnnotationTypeRequiredMemberBuilder.
*
- * @param configuration the current configuration of the
- * doclet.
+ * @param context the build context.
+ * @param classDoc the class whose members are being documented.
+ * @param writer the doclet specific writer.
*/
- protected AnnotationTypeRequiredMemberBuilder(Configuration configuration) {
- super(configuration);
+ protected AnnotationTypeRequiredMemberBuilder(Context context,
+ ClassDoc classDoc,
+ AnnotationTypeRequiredMemberWriter writer,
+ int memberType) {
+ super(context);
+ this.classDoc = classDoc;
+ this.writer = writer;
+ this.visibleMemberMap = new VisibleMemberMap(classDoc, memberType,
+ configuration.nodeprecated);
+ this.members = new ArrayList(
+ this.visibleMemberMap.getMembersFor(classDoc));
+ if (configuration.getMemberComparator() != null) {
+ Collections.sort(this.members, configuration.getMemberComparator());
+ }
}
/**
* Construct a new AnnotationTypeMemberBuilder.
*
- * @param configuration the current configuration of the doclet.
- * @param classDoc the class whoses members are being documented.
+ * @param context the build context.
+ * @param classDoc the class whose members are being documented.
* @param writer the doclet specific writer.
*/
public static AnnotationTypeRequiredMemberBuilder getInstance(
- Configuration configuration, ClassDoc classDoc,
+ Context context, ClassDoc classDoc,
AnnotationTypeRequiredMemberWriter writer) {
- AnnotationTypeRequiredMemberBuilder builder =
- new AnnotationTypeRequiredMemberBuilder(configuration);
- builder.classDoc = classDoc;
- builder.writer = writer;
- builder.visibleMemberMap = new VisibleMemberMap(classDoc,
- VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, configuration.nodeprecated);
- builder.members = new ArrayList(
- builder.visibleMemberMap.getMembersFor(classDoc));
- if (configuration.getMemberComparator() != null) {
- Collections.sort(builder.members,
- configuration.getMemberComparator());
- }
- return builder;
+ return new AnnotationTypeRequiredMemberBuilder(context, classDoc,
+ writer,
+ VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java
index 71fb5a36b1b..1936c72a9fa 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java
@@ -25,6 +25,9 @@
package com.sun.tools.doclets.internal.toolkit.builders;
+import java.util.HashSet;
+import java.util.Set;
+
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
@@ -46,12 +49,14 @@ public class BuilderFactory {
/**
* The current configuration of the doclet.
*/
- private Configuration configuration;
+ private final Configuration configuration;
/**
* The factory to retrieve the required writers from.
*/
- private WriterFactory writerFactory;
+ private final WriterFactory writerFactory;
+
+ private final AbstractBuilder.Context context;
/**
* Construct a builder factory using the given configuration.
@@ -61,6 +66,10 @@ public class BuilderFactory {
public BuilderFactory (Configuration configuration) {
this.configuration = configuration;
this.writerFactory = configuration.getWriterFactory();
+
+ Set containingPackagesSeen = new HashSet();
+ context = new AbstractBuilder.Context(configuration, containingPackagesSeen,
+ LayoutParser.getInstance(configuration));
}
/**
@@ -68,7 +77,7 @@ public class BuilderFactory {
* @return the builder that builds the constant summary.
*/
public AbstractBuilder getConstantsSummaryBuider() throws Exception {
- return ConstantsSummaryBuilder.getInstance(configuration,
+ return ConstantsSummaryBuilder.getInstance(context,
writerFactory.getConstantsSummaryWriter());
}
@@ -82,7 +91,7 @@ public class BuilderFactory {
*/
public AbstractBuilder getPackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
PackageDoc nextPkg) throws Exception {
- return PackageSummaryBuilder.getInstance(configuration, pkg,
+ return PackageSummaryBuilder.getInstance(context, pkg,
writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg));
}
@@ -97,9 +106,9 @@ public class BuilderFactory {
* writer is not supported by the doclet.
*/
public AbstractBuilder getClassBuilder(ClassDoc classDoc,
- ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
+ ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
throws Exception {
- return ClassBuilder.getInstance(configuration, classDoc,
+ return ClassBuilder.getInstance(context, classDoc,
writerFactory.getClassWriter(classDoc, prevClass, nextClass,
classTree));
}
@@ -117,9 +126,8 @@ public class BuilderFactory {
AnnotationTypeDoc annotationType,
Type prevType, Type nextType)
throws Exception {
- return AnnotationTypeBuilder.getInstance(configuration, annotationType,
- writerFactory.getAnnotationTypeWriter(annotationType, prevType,
- nextType));
+ return AnnotationTypeBuilder.getInstance(context, annotationType,
+ writerFactory.getAnnotationTypeWriter(annotationType, prevType, nextType));
}
/**
@@ -129,7 +137,7 @@ public class BuilderFactory {
*/
public AbstractBuilder getMethodBuilder(ClassWriter classWriter)
throws Exception {
- return MethodBuilder.getInstance(configuration,
+ return MethodBuilder.getInstance(context,
classWriter.getClassDoc(),
writerFactory.getMethodWriter(classWriter));
}
@@ -144,7 +152,7 @@ public class BuilderFactory {
public AbstractBuilder getAnnotationTypeOptionalMemberBuilder(
AnnotationTypeWriter annotationTypeWriter)
throws Exception {
- return AnnotationTypeOptionalMemberBuilder.getInstance(configuration,
+ return AnnotationTypeOptionalMemberBuilder.getInstance(context,
annotationTypeWriter.getAnnotationTypeDoc(),
writerFactory.getAnnotationTypeOptionalMemberWriter(
annotationTypeWriter));
@@ -160,7 +168,7 @@ public class BuilderFactory {
public AbstractBuilder getAnnotationTypeRequiredMemberBuilder(
AnnotationTypeWriter annotationTypeWriter)
throws Exception {
- return AnnotationTypeRequiredMemberBuilder.getInstance(configuration,
+ return AnnotationTypeRequiredMemberBuilder.getInstance(context,
annotationTypeWriter.getAnnotationTypeDoc(),
writerFactory.getAnnotationTypeRequiredMemberWriter(
annotationTypeWriter));
@@ -173,7 +181,7 @@ public class BuilderFactory {
*/
public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter)
throws Exception {
- return EnumConstantBuilder.getInstance(configuration, classWriter.getClassDoc(),
+ return EnumConstantBuilder.getInstance(context, classWriter.getClassDoc(),
writerFactory.getEnumConstantWriter(classWriter));
}
@@ -184,7 +192,7 @@ public class BuilderFactory {
*/
public AbstractBuilder getFieldBuilder(ClassWriter classWriter)
throws Exception {
- return FieldBuilder.getInstance(configuration, classWriter.getClassDoc(),
+ return FieldBuilder.getInstance(context, classWriter.getClassDoc(),
writerFactory.getFieldWriter(classWriter));
}
@@ -195,9 +203,9 @@ public class BuilderFactory {
*/
public AbstractBuilder getConstructorBuilder(ClassWriter classWriter)
throws Exception {
- return ConstructorBuilder.getInstance(configuration,
- classWriter.getClassDoc(), writerFactory.getConstructorWriter(
- classWriter));
+ return ConstructorBuilder.getInstance(context,
+ classWriter.getClassDoc(),
+ writerFactory.getConstructorWriter(classWriter));
}
/**
@@ -207,7 +215,7 @@ public class BuilderFactory {
*/
public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter)
throws Exception {
- return MemberSummaryBuilder.getInstance(classWriter, configuration);
+ return MemberSummaryBuilder.getInstance(classWriter, context);
}
/**
@@ -220,8 +228,7 @@ public class BuilderFactory {
public AbstractBuilder getMemberSummaryBuilder(
AnnotationTypeWriter annotationTypeWriter)
throws Exception {
- return MemberSummaryBuilder.getInstance(annotationTypeWriter,
- configuration);
+ return MemberSummaryBuilder.getInstance(annotationTypeWriter, context);
}
/**
@@ -231,6 +238,6 @@ public class BuilderFactory {
*/
public AbstractBuilder getSerializedFormBuilder()
throws Exception {
- return SerializedFormBuilder.getInstance(configuration);
+ return SerializedFormBuilder.getInstance(context);
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
index 83b0b85dd4d..1f2e82a10ad 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
@@ -54,22 +54,22 @@ public class ClassBuilder extends AbstractBuilder {
/**
* The class being documented.
*/
- private ClassDoc classDoc;
+ private final ClassDoc classDoc;
/**
* The doclet specific writer.
*/
- private ClassWriter writer;
+ private final ClassWriter writer;
/**
* Keep track of whether or not this classdoc is an interface.
*/
- private boolean isInterface = false;
+ private final boolean isInterface;
/**
* Keep track of whether or not this classdoc is an enum.
*/
- private boolean isEnum = false;
+ private final boolean isEnum;
/**
* The content tree for the class documentation.
@@ -79,44 +79,45 @@ public class ClassBuilder extends AbstractBuilder {
/**
* Construct a new ClassBuilder.
*
- * @param configuration the current configuration of the
- * doclet.
+ * @param context the build context
+ * @param classDoc the class being documented.
+ * @param writer the doclet specific writer.
*/
- private ClassBuilder(Configuration configuration) {
- super(configuration);
+ private ClassBuilder(Context context,
+ ClassDoc classDoc, ClassWriter writer) {
+ super(context);
+ this.classDoc = classDoc;
+ this.writer = writer;
+ if (classDoc.isInterface()) {
+ isInterface = true;
+ isEnum = false;
+ } else if (classDoc.isEnum()) {
+ isInterface = false;
+ isEnum = true;
+ Util.setEnumDocumentation(configuration, classDoc);
+ } else {
+ isInterface = false;
+ isEnum = false;
+ }
}
/**
* Construct a new ClassBuilder.
*
- * @param configuration the current configuration of the doclet.
+ * @param context the build context
* @param classDoc the class being documented.
* @param writer the doclet specific writer.
*/
- public static ClassBuilder getInstance(Configuration configuration,
- ClassDoc classDoc, ClassWriter writer)
- throws Exception {
- ClassBuilder builder = new ClassBuilder(configuration);
- builder.configuration = configuration;
- builder.classDoc = classDoc;
- builder.writer = writer;
- if (classDoc.isInterface()) {
- builder.isInterface = true;
- } else if (classDoc.isEnum()) {
- builder.isEnum = true;
- Util.setEnumDocumentation(configuration, classDoc);
- }
- if(containingPackagesSeen == null) {
- containingPackagesSeen = new HashSet();
- }
- return builder;
+ public static ClassBuilder getInstance(Context context,
+ ClassDoc classDoc, ClassWriter writer) {
+ return new ClassBuilder(context, classDoc, writer);
}
/**
* {@inheritDoc}
*/
public void build() throws IOException {
- build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+ build(layoutParser.parseXML(ROOT), contentTree);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
index 6de9f78920f..bab4f0da24e 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
@@ -60,12 +60,12 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
/**
* The writer used to write the results.
*/
- protected ConstantsSummaryWriter writer;
+ protected final ConstantsSummaryWriter writer;
/**
* The set of ClassDocs that have constant fields.
*/
- protected Set classDocsWithConstFields;
+ protected final Set classDocsWithConstFields;
/**
* The set of printed package headers.
@@ -90,27 +90,25 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
/**
* Construct a new ConstantsSummaryBuilder.
*
- * @param configuration the current configuration of the
- * doclet.
+ * @param context the build context.
+ * @param writer the writer for the summary.
*/
- private ConstantsSummaryBuilder(Configuration configuration) {
- super(configuration);
+ private ConstantsSummaryBuilder(Context context,
+ ConstantsSummaryWriter writer) {
+ super(context);
+ this.writer = writer;
+ this.classDocsWithConstFields = new HashSet();
}
/**
* Construct a ConstantsSummaryBuilder.
*
- * @param configuration the configuration used in this run
- * of the doclet.
+ * @param context the build context.
* @param writer the writer for the summary.
*/
- public static ConstantsSummaryBuilder getInstance(
- Configuration configuration, ConstantsSummaryWriter writer) {
- ConstantsSummaryBuilder builder = new ConstantsSummaryBuilder(
- configuration);
- builder.writer = writer;
- builder.classDocsWithConstFields = new HashSet();
- return builder;
+ public static ConstantsSummaryBuilder getInstance(Context context,
+ ConstantsSummaryWriter writer) {
+ return new ConstantsSummaryBuilder(context, writer);
}
/**
@@ -121,7 +119,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
//Doclet does not support this output.
return;
}
- build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+ build(layoutParser.parseXML(ROOT), contentTree);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
index 20f93081562..d4cb7061f6c 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
@@ -59,66 +59,64 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
/**
* The class whose constructors are being documented.
*/
- private ClassDoc classDoc;
+ private final ClassDoc classDoc;
/**
* The visible constructors for the given class.
*/
- private VisibleMemberMap visibleMemberMap;
+ private final VisibleMemberMap visibleMemberMap;
/**
* The writer to output the constructor documentation.
*/
- private ConstructorWriter writer;
+ private final ConstructorWriter writer;
/**
* The constructors being documented.
*/
- private List constructors;
+ private final List constructors;
/**
* Construct a new ConstructorBuilder.
*
- * @param configuration the current configuration of the
- * doclet.
+ * @param context the build context.
+ * @param classDoc the class whoses members are being documented.
+ * @param writer the doclet specific writer.
*/
- private ConstructorBuilder(Configuration configuration) {
- super(configuration);
+ private ConstructorBuilder(Context context,
+ ClassDoc classDoc,
+ ConstructorWriter writer) {
+ super(context);
+ this.classDoc = classDoc;
+ this.writer = writer;
+ visibleMemberMap =
+ new VisibleMemberMap(
+ classDoc,
+ VisibleMemberMap.CONSTRUCTORS,
+ configuration.nodeprecated);
+ constructors =
+ new ArrayList(visibleMemberMap.getMembersFor(classDoc));
+ for (int i = 0; i < constructors.size(); i++) {
+ if (constructors.get(i).isProtected()
+ || constructors.get(i).isPrivate()) {
+ writer.setFoundNonPubConstructor(true);
+ }
+ }
+ if (configuration.getMemberComparator() != null) {
+ Collections.sort(constructors,configuration.getMemberComparator());
+ }
}
/**
* Construct a new ConstructorBuilder.
*
- * @param configuration the current configuration of the doclet.
+ * @param context the build context.
* @param classDoc the class whoses members are being documented.
* @param writer the doclet specific writer.
*/
- public static ConstructorBuilder getInstance(
- Configuration configuration,
- ClassDoc classDoc,
- ConstructorWriter writer) {
- ConstructorBuilder builder = new ConstructorBuilder(configuration);
- builder.classDoc = classDoc;
- builder.writer = writer;
- builder.visibleMemberMap =
- new VisibleMemberMap(
- classDoc,
- VisibleMemberMap.CONSTRUCTORS,
- configuration.nodeprecated);
- builder.constructors =
- new ArrayList(builder.visibleMemberMap.getMembersFor(classDoc));
- for (int i = 0; i < builder.constructors.size(); i++) {
- if (builder.constructors.get(i).isProtected()
- || builder.constructors.get(i).isPrivate()) {
- writer.setFoundNonPubConstructor(true);
- }
- }
- if (configuration.getMemberComparator() != null) {
- Collections.sort(
- builder.constructors,
- configuration.getMemberComparator());
- }
- return builder;
+ public static ConstructorBuilder getInstance(Context context,
+ ClassDoc classDoc, ConstructorWriter writer) {
+ return new ConstructorBuilder(context, classDoc, writer);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
index 36f5d397441..6ac59cd3034 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
@@ -48,22 +48,22 @@ public class EnumConstantBuilder extends AbstractMemberBuilder {
/**
* The class whose enum constants are being documented.
*/
- private ClassDoc classDoc;
+ private final ClassDoc classDoc;
/**
* The visible enum constantss for the given class.
*/
- private VisibleMemberMap visibleMemberMap;
+ private final VisibleMemberMap visibleMemberMap;
/**
* The writer to output the enum constants documentation.
*/
- private EnumConstantWriter writer;
+ private final EnumConstantWriter writer;
/**
* The list of enum constants being documented.
*/
- private List enumConstants;
+ private final List enumConstants;
/**
* The index of the current enum constant that is being documented at this point
@@ -74,40 +74,37 @@ public class EnumConstantBuilder extends AbstractMemberBuilder {
/**
* Construct a new EnumConstantsBuilder.
*
- * @param configuration the current configuration of the
- * doclet.
+ * @param context the build context.
+ * @param classDoc the class whoses members are being documented.
+ * @param writer the doclet specific writer.
*/
- private EnumConstantBuilder(Configuration configuration) {
- super(configuration);
+ private EnumConstantBuilder(Context context,
+ ClassDoc classDoc, EnumConstantWriter writer) {
+ super(context);
+ this.classDoc = classDoc;
+ this.writer = writer;
+ visibleMemberMap =
+ new VisibleMemberMap(
+ classDoc,
+ VisibleMemberMap.ENUM_CONSTANTS,
+ configuration.nodeprecated);
+ enumConstants =
+ new ArrayList(visibleMemberMap.getMembersFor(classDoc));
+ if (configuration.getMemberComparator() != null) {
+ Collections.sort(enumConstants, configuration.getMemberComparator());
+ }
}
/**
* Construct a new EnumConstantsBuilder.
*
- * @param configuration the current configuration of the doclet.
+ * @param context the build context.
* @param classDoc the class whoses members are being documented.
* @param writer the doclet specific writer.
*/
- public static EnumConstantBuilder getInstance(
- Configuration configuration,
- ClassDoc classDoc,
- EnumConstantWriter writer) {
- EnumConstantBuilder builder = new EnumConstantBuilder(configuration);
- builder.classDoc = classDoc;
- builder.writer = writer;
- builder.visibleMemberMap =
- new VisibleMemberMap(
- classDoc,
- VisibleMemberMap.ENUM_CONSTANTS,
- configuration.nodeprecated);
- builder.enumConstants =
- new ArrayList(builder.visibleMemberMap.getMembersFor(classDoc));
- if (configuration.getMemberComparator() != null) {
- Collections.sort(
- builder.enumConstants,
- configuration.getMemberComparator());
- }
- return builder;
+ public static EnumConstantBuilder getInstance(Context context,
+ ClassDoc classDoc, EnumConstantWriter writer) {
+ return new EnumConstantBuilder(context, classDoc, writer);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
index 4f05027f672..a9dbec3bd74 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
@@ -48,22 +48,22 @@ public class FieldBuilder extends AbstractMemberBuilder {
/**
* The class whose fields are being documented.
*/
- private ClassDoc classDoc;
+ private final ClassDoc classDoc;
/**
* The visible fields for the given class.
*/
- private VisibleMemberMap visibleMemberMap;
+ private final VisibleMemberMap visibleMemberMap;
/**
* The writer to output the field documentation.
*/
- private FieldWriter writer;
+ private final FieldWriter writer;
/**
* The list of fields being documented.
*/
- private List fields;
+ private final List fields;
/**
* The index of the current field that is being documented at this point
@@ -74,41 +74,40 @@ public class FieldBuilder extends AbstractMemberBuilder {
/**
* Construct a new FieldBuilder.
*
- * @param configuration the current configuration of the
- * doclet.
+ * @param context the build context.
+ * @param classDoc the class whoses members are being documented.
+ * @param writer the doclet specific writer.
*/
- private FieldBuilder(Configuration configuration) {
- super(configuration);
+ private FieldBuilder(Context context,
+ ClassDoc classDoc,
+ FieldWriter writer) {
+ super(context);
+ this.classDoc = classDoc;
+ this.writer = writer;
+ visibleMemberMap =
+ new VisibleMemberMap(
+ classDoc,
+ VisibleMemberMap.FIELDS,
+ configuration.nodeprecated);
+ fields =
+ new ArrayList(visibleMemberMap.getLeafClassMembers(
+ configuration));
+ if (configuration.getMemberComparator() != null) {
+ Collections.sort(fields, configuration.getMemberComparator());
+ }
}
/**
* Construct a new FieldBuilder.
*
- * @param configuration the current configuration of the doclet.
+ * @param context the build context.
* @param classDoc the class whoses members are being documented.
* @param writer the doclet specific writer.
*/
- public static FieldBuilder getInstance(
- Configuration configuration,
+ public static FieldBuilder getInstance(Context context,
ClassDoc classDoc,
FieldWriter writer) {
- FieldBuilder builder = new FieldBuilder(configuration);
- builder.classDoc = classDoc;
- builder.writer = writer;
- builder.visibleMemberMap =
- new VisibleMemberMap(
- classDoc,
- VisibleMemberMap.FIELDS,
- configuration.nodeprecated);
- builder.fields =
- new ArrayList(builder.visibleMemberMap.getLeafClassMembers(
- configuration));
- if (configuration.getMemberComparator() != null) {
- Collections.sort(
- builder.fields,
- configuration.getMemberComparator());
- }
- return builder;
+ return new FieldBuilder(context, classDoc, writer);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
index f6e2f339dda..6c9b3067846 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
@@ -55,14 +55,10 @@ public class LayoutParser extends DefaultHandler {
*/
private Map xmlElementsMap;
private XMLNode currentNode;
- private Configuration configuration;
- private static LayoutParser instance;
+ private final Configuration configuration;
private String currentRoot;
private boolean isParsing;
- /**
- * This class is a singleton.
- */
private LayoutParser(Configuration configuration) {
xmlElementsMap = new HashMap();
this.configuration = configuration;
@@ -75,10 +71,7 @@ public class LayoutParser extends DefaultHandler {
* @return an instance of the BuilderXML.
*/
public static LayoutParser getInstance(Configuration configuration) {
- if (instance == null) {
- instance = new LayoutParser(configuration);
- }
- return instance;
+ return new LayoutParser(configuration);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
index 2d81a4caefd..aef27a1501a 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
@@ -53,7 +53,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
/**
* The visible members for the given class.
*/
- private VisibleMemberMap[] visibleMemberMaps;
+ private final VisibleMemberMap[] visibleMemberMaps;
/**
* The member summary writers for the given class.
@@ -63,10 +63,27 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
/**
* The type being documented.
*/
- private ClassDoc classDoc;
+ private final ClassDoc classDoc;
- private MemberSummaryBuilder(Configuration configuration) {
- super(configuration);
+ /**
+ * Construct a new MemberSummaryBuilder.
+ *
+ * @param classWriter the writer for the class whose members are being
+ * summarized.
+ * @param context the build context.
+ */
+ private MemberSummaryBuilder(Context context, ClassDoc classDoc) {
+ super(context);
+ this.classDoc = classDoc;
+ visibleMemberMaps =
+ new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES];
+ for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
+ visibleMemberMaps[i] =
+ new VisibleMemberMap(
+ classDoc,
+ i,
+ configuration.nodeprecated);
+ }
}
/**
@@ -74,14 +91,22 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
*
* @param classWriter the writer for the class whose members are being
* summarized.
- * @param configuration the current configuration of the doclet.
+ * @param context the build context.
*/
public static MemberSummaryBuilder getInstance(
- ClassWriter classWriter, Configuration configuration)
+ ClassWriter classWriter, Context context)
throws Exception {
- MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
- builder.classDoc = classWriter.getClassDoc();
- builder.init(classWriter);
+ MemberSummaryBuilder builder = new MemberSummaryBuilder(context,
+ classWriter.getClassDoc());
+ builder.memberSummaryWriters =
+ new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
+ WriterFactory wf = context.configuration.getWriterFactory();
+ for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
+ builder.memberSummaryWriters[i] =
+ builder.visibleMemberMaps[i].noVisibleMembers() ?
+ null :
+ wf.getMemberSummaryWriter(classWriter, i);
+ }
return builder;
}
@@ -93,42 +118,21 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
* @param configuration the current configuration of the doclet.
*/
public static MemberSummaryBuilder getInstance(
- AnnotationTypeWriter annotationTypeWriter, Configuration configuration)
+ AnnotationTypeWriter annotationTypeWriter, Context context)
throws Exception {
- MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
- builder.classDoc = annotationTypeWriter.getAnnotationTypeDoc();
- builder.init(annotationTypeWriter);
- return builder;
- }
-
- private void init(Object writer) throws Exception {
- visibleMemberMaps =
- new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES];
- for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
- visibleMemberMaps[i] =
- new VisibleMemberMap(
- classDoc,
- i,
- configuration.nodeprecated);
- }
- memberSummaryWriters =
+ MemberSummaryBuilder builder = new MemberSummaryBuilder(context,
+ annotationTypeWriter.getAnnotationTypeDoc());
+ builder.memberSummaryWriters =
new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
+ WriterFactory wf = context.configuration.getWriterFactory();
for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
- if (classDoc.isAnnotationType()) {
- memberSummaryWriters[i] =
- visibleMemberMaps[i].noVisibleMembers()?
+ builder.memberSummaryWriters[i] =
+ builder.visibleMemberMaps[i].noVisibleMembers()?
null :
- configuration.getWriterFactory().getMemberSummaryWriter(
- (AnnotationTypeWriter) writer, i);
- } else {
- memberSummaryWriters[i] =
- visibleMemberMaps[i].noVisibleMembers()?
- null :
- configuration.getWriterFactory().getMemberSummaryWriter(
- (ClassWriter) writer, i);
- }
+ wf.getMemberSummaryWriter(
+ annotationTypeWriter, i);
}
-
+ return builder;
}
/**
@@ -304,7 +308,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
configuration));
if (members.size() > 0) {
Collections.sort(members);
- Content tableTree = writer.getSummaryTableTree(classDoc);
+ List tableContents = new LinkedList();
for (int i = 0; i < members.size(); i++) {
ProgramElementDoc member = members.get(i);
Tag[] firstSentenceTags = member.firstSentenceTags();
@@ -313,14 +317,15 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
//necessary.
DocFinder.Output inheritedDoc =
DocFinder.search(new DocFinder.Input((MethodDoc) member));
- if (inheritedDoc.holder != null &&
- inheritedDoc.holder.firstSentenceTags().length > 0) {
+ if (inheritedDoc.holder != null
+ && inheritedDoc.holder.firstSentenceTags().length > 0) {
firstSentenceTags = inheritedDoc.holder.firstSentenceTags();
}
}
- writer.addMemberSummary(classDoc, member, firstSentenceTags, tableTree, i);
+ writer.addMemberSummary(classDoc, member, firstSentenceTags,
+ tableContents, i);
}
- summaryTreeList.add(tableTree);
+ summaryTreeList.add(writer.getSummaryTableTree(classDoc, tableContents));
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
index ed933351fe1..2c9b10c93ba 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
@@ -54,57 +54,61 @@ public class MethodBuilder extends AbstractMemberBuilder {
/**
* The class whose methods are being documented.
*/
- private ClassDoc classDoc;
+ private final ClassDoc classDoc;
/**
* The visible methods for the given class.
*/
- private VisibleMemberMap visibleMemberMap;
+ private final VisibleMemberMap visibleMemberMap;
/**
* The writer to output the method documentation.
*/
- private MethodWriter writer;
+ private final MethodWriter writer;
/**
* The methods being documented.
*/
private List methods;
- private MethodBuilder(Configuration configuration) {
- super(configuration);
+
+ /**
+ * Construct a new MethodBuilder.
+ *
+ * @param context the build context.
+ * @param classDoc the class whoses members are being documented.
+ * @param writer the doclet specific writer.
+ */
+ private MethodBuilder(Context context,
+ ClassDoc classDoc,
+ MethodWriter writer) {
+ super(context);
+ this.classDoc = classDoc;
+ this.writer = writer;
+ visibleMemberMap = new VisibleMemberMap(
+ classDoc,
+ VisibleMemberMap.METHODS,
+ configuration.nodeprecated);
+ methods =
+ new ArrayList(visibleMemberMap.getLeafClassMembers(
+ configuration));
+ if (configuration.getMemberComparator() != null) {
+ Collections.sort(methods, configuration.getMemberComparator());
+ }
}
/**
* Construct a new MethodBuilder.
*
- * @param configuration the current configuration of the doclet.
+ * @param context the build context.
* @param classDoc the class whoses members are being documented.
* @param writer the doclet specific writer.
*
* @return an instance of a MethodBuilder.
*/
- public static MethodBuilder getInstance(
- Configuration configuration,
- ClassDoc classDoc,
- MethodWriter writer) {
- MethodBuilder builder = new MethodBuilder(configuration);
- builder.classDoc = classDoc;
- builder.writer = writer;
- builder.visibleMemberMap =
- new VisibleMemberMap(
- classDoc,
- VisibleMemberMap.METHODS,
- configuration.nodeprecated);
- builder.methods =
- new ArrayList(builder.visibleMemberMap.getLeafClassMembers(
- configuration));
- if (configuration.getMemberComparator() != null) {
- Collections.sort(
- builder.methods,
- configuration.getMemberComparator());
- }
- return builder;
+ public static MethodBuilder getInstance(Context context,
+ ClassDoc classDoc, MethodWriter writer) {
+ return new MethodBuilder(context, classDoc, writer);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
index 290d1fbc24f..a40968da070 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
@@ -52,40 +52,47 @@ public class PackageSummaryBuilder extends AbstractBuilder {
/**
* The package being documented.
*/
- private PackageDoc packageDoc;
+ private final PackageDoc packageDoc;
/**
* The doclet specific writer that will output the result.
*/
- private PackageSummaryWriter packageWriter;
+ private final PackageSummaryWriter packageWriter;
/**
* The content that will be added to the package summary documentation tree.
*/
private Content contentTree;
- private PackageSummaryBuilder(Configuration configuration) {
- super(configuration);
+ /**
+ * Construct a new PackageSummaryBuilder.
+ *
+ * @param context the build context.
+ * @param pkg the package being documented.
+ * @param packageWriter the doclet specific writer that will output the
+ * result.
+ */
+ private PackageSummaryBuilder(Context context,
+ PackageDoc pkg,
+ PackageSummaryWriter packageWriter) {
+ super(context);
+ this.packageDoc = pkg;
+ this.packageWriter = packageWriter;
}
/**
* Construct a new PackageSummaryBuilder.
- * @param configuration the current configuration of the doclet.
+ *
+ * @param context the build context.
* @param pkg the package being documented.
* @param packageWriter the doclet specific writer that will output the
* result.
*
* @return an instance of a PackageSummaryBuilder.
*/
- public static PackageSummaryBuilder getInstance(
- Configuration configuration,
- PackageDoc pkg,
- PackageSummaryWriter packageWriter) {
- PackageSummaryBuilder builder =
- new PackageSummaryBuilder(configuration);
- builder.packageDoc = pkg;
- builder.packageWriter = packageWriter;
- return builder;
+ public static PackageSummaryBuilder getInstance(Context context,
+ PackageDoc pkg, PackageSummaryWriter packageWriter) {
+ return new PackageSummaryBuilder(context, pkg, packageWriter);
}
/**
@@ -96,7 +103,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
//Doclet does not support this output.
return;
}
- build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+ build(layoutParser.parseXML(ROOT), contentTree);
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
index 3b50d6c00e7..da424f66036 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
@@ -93,17 +93,21 @@ public class SerializedFormBuilder extends AbstractBuilder {
*/
private Content contentTree;
- private SerializedFormBuilder(Configuration configuration) {
- super(configuration);
+
+ /**
+ * Construct a new SerializedFormBuilder.
+ * @param context the build context.
+ */
+ private SerializedFormBuilder(Context context) {
+ super(context);
}
/**
* Construct a new SerializedFormBuilder.
- * @param configuration the current configuration of the doclet.
+ * @param context the build context.
*/
- public static SerializedFormBuilder getInstance(Configuration configuration) {
- SerializedFormBuilder builder = new SerializedFormBuilder(configuration);
- return builder;
+ public static SerializedFormBuilder getInstance(Context context) {
+ return new SerializedFormBuilder(context);
}
/**
@@ -123,7 +127,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
} catch (Exception e) {
throw new DocletAbortException();
}
- build(LayoutParser.getInstance(configuration).parseXML(NAME), contentTree);
+ build(layoutParser.parseXML(NAME), contentTree);
writer.close();
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar.gif b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar.gif
new file mode 100644
index 00000000000..7b6e08fff67
Binary files /dev/null and b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar.gif differ
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar_end.gif b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar_end.gif
new file mode 100644
index 00000000000..feabf0bf6c8
Binary files /dev/null and b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar_end.gif differ
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/script.js b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/script.js
new file mode 100644
index 00000000000..b3463569314
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/script.js
@@ -0,0 +1,30 @@
+function show(type)
+{
+ count = 0;
+ for (var key in methods) {
+ var row = document.getElementById(key);
+ if ((methods[key] & type) != 0) {
+ row.style.display = '';
+ row.className = (count++ % 2) ? rowColor : altColor;
+ }
+ else
+ row.style.display = 'none';
+ }
+ updateTabs(type);
+}
+
+function updateTabs(type)
+{
+ for (var value in tabs) {
+ var sNode = document.getElementById(tabs[value][0]);
+ var spanNode = sNode.firstChild;
+ if (value == type) {
+ sNode.className = activeTableTab;
+ spanNode.innerHTML = tabs[value][1];
+ }
+ else {
+ sNode.className = tableTab;
+ spanNode.innerHTML = "" + tabs[value][1] + "";
+ }
+ }
+}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
index 0aeaa97fe05..ce3df208de2 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
@@ -381,6 +381,31 @@ caption a:link, caption a:hover, caption a:active, caption a:visited {
background-image:url(resources/titlebar.gif);
height:18px;
}
+.contentContainer ul.blockList li.blockList caption span.activeTableTab span {
+ white-space:nowrap;
+ padding-top:8px;
+ padding-left:8px;
+ display:block;
+ float:left;
+ background-image:url(resources/activetitlebar.gif);
+ height:18px;
+}
+.contentContainer ul.blockList li.blockList caption span.tableTab span {
+ white-space:nowrap;
+ padding-top:8px;
+ padding-left:8px;
+ display:block;
+ float:left;
+ background-image:url(resources/titlebar.gif);
+ height:18px;
+}
+.contentContainer ul.blockList li.blockList caption span.tableTab, .contentContainer ul.blockList li.blockList caption span.activeTableTab {
+ padding-top:0px;
+ padding-left:0px;
+ background-image:none;
+ float:none;
+ display:inline;
+}
.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
width:10px;
background-image:url(resources/titlebar_end.gif);
@@ -389,6 +414,24 @@ caption a:link, caption a:hover, caption a:active, caption a:visited {
position:relative;
float:left;
}
+.contentContainer ul.blockList li.blockList .activeTableTab .tabEnd {
+ width:10px;
+ margin-right:5px;
+ background-image:url(resources/activetitlebar_end.gif);
+ background-repeat:no-repeat;
+ background-position:top right;
+ position:relative;
+ float:left;
+}
+.contentContainer ul.blockList li.blockList .tableTab .tabEnd {
+ width:10px;
+ margin-right:5px;
+ background-image:url(resources/titlebar_end.gif);
+ background-repeat:no-repeat;
+ background-position:top right;
+ position:relative;
+ float:left;
+}
ul.blockList ul.blockList li.blockList table {
margin:0 0 12px 0px;
width:100%;
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java
index e737f9c7698..65924bbad7f 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java
@@ -26,6 +26,7 @@
package com.sun.tools.doclets.internal.toolkit.taglets;
import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Configuration;
import com.sun.tools.doclets.internal.toolkit.util.*;
/**
@@ -104,7 +105,7 @@ public class InheritDocTaglet extends BaseInlineTaglet {
/**
* Given a MethodDoc item, a Tag in the
- * MethodDoc item and a String, replace all occurances
+ * MethodDoc item and a String, replace all occurrences
* of @inheritDoc with documentation from it's superclass or superinterface.
*
* @param writer the writer that is writing the output.
@@ -116,12 +117,13 @@ public class InheritDocTaglet extends BaseInlineTaglet {
MethodDoc md, Tag holderTag, boolean isFirstSentence) {
TagletOutput replacement = writer.getTagletOutputInstance();
+ Configuration configuration = writer.configuration();
Taglet inheritableTaglet = holderTag == null ?
- null : writer.configuration().tagletManager.getTaglet(holderTag.name());
+ null : configuration.tagletManager.getTaglet(holderTag.name());
if (inheritableTaglet != null &&
!(inheritableTaglet instanceof InheritableTaglet)) {
//This tag does not support inheritence.
- writer.configuration().message.warning(md.position(),
+ configuration.message.warning(md.position(),
"doclet.noInheritedDoc", md.name() + md.flatSignature());
}
DocFinder.Output inheritedDoc =
@@ -129,7 +131,7 @@ public class InheritDocTaglet extends BaseInlineTaglet {
(InheritableTaglet) inheritableTaglet, holderTag,
isFirstSentence, true));
if (inheritedDoc.isValidInheritDocTag == false) {
- writer.configuration().message.warning(md.position(),
+ configuration.message.warning(md.position(),
"doclet.noInheritedDoc", md.name() + md.flatSignature());
} else if (inheritedDoc.inlineTags.length > 0) {
replacement = writer.commentTagsToOutput(inheritedDoc.holderTag,
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java
index 4637b92a9ca..66cdce9132f 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java
@@ -30,6 +30,9 @@ import java.lang.reflect.*;
import java.net.*;
import java.util.*;
+import javax.tools.DocumentationTool;
+import javax.tools.JavaFileManager;
+
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
@@ -48,16 +51,16 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
public class TagletManager {
/**
- * The default seperator for the simple tag option.
+ * The default separator for the simple tag option.
*/
- public static final char SIMPLE_TAGLET_OPT_SEPERATOR = ':';
+ public static final char SIMPLE_TAGLET_OPT_SEPARATOR = ':';
/**
- * The alternate seperator for simple tag options. Use this
- * with you want the default seperator to be in the name of the
+ * The alternate separator for simple tag options. Use this
+ * when you want the default separator to be in the name of the
* custom tag.
*/
- public static final String ALT_SIMPLE_TAGLET_OPT_SEPERATOR = "-";
+ public static final String ALT_SIMPLE_TAGLET_OPT_SEPARATOR = "-";
/**
* The map of custom tags.
@@ -200,18 +203,24 @@ public class TagletManager {
* @param classname the name of the class representing the custom tag.
* @param tagletPath the path to the class representing the custom tag.
*/
- public void addCustomTag(String classname, String tagletPath) {
+ public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) {
try {
Class> customTagClass = null;
// construct class loader
String cpString = null; // make sure env.class.path defaults to dot
- // do prepends to get correct ordering
- cpString = appendPath(System.getProperty("env.class.path"), cpString);
- cpString = appendPath(System.getProperty("java.class.path"), cpString);
- cpString = appendPath(tagletPath, cpString);
- URLClassLoader appClassLoader = new URLClassLoader(pathToURLs(cpString));
- customTagClass = appClassLoader.loadClass(classname);
+ ClassLoader tagClassLoader;
+ if (fileManager != null && fileManager.hasLocation(DocumentationTool.Location.TAGLET_PATH)) {
+ tagClassLoader = fileManager.getClassLoader(DocumentationTool.Location.TAGLET_PATH);
+ } else {
+ // do prepends to get correct ordering
+ cpString = appendPath(System.getProperty("env.class.path"), cpString);
+ cpString = appendPath(System.getProperty("java.class.path"), cpString);
+ cpString = appendPath(tagletPath, cpString);
+ tagClassLoader = new URLClassLoader(pathToURLs(cpString));
+ }
+
+ customTagClass = tagClassLoader.loadClass(classname);
Method meth = customTagClass.getMethod("register",
new Class>[] {java.util.Map.class});
Object[] list = customTags.values().toArray();
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java
index 2e594db8e77..4410f51ce1f 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java
@@ -46,7 +46,11 @@ public abstract class TagletWriter {
/**
* True if we only want to write the first sentence.
*/
- protected boolean isFirstSentence = false;
+ protected final boolean isFirstSentence;
+
+ protected TagletWriter(boolean isFirstSentence) {
+ this.isFirstSentence = isFirstSentence;
+ }
/**
* @return an instance of the output object.
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java
index 33781c73174..f55d99a999d 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java
@@ -25,14 +25,9 @@
package com.sun.tools.doclets.internal.toolkit.util;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -40,10 +35,6 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
-import java.util.ArrayList;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
import javax.tools.JavaFileManager.Location;
import javax.tools.StandardLocation;
@@ -61,46 +52,36 @@ import com.sun.tools.doclets.internal.toolkit.Configuration;
*
* @since 8
*/
-public class DocFile {
+public abstract class DocFile {
+
+ /** Create a DocFile for a directory. */
+ public static DocFile createFileForDirectory(Configuration configuration, String file) {
+ return DocFileFactory.getFactory(configuration).createFileForDirectory(file);
+ }
+
+ /** Create a DocFile for a file that will be opened for reading. */
+ public static DocFile createFileForInput(Configuration configuration, String file) {
+ return DocFileFactory.getFactory(configuration).createFileForInput(file);
+ }
+
+ /** Create a DocFile for a file that will be opened for writing. */
+ public static DocFile createFileForOutput(Configuration configuration, DocPath path) {
+ return DocFileFactory.getFactory(configuration).createFileForOutput(path);
+ }
- /**
- * The doclet configuration.
- * Provides access to options such as docencoding, output directory, etc.
- */
private final Configuration configuration;
/**
* The location for this file. Maybe null if the file was created without
* a location or path.
*/
- private final Location location;
+ protected final Location location;
/**
* The path relative to the (output) location. Maybe null if the file was
* created without a location or path.
*/
- private final DocPath path;
-
- /**
- * The file object itself.
- * This is temporary, until we create different subtypes of DocFile.
- */
- private final File file;
-
- /** Create a DocFile for a directory. */
- public static DocFile createFileForDirectory(Configuration configuration, String file) {
- return new DocFile(configuration, new File(file));
- }
-
- /** Create a DocFile for a file that will be opened for reading. */
- public static DocFile createFileForInput(Configuration configuration, String file) {
- return new DocFile(configuration, new File(file));
- }
-
- /** Create a DocFile for a file that will be opened for writing. */
- public static DocFile createFileForOutput(Configuration configuration, DocPath path) {
- return new DocFile(configuration, StandardLocation.CLASS_OUTPUT, path);
- }
+ protected final DocPath path;
/**
* List the directories and files found in subdirectories along the
@@ -111,85 +92,46 @@ public class DocFile {
* list files
*/
public static Iterable list(Configuration configuration, Location location, DocPath path) {
- if (location != StandardLocation.SOURCE_PATH)
- throw new IllegalArgumentException();
-
- Set files = new LinkedHashSet();
- for (String s : configuration.sourcepath.split(File.pathSeparator)) {
- if (s.isEmpty())
- continue;
- File f = new File(s);
- if (f.isDirectory()) {
- f = new File(f, path.getPath());
- if (f.exists())
- files.add(new DocFile(configuration, f));
- }
- }
- return files;
+ return DocFileFactory.getFactory(configuration).list(location, path);
}
- /** Create a DocFile for a given file. */
- private DocFile(Configuration configuration, File file) {
+ /** Create a DocFile without a location or path */
+ protected DocFile(Configuration configuration) {
this.configuration = configuration;
this.location = null;
this.path = null;
- this.file = file;
}
/** Create a DocFile for a given location and relative path. */
- private DocFile(Configuration configuration, Location location, DocPath path) {
+ protected DocFile(Configuration configuration, Location location, DocPath path) {
this.configuration = configuration;
this.location = location;
this.path = path;
- this.file = path.resolveAgainst(configuration.destDirName);
}
/** Open an input stream for the file. */
- public InputStream openInputStream() throws FileNotFoundException {
- return new BufferedInputStream(new FileInputStream(file));
- }
+ public abstract InputStream openInputStream() throws IOException;
/**
* Open an output stream for the file.
* The file must have been created with a location of
- * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path.
+ * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT}
+ * and a corresponding relative path.
*/
- public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
- if (location != StandardLocation.CLASS_OUTPUT)
- throw new IllegalStateException();
-
- createDirectoryForFile(file);
- return new BufferedOutputStream(new FileOutputStream(file));
- }
+ public abstract OutputStream openOutputStream() throws IOException, UnsupportedEncodingException;
/**
* Open an writer for the file, using the encoding (if any) given in the
* doclet configuration.
* The file must have been created with a location of
- * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path.
+ * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
*/
- public Writer openWriter() throws IOException, UnsupportedEncodingException {
- if (location != StandardLocation.CLASS_OUTPUT)
- throw new IllegalStateException();
-
- createDirectoryForFile(file);
- FileOutputStream fos = new FileOutputStream(file);
- if (configuration.docencoding == null) {
- return new BufferedWriter(new OutputStreamWriter(fos));
- } else {
- return new BufferedWriter(new OutputStreamWriter(fos, configuration.docencoding));
- }
- }
+ public abstract Writer openWriter() throws IOException, UnsupportedEncodingException;
/**
* Copy the contents of another file directly to this file.
*/
public void copyFile(DocFile fromFile) throws IOException {
- if (location != StandardLocation.CLASS_OUTPUT)
- throw new IllegalStateException();
-
- createDirectoryForFile(file);
-
InputStream input = fromFile.openInputStream();
OutputStream output = openOutputStream();
try {
@@ -215,20 +157,15 @@ public class DocFile {
* separator
*/
public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine) {
- if (location != StandardLocation.CLASS_OUTPUT)
- throw new IllegalStateException();
-
- if (file.exists() && !overwrite)
+ if (exists() && !overwrite)
return;
- createDirectoryForFile(file);
-
try {
InputStream in = Configuration.class.getResourceAsStream(resource.getPath());
if (in == null)
return;
- OutputStream out = new FileOutputStream(file);
+ OutputStream out = openOutputStream();
try {
if (!replaceNewLine) {
byte[] buf = new byte[2048];
@@ -265,68 +202,37 @@ public class DocFile {
}
/** Return true if the file can be read. */
- public boolean canRead() {
- return file.canRead();
- }
+ public abstract boolean canRead();
/** Return true if the file can be written. */
- public boolean canWrite() {
- return file.canRead();
- }
+ public abstract boolean canWrite();
/** Return true if the file exists. */
- public boolean exists() {
- return file.exists();
- }
+ public abstract boolean exists();
/** Return the base name (last component) of the file name. */
- public String getName() {
- return file.getName();
- }
+ public abstract String getName();
/** Return the file system path for this file. */
- public String getPath() {
- return file.getPath();
- }
+ public abstract String getPath();
- /** Return true is file has an absolute path name. */
- boolean isAbsolute() {
- return file.isAbsolute();
- }
+ /** Return true if file has an absolute path name. */
+ public abstract boolean isAbsolute();
- /** Return true is file identifies a directory. */
- public boolean isDirectory() {
- return file.isDirectory();
- }
+ /** Return true if file identifies a directory. */
+ public abstract boolean isDirectory();
- /** Return true is file identifies a file. */
- public boolean isFile() {
- return file.isFile();
- }
+ /** Return true if file identifies a file. */
+ public abstract boolean isFile();
/** Return true if this file is the same as another. */
- public boolean isSameFile(DocFile other) {
- try {
- return file.exists()
- && file.getCanonicalFile().equals(other.file.getCanonicalFile());
- } catch (IOException e) {
- return false;
- }
- }
+ public abstract boolean isSameFile(DocFile other);
/** If the file is a directory, list its contents. */
- public Iterable list() {
- List files = new ArrayList();
- for (File f: file.listFiles()) {
- files.add(new DocFile(configuration, f));
- }
- return files;
- }
+ public abstract Iterable list() throws IOException;
/** Create the file as a directory, including any parent directories. */
- public boolean mkdirs() {
- return file.mkdirs();
- }
+ public abstract boolean mkdirs();
/**
* Derive a new file by resolving a relative path against this file.
@@ -334,9 +240,7 @@ public class DocFile {
* If this file has a path set, the new file will have a corresponding
* new path.
*/
- public DocFile resolve(DocPath p) {
- return resolve(p.getPath());
- }
+ public abstract DocFile resolve(DocPath p);
/**
* Derive a new file by resolving a relative path against this file.
@@ -344,56 +248,12 @@ public class DocFile {
* If this file has a path set, the new file will have a corresponding
* new path.
*/
- public DocFile resolve(String p) {
- if (location == null && path == null) {
- return new DocFile(configuration, new File(file, p));
- } else {
- return new DocFile(configuration, location, path.resolve(p));
- }
- }
+ public abstract DocFile resolve(String p);
/**
* Resolve a relative file against the given output location.
- * @param locn Currently, only SOURCE_OUTPUT is supported.
+ * @param locn Currently, only
+ * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported.
*/
- public DocFile resolveAgainst(StandardLocation locn) {
- if (locn != StandardLocation.CLASS_OUTPUT)
- throw new IllegalArgumentException();
- return new DocFile(configuration,
- new File(configuration.destDirName, file.getPath()));
- }
-
- /**
- * Given a path string create all the directories in the path. For example,
- * if the path string is "java/applet", the method will create directory
- * "java" and then "java/applet" if they don't exist. The file separator
- * string "/" is platform dependent system property.
- *
- * @param path Directory path string.
- */
- private void createDirectoryForFile(File file) {
- File dir = file.getParentFile();
- if (dir == null || dir.exists() || dir.mkdirs())
- return;
-
- configuration.message.error(
- "doclet.Unable_to_create_directory_0", dir.getPath());
- throw new DocletAbortException();
- }
-
- /** Return a string to identify the contents of this object,
- * for debugging purposes.
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("DocFile[");
- if (location != null)
- sb.append("locn:").append(location).append(",");
- if (path != null)
- sb.append("path:").append(path.getPath()).append(",");
- sb.append("file:").append(file);
- sb.append("]");
- return sb.toString();
- }
+ public abstract DocFile resolveAgainst(Location locn);
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java
new file mode 100644
index 00000000000..dc5349c87bc
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 1998, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.tools.doclets.internal.toolkit.util;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+
+/**
+ * Factory for DocFile objects.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @since 1.8
+ */
+abstract class DocFileFactory {
+ private static Map factories =
+ new WeakHashMap();
+
+ /**
+ * Get the appropriate factory, based on the file manager given in the
+ * configuration.
+ */
+ static synchronized DocFileFactory getFactory(Configuration configuration) {
+ DocFileFactory f = factories.get(configuration);
+ if (f == null) {
+ JavaFileManager fm = configuration.getFileManager();
+ if (fm instanceof StandardJavaFileManager)
+ f = new StandardDocFileFactory(configuration);
+ else {
+ try {
+ Class> pathFileManagerClass =
+ Class.forName("com.sun.tools.javac.nio.PathFileManager");
+ if (pathFileManagerClass.isAssignableFrom(fm.getClass()))
+ f = new PathDocFileFactory(configuration);
+ } catch (Throwable t) {
+ throw new IllegalStateException(t);
+ }
+ }
+ factories.put(configuration, f);
+ }
+ return f;
+ }
+
+ protected Configuration configuration;
+
+ protected DocFileFactory(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ /** Create a DocFile for a directory. */
+ abstract DocFile createFileForDirectory(String file);
+
+ /** Create a DocFile for a file that will be opened for reading. */
+ abstract DocFile createFileForInput(String file);
+
+ /** Create a DocFile for a file that will be opened for writing. */
+ abstract DocFile createFileForOutput(DocPath path);
+
+ /**
+ * List the directories and files found in subdirectories along the
+ * elements of the given location.
+ * @param location currently, only {@link StandardLocation#SOURCE_PATH} is supported.
+ * @param path the subdirectory of the directories of the location for which to
+ * list files
+ */
+ abstract Iterable list(Location location, DocPath path);
+}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java
index fb7d1fa96d7..055d449a862 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java
@@ -27,7 +27,6 @@ package com.sun.tools.doclets.internal.toolkit.util;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.PackageDoc;
-import java.io.File;
/**
* Abstraction for immutable relative paths.
@@ -158,15 +157,6 @@ public class DocPath {
return new DocPath(path + "/" + p.getPath());
}
- /**
- * Get the file created by evaluating the path against a specified directory.
- */
- // Temporary: this signature should not use String for dir.
- // Eventually, this should involve javax.tools.Location.
- public File resolveAgainst(String dir) {
- return dir.isEmpty() ? new File(path) : new File(dir, path);
- }
-
/**
* Return the inverse path for this path.
* For example, if the path is a/b/c, the inverse path is ../../..
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java
index 9625be7b346..f1c2a13a30d 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java
@@ -72,6 +72,9 @@ public class DocPaths {
return DocPath.create("index-" + n + ".html");
}
+ /** The name of the default javascript file. */
+ public static final DocPath JAVASCRIPT = DocPath.create("script.js");
+
/** The name of the file for the overview frame. */
public static final DocPath OVERVIEW_FRAME = DocPath.create("overview-frame.html");
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java
index 5aa768876d7..0306f7b38c0 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java
@@ -30,7 +30,7 @@ import java.net.*;
import java.util.HashMap;
import java.util.Map;
-import javax.tools.StandardLocation;
+import javax.tools.DocumentationTool;
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
@@ -253,7 +253,7 @@ public class Extern {
throws Fault {
DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST);
if (! (file.isAbsolute() || linkoffline)){
- file = file.resolveAgainst(StandardLocation.CLASS_OUTPUT);
+ file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT);
}
try {
if (file.exists() && file.canRead()) {
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java
new file mode 100644
index 00000000000..d1211fc1c91
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.tools.doclets.internal.toolkit.util;
+
+/**
+ * Enum representing method types.
+ *
+ * @author Bhavesh Patel
+ */
+public enum MethodTypes {
+ ALL(0xffff, "All Methods", "t0", true),
+ STATIC(0x1, "Static Methods", "t1", false),
+ INSTANCE(0x2, "Instance Methods", "t2", false),
+ ABSTRACT(0x4, "Abstract Methods", "t3", false),
+ CONCRETE(0x8, "Concrete Methods", "t4", false),
+ DEPRECATED(0x10, "Deprecated Methods", "t5", false);
+
+ private final int value;
+ private final String text;
+ private final String tabId;
+ private final boolean isDefaultTab;
+
+ MethodTypes(int v, String t, String id, boolean dt) {
+ this.value = v;
+ this.text = t;
+ this.tabId = id;
+ this.isDefaultTab = dt;
+ }
+
+ public int value() {
+ return value;
+ }
+
+ public String text() {
+ return text;
+ }
+
+ public String tabId() {
+ return tabId;
+ }
+
+ public boolean isDefaultTab() {
+ return isDefaultTab;
+ }
+}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java
new file mode 100644
index 00000000000..d2ee2d639ed
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 1998, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.tools.doclets.internal.toolkit.util;
+
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.DocumentationTool;
+import javax.tools.FileObject;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+import com.sun.tools.javac.nio.PathFileManager;
+
+
+/**
+ * Implementation of DocFileFactory using a {@link PathFileManager}.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @since 1.8
+ */
+class PathDocFileFactory extends DocFileFactory {
+ private final PathFileManager fileManager;
+ private final Path destDir;
+
+ public PathDocFileFactory(Configuration configuration) {
+ super(configuration);
+ fileManager = (PathFileManager) configuration.getFileManager();
+
+ if (!configuration.destDirName.isEmpty()
+ || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) {
+ try {
+ String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName;
+ Path dir = fileManager.getDefaultFileSystem().getPath(dirName);
+ fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
+ } catch (IOException e) {
+ throw new DocletAbortException();
+ }
+ }
+
+ destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next();
+ }
+
+ public DocFile createFileForDirectory(String file) {
+ return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file));
+ }
+
+ public DocFile createFileForInput(String file) {
+ return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file));
+ }
+
+ public DocFile createFileForOutput(DocPath path) {
+ return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
+ }
+
+ @Override
+ Iterable list(Location location, DocPath path) {
+ if (location != StandardLocation.SOURCE_PATH)
+ throw new IllegalArgumentException();
+
+ Set files = new LinkedHashSet();
+ if (fileManager.hasLocation(location)) {
+ for (Path f: fileManager.getLocation(location)) {
+ if (Files.isDirectory(f)) {
+ f = f.resolve(path.getPath());
+ if (Files.exists(f))
+ files.add(new StandardDocFile(f));
+ }
+ }
+ }
+ return files;
+ }
+
+ class StandardDocFile extends DocFile {
+ private Path file;
+
+ /** Create a StandardDocFile for a given file. */
+ private StandardDocFile(Path file) {
+ super(configuration);
+ this.file = file;
+ }
+
+ /** Create a StandardDocFile for a given location and relative path. */
+ private StandardDocFile(Location location, DocPath path) {
+ super(configuration, location, path);
+ this.file = destDir.resolve(path.getPath());
+ }
+
+ /** Open an input stream for the file. */
+ public InputStream openInputStream() throws IOException {
+ JavaFileObject fo = getJavaFileObjectForInput(file);
+ return new BufferedInputStream(fo.openInputStream());
+ }
+
+ /**
+ * Open an output stream for the file.
+ * The file must have been created with a location of
+ * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+ */
+ public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
+ if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+ throw new IllegalStateException();
+
+ OutputStream out = getFileObjectForOutput(path).openOutputStream();
+ return new BufferedOutputStream(out);
+ }
+
+ /**
+ * Open an writer for the file, using the encoding (if any) given in the
+ * doclet configuration.
+ * The file must have been created with a location of
+ * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+ */
+ public Writer openWriter() throws IOException, UnsupportedEncodingException {
+ if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+ throw new IllegalStateException();
+
+ OutputStream out = getFileObjectForOutput(path).openOutputStream();
+ if (configuration.docencoding == null) {
+ return new BufferedWriter(new OutputStreamWriter(out));
+ } else {
+ return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding));
+ }
+ }
+
+ /** Return true if the file can be read. */
+ public boolean canRead() {
+ return Files.isReadable(file);
+ }
+
+ /** Return true if the file can be written. */
+ public boolean canWrite() {
+ return Files.isWritable(file);
+ }
+
+ /** Return true if the file exists. */
+ public boolean exists() {
+ return Files.exists(file);
+ }
+
+ /** Return the base name (last component) of the file name. */
+ public String getName() {
+ return file.getFileName().toString();
+ }
+
+ /** Return the file system path for this file. */
+ public String getPath() {
+ return file.toString();
+ }
+
+ /** Return true is file has an absolute path name. */
+ public boolean isAbsolute() {
+ return file.isAbsolute();
+ }
+
+ /** Return true is file identifies a directory. */
+ public boolean isDirectory() {
+ return Files.isDirectory(file);
+ }
+
+ /** Return true is file identifies a file. */
+ public boolean isFile() {
+ return Files.isRegularFile(file);
+ }
+
+ /** Return true if this file is the same as another. */
+ public boolean isSameFile(DocFile other) {
+ if (!(other instanceof StandardDocFile))
+ return false;
+
+ try {
+ return Files.isSameFile(file, ((StandardDocFile) other).file);
+ } catch (IOException e) {
+ return false;
+ }
+ }
+
+ /** If the file is a directory, list its contents. */
+ public Iterable list() throws IOException {
+ List files = new ArrayList();
+ for (Path f: Files.newDirectoryStream(file)) {
+ files.add(new StandardDocFile(f));
+ }
+ return files;
+ }
+
+ /** Create the file as a directory, including any parent directories. */
+ public boolean mkdirs() {
+ try {
+ Files.createDirectories(file);
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Derive a new file by resolving a relative path against this file.
+ * The new file will inherit the configuration and location of this file
+ * If this file has a path set, the new file will have a corresponding
+ * new path.
+ */
+ public DocFile resolve(DocPath p) {
+ return resolve(p.getPath());
+ }
+
+ /**
+ * Derive a new file by resolving a relative path against this file.
+ * The new file will inherit the configuration and location of this file
+ * If this file has a path set, the new file will have a corresponding
+ * new path.
+ */
+ public DocFile resolve(String p) {
+ if (location == null && path == null) {
+ return new StandardDocFile(file.resolve(p));
+ } else {
+ return new StandardDocFile(location, path.resolve(p));
+ }
+ }
+
+ /**
+ * Resolve a relative file against the given output location.
+ * @param locn Currently, only
+ * {@link DocumentationTool.Location.DOCUMENTATION_OUTPUT} is supported.
+ */
+ public DocFile resolveAgainst(Location locn) {
+ if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+ throw new IllegalArgumentException();
+ return new StandardDocFile(destDir.resolve(file));
+ }
+
+ /** Return a string to identify the contents of this object,
+ * for debugging purposes.
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("PathDocFile[");
+ if (location != null)
+ sb.append("locn:").append(location).append(",");
+ if (path != null)
+ sb.append("path:").append(path.getPath()).append(",");
+ sb.append("file:").append(file);
+ sb.append("]");
+ return sb.toString();
+ }
+
+ private JavaFileObject getJavaFileObjectForInput(Path file) {
+ return fileManager.getJavaFileObjects(file).iterator().next();
+ }
+
+ private FileObject getFileObjectForOutput(DocPath path) throws IOException {
+ // break the path into a package-part and the rest, by finding
+ // the position of the last '/' before an invalid character for a
+ // package name, such as the "." before an extension or the "-"
+ // in filenames like package-summary.html, doc-files or src-html.
+ String p = path.getPath();
+ int lastSep = -1;
+ for (int i = 0; i < p.length(); i++) {
+ char ch = p.charAt(i);
+ if (ch == '/') {
+ lastSep = i;
+ } else if (i == lastSep + 1 && !Character.isJavaIdentifierStart(ch)
+ || !Character.isJavaIdentifierPart(ch)) {
+ break;
+ }
+ }
+ String pkg = (lastSep == -1) ? "" : p.substring(0, lastSep);
+ String rest = p.substring(lastSep + 1);
+ return fileManager.getFileForOutput(location, pkg, rest, null);
+ }
+ }
+
+}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java
new file mode 100644
index 00000000000..e9711f5c316
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java
@@ -0,0 +1,292 @@
+/*
+ * Copyright (c) 1998, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.tools.doclets.internal.toolkit.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.DocumentationTool;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+
+/**
+ * Implementation of DocFileFactory that just uses java.io.File API,
+ * and does not use a JavaFileManager..
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @since 1.8
+ */
+class SimpleDocFileFactory extends DocFileFactory {
+
+ public SimpleDocFileFactory(Configuration configuration) {
+ super(configuration);
+ }
+
+ public DocFile createFileForDirectory(String file) {
+ return new SimpleDocFile(new File(file));
+ }
+
+ public DocFile createFileForInput(String file) {
+ return new SimpleDocFile(new File(file));
+ }
+
+ public DocFile createFileForOutput(DocPath path) {
+ return new SimpleDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
+ }
+
+ @Override
+ Iterable list(Location location, DocPath path) {
+ if (location != StandardLocation.SOURCE_PATH)
+ throw new IllegalArgumentException();
+
+ Set files = new LinkedHashSet();
+ for (String s : configuration.sourcepath.split(File.pathSeparator)) {
+ if (s.isEmpty())
+ continue;
+ File f = new File(s);
+ if (f.isDirectory()) {
+ f = new File(f, path.getPath());
+ if (f.exists())
+ files.add(new SimpleDocFile(f));
+ }
+ }
+ return files;
+ }
+
+ class SimpleDocFile extends DocFile {
+ private File file;
+
+ /** Create a DocFile for a given file. */
+ private SimpleDocFile(File file) {
+ super(configuration);
+ this.file = file;
+ }
+
+ /** Create a DocFile for a given location and relative path. */
+ private SimpleDocFile(Location location, DocPath path) {
+ super(configuration, location, path);
+ String destDirName = configuration.destDirName;
+ this.file = destDirName.isEmpty() ? new File(path.getPath())
+ : new File(destDirName, path.getPath());
+ }
+
+ /** Open an input stream for the file. */
+ public InputStream openInputStream() throws FileNotFoundException {
+ return new BufferedInputStream(new FileInputStream(file));
+ }
+
+ /**
+ * Open an output stream for the file.
+ * The file must have been created with a location of
+ * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+ */
+ public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
+ if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+ throw new IllegalStateException();
+
+ createDirectoryForFile(file);
+ return new BufferedOutputStream(new FileOutputStream(file));
+ }
+
+ /**
+ * Open an writer for the file, using the encoding (if any) given in the
+ * doclet configuration.
+ * The file must have been created with a location of
+ * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+ */
+ public Writer openWriter() throws IOException, UnsupportedEncodingException {
+ if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+ throw new IllegalStateException();
+
+ createDirectoryForFile(file);
+ FileOutputStream fos = new FileOutputStream(file);
+ if (configuration.docencoding == null) {
+ return new BufferedWriter(new OutputStreamWriter(fos));
+ } else {
+ return new BufferedWriter(new OutputStreamWriter(fos, configuration.docencoding));
+ }
+ }
+
+ /** Return true if the file can be read. */
+ public boolean canRead() {
+ return file.canRead();
+ }
+
+ /** Return true if the file can be written. */
+ public boolean canWrite() {
+ return file.canRead();
+ }
+
+ /** Return true if the file exists. */
+ public boolean exists() {
+ return file.exists();
+ }
+
+ /** Return the base name (last component) of the file name. */
+ public String getName() {
+ return file.getName();
+ }
+
+ /** Return the file system path for this file. */
+ public String getPath() {
+ return file.getPath();
+ }
+
+ /** Return true is file has an absolute path name. */
+ public boolean isAbsolute() {
+ return file.isAbsolute();
+ }
+
+ /** Return true is file identifies a directory. */
+ public boolean isDirectory() {
+ return file.isDirectory();
+ }
+
+ /** Return true is file identifies a file. */
+ public boolean isFile() {
+ return file.isFile();
+ }
+
+ /** Return true if this file is the same as another. */
+ public boolean isSameFile(DocFile other) {
+ if (!(other instanceof SimpleDocFile))
+ return false;
+
+ try {
+ return file.exists()
+ && file.getCanonicalFile().equals(((SimpleDocFile)other).file.getCanonicalFile());
+ } catch (IOException e) {
+ return false;
+ }
+ }
+
+ /** If the file is a directory, list its contents. */
+ public Iterable list() {
+ List files = new ArrayList();
+ for (File f: file.listFiles()) {
+ files.add(new SimpleDocFile(f));
+ }
+ return files;
+ }
+
+ /** Create the file as a directory, including any parent directories. */
+ public boolean mkdirs() {
+ return file.mkdirs();
+ }
+
+ /**
+ * Derive a new file by resolving a relative path against this file.
+ * The new file will inherit the configuration and location of this file
+ * If this file has a path set, the new file will have a corresponding
+ * new path.
+ */
+ public DocFile resolve(DocPath p) {
+ return resolve(p.getPath());
+ }
+
+ /**
+ * Derive a new file by resolving a relative path against this file.
+ * The new file will inherit the configuration and location of this file
+ * If this file has a path set, the new file will have a corresponding
+ * new path.
+ */
+ public DocFile resolve(String p) {
+ if (location == null && path == null) {
+ return new SimpleDocFile(new File(file, p));
+ } else {
+ return new SimpleDocFile(location, path.resolve(p));
+ }
+ }
+
+ /**
+ * Resolve a relative file against the given output location.
+ * @param locn Currently, only
+ * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported.
+ */
+ public DocFile resolveAgainst(Location locn) {
+ if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+ throw new IllegalArgumentException();
+ return new SimpleDocFile(
+ new File(configuration.destDirName, file.getPath()));
+ }
+
+ /**
+ * Given a path string create all the directories in the path. For example,
+ * if the path string is "java/applet", the method will create directory
+ * "java" and then "java/applet" if they don't exist. The file separator
+ * string "/" is platform dependent system property.
+ *
+ * @param path Directory path string.
+ */
+ private void createDirectoryForFile(File file) {
+ File dir = file.getParentFile();
+ if (dir == null || dir.exists() || dir.mkdirs())
+ return;
+
+ configuration.message.error(
+ "doclet.Unable_to_create_directory_0", dir.getPath());
+ throw new DocletAbortException();
+ }
+
+ /** Return a string to identify the contents of this object,
+ * for debugging purposes.
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("DocFile[");
+ if (location != null)
+ sb.append("locn:").append(location).append(",");
+ if (path != null)
+ sb.append("path:").append(path.getPath()).append(",");
+ sb.append("file:").append(file);
+ sb.append("]");
+ return sb.toString();
+ }
+
+ }
+}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java
new file mode 100644
index 00000000000..1f7d20c1126
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java
@@ -0,0 +1,322 @@
+/*
+ * Copyright (c) 1998, 2012, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 com.sun.tools.doclets.internal.toolkit.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.DocumentationTool;
+import javax.tools.FileObject;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+import com.sun.tools.javac.util.Assert;
+
+/**
+ * Implementation of DocFileFactory using a {@link StandardJavaFileManager}.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @since 1.8
+ */
+class StandardDocFileFactory extends DocFileFactory {
+ private final StandardJavaFileManager fileManager;
+ private File destDir;
+
+ public StandardDocFileFactory(Configuration configuration) {
+ super(configuration);
+ fileManager = (StandardJavaFileManager) configuration.getFileManager();
+ }
+
+ private File getDestDir() {
+ if (destDir == null) {
+ if (!configuration.destDirName.isEmpty()
+ || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) {
+ try {
+ String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName;
+ File dir = new File(dirName);
+ fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
+ } catch (IOException e) {
+ throw new DocletAbortException();
+ }
+ }
+
+ destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next();
+ }
+ return destDir;
+ }
+
+ public DocFile createFileForDirectory(String file) {
+ return new StandardDocFile(new File(file));
+ }
+
+ public DocFile createFileForInput(String file) {
+ return new StandardDocFile(new File(file));
+ }
+
+ public DocFile createFileForOutput(DocPath path) {
+ return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
+ }
+
+ @Override
+ Iterable list(Location location, DocPath path) {
+ if (location != StandardLocation.SOURCE_PATH)
+ throw new IllegalArgumentException();
+
+ Set files = new LinkedHashSet();
+ Location l = fileManager.hasLocation(StandardLocation.SOURCE_PATH)
+ ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;
+ for (File f: fileManager.getLocation(l)) {
+ if (f.isDirectory()) {
+ f = new File(f, path.getPath());
+ if (f.exists())
+ files.add(new StandardDocFile(f));
+ }
+ }
+ return files;
+ }
+
+ private static File newFile(File dir, String path) {
+ return (dir == null) ? new File(path) : new File(dir, path);
+ }
+
+ class StandardDocFile extends DocFile {
+ private File file;
+
+
+ /** Create a StandardDocFile for a given file. */
+ private StandardDocFile(File file) {
+ super(configuration);
+ this.file = file;
+ }
+
+ /** Create a StandardDocFile for a given location and relative path. */
+ private StandardDocFile(Location location, DocPath path) {
+ super(configuration, location, path);
+ Assert.check(location == DocumentationTool.Location.DOCUMENTATION_OUTPUT);
+ this.file = newFile(getDestDir(), path.getPath());
+ }
+
+ /** Open an input stream for the file. */
+ public InputStream openInputStream() throws IOException {
+ JavaFileObject fo = getJavaFileObjectForInput(file);
+ return new BufferedInputStream(fo.openInputStream());
+ }
+
+ /**
+ * Open an output stream for the file.
+ * The file must have been created with a location of
+ * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+ */
+ public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
+ if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+ throw new IllegalStateException();
+
+ OutputStream out = getFileObjectForOutput(path).openOutputStream();
+ return new BufferedOutputStream(out);
+ }
+
+ /**
+ * Open an writer for the file, using the encoding (if any) given in the
+ * doclet configuration.
+ * The file must have been created with a location of
+ * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+ */
+ public Writer openWriter() throws IOException, UnsupportedEncodingException {
+ if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+ throw new IllegalStateException();
+
+ OutputStream out = getFileObjectForOutput(path).openOutputStream();
+ if (configuration.docencoding == null) {
+ return new BufferedWriter(new OutputStreamWriter(out));
+ } else {
+ return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding));
+ }
+ }
+
+ /** Return true if the file can be read. */
+ public boolean canRead() {
+ return file.canRead();
+ }
+
+ /** Return true if the file can be written. */
+ public boolean canWrite() {
+ return file.canWrite();
+ }
+
+ /** Return true if the file exists. */
+ public boolean exists() {
+ return file.exists();
+ }
+
+ /** Return the base name (last component) of the file name. */
+ public String getName() {
+ return file.getName();
+ }
+
+ /** Return the file system path for this file. */
+ public String getPath() {
+ return file.getPath();
+ }
+
+ /** Return true is file has an absolute path name. */
+ public boolean isAbsolute() {
+ return file.isAbsolute();
+ }
+
+ /** Return true is file identifies a directory. */
+ public boolean isDirectory() {
+ return file.isDirectory();
+ }
+
+ /** Return true is file identifies a file. */
+ public boolean isFile() {
+ return file.isFile();
+ }
+
+ /** Return true if this file is the same as another. */
+ public boolean isSameFile(DocFile other) {
+ if (!(other instanceof StandardDocFile))
+ return false;
+
+ try {
+ return file.exists()
+ && file.getCanonicalFile().equals(((StandardDocFile) other).file.getCanonicalFile());
+ } catch (IOException e) {
+ return false;
+ }
+ }
+
+ /** If the file is a directory, list its contents. */
+ public Iterable list() {
+ List files = new ArrayList();
+ for (File f: file.listFiles()) {
+ files.add(new StandardDocFile(f));
+ }
+ return files;
+ }
+
+ /** Create the file as a directory, including any parent directories. */
+ public boolean mkdirs() {
+ return file.mkdirs();
+ }
+
+ /**
+ * Derive a new file by resolving a relative path against this file.
+ * The new file will inherit the configuration and location of this file
+ * If this file has a path set, the new file will have a corresponding
+ * new path.
+ */
+ public DocFile resolve(DocPath p) {
+ return resolve(p.getPath());
+ }
+
+ /**
+ * Derive a new file by resolving a relative path against this file.
+ * The new file will inherit the configuration and location of this file
+ * If this file has a path set, the new file will have a corresponding
+ * new path.
+ */
+ public DocFile resolve(String p) {
+ if (location == null && path == null) {
+ return new StandardDocFile(new File(file, p));
+ } else {
+ return new StandardDocFile(location, path.resolve(p));
+ }
+ }
+
+ /**
+ * Resolve a relative file against the given output location.
+ * @param locn Currently, only
+ * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported.
+ */
+ public DocFile resolveAgainst(Location locn) {
+ if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+ throw new IllegalArgumentException();
+ return new StandardDocFile(newFile(getDestDir(), file.getPath()));
+ }
+
+ /** Return a string to identify the contents of this object,
+ * for debugging purposes.
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("StandardDocFile[");
+ if (location != null)
+ sb.append("locn:").append(location).append(",");
+ if (path != null)
+ sb.append("path:").append(path.getPath()).append(",");
+ sb.append("file:").append(file);
+ sb.append("]");
+ return sb.toString();
+ }
+
+ private JavaFileObject getJavaFileObjectForInput(File file) {
+ return fileManager.getJavaFileObjects(file).iterator().next();
+ }
+
+ private FileObject getFileObjectForOutput(DocPath path) throws IOException {
+ // break the path into a package-part and the rest, by finding
+ // the position of the last '/' before an invalid character for a
+ // package name, such as the "." before an extension or the "-"
+ // in filenames like package-summary.html, doc-files or src-html.
+ String p = path.getPath();
+ int lastSep = -1;
+ for (int i = 0; i < p.length(); i++) {
+ char ch = p.charAt(i);
+ if (ch == '/') {
+ lastSep = i;
+ } else if (i == lastSep + 1 && !Character.isJavaIdentifierStart(ch)
+ || !Character.isJavaIdentifierPart(ch)) {
+ break;
+ }
+ }
+ String pkg = (lastSep == -1) ? "" : p.substring(0, lastSep);
+ String rest = p.substring(lastSep + 1);
+ return fileManager.getFileForOutput(location, pkg, rest, null);
+ }
+ }
+}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
index 36c141aeba7..045d73e8671 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
@@ -45,13 +45,6 @@ import javax.tools.StandardLocation;
*/
public class Util {
- /**
- * A mapping between characters and their
- * corresponding HTML escape character.
- */
- public static final String[][] HTML_ESCAPE_CHARS =
- {{"&", "&"}, {"<", "<"}, {">", ">"}};
-
/**
* Return array of class members whose documentation is to be generated.
* If the member is deprecated do not include such a member in the
@@ -424,18 +417,44 @@ public class Util {
* return the result.
*
* @param s The string to check.
- * @return the original string with all of the HTML characters
- * escaped.
- *
- * @see #HTML_ESCAPE_CHARS
+ * @return the original string with all of the HTML characters escaped.
*/
public static String escapeHtmlChars(String s) {
- String result = s;
- for (int i = 0; i < HTML_ESCAPE_CHARS.length; i++) {
- result = Util.replaceText(result,
- HTML_ESCAPE_CHARS[i][0], HTML_ESCAPE_CHARS[i][1]);
+ for (int i = 0; i < s.length(); i++) {
+ char ch = s.charAt(i);
+ switch (ch) {
+ // only start building a new string if we need to
+ case '<': case '>': case '&':
+ StringBuilder sb = new StringBuilder(s.substring(0, i));
+ for ( ; i < s.length(); i++) {
+ ch = s.charAt(i);
+ switch (ch) {
+ case '<': sb.append("<"); break;
+ case '>': sb.append(">"); break;
+ case '&': sb.append("&"); break;
+ default: sb.append(ch); break;
+ }
+ }
+ return sb.toString();
+ }
+ }
+ return s;
+ }
+
+ /**
+ * Escape all special html characters in a string buffer.
+ *
+ * @param sb The string buffer to update
+ */
+ public static void escapeHtmlChars(StringBuilder sb) {
+ // scan backwards, replacing characters as needed.
+ for (int i = sb.length() - 1; i >= 0; i--) {
+ switch (sb.charAt(i)) {
+ case '<': sb.replace(i, i+1, "<"); break;
+ case '>': sb.replace(i, i+1, ">"); break;
+ case '&': sb.replace(i, i+1, "&"); break;
+ }
}
- return result;
}
/**
@@ -579,22 +598,21 @@ public class Util {
}
/**
- * Given a string, replace all tabs with the appropriate
- * number of spaces.
- * @param tabLength the length of each tab.
- * @param s the String to scan.
+ * Replace all tabs with the appropriate number of spaces.
+ * @param configuration the doclet configuration defining the setting for the
+ * tab length.
+ * @param sb the StringBuilder in which to replace the tabs
*/
- public static void replaceTabs(int tabLength, StringBuilder s) {
- if (whitespace == null || whitespace.length() < tabLength)
- whitespace = String.format("%" + tabLength + "s", " ");
+ public static void replaceTabs(Configuration configuration, StringBuilder sb) {
+ int tabLength = configuration.sourcetab;
+ String whitespace = configuration.tabSpaces;
int index = 0;
- while ((index = s.indexOf("\t", index)) != -1) {
+ while ((index = sb.indexOf("\t", index)) != -1) {
int spaceCount = tabLength - index % tabLength;
- s.replace(index, index+1, whitespace.substring(0, spaceCount));
+ sb.replace(index, index+1, whitespace.substring(0, spaceCount));
index += spaceCount;
}
}
- private static String whitespace;
/**
* The documentation for values() and valueOf() in Enums are set by the
diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java b/langtools/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java
index e485804e124..38cff74c8ca 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java
@@ -136,6 +136,14 @@ public class BasicJavacTask extends JavacTask {
throw new IllegalStateException();
}
+ /**
+ * For internal use only. This method will be
+ * removed without warning.
+ */
+ public Context getContext() {
+ return context;
+ }
+
/**
* For internal use only. This method will be
* removed without warning.
diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java b/langtools/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java
index 8726ffe867e..a4dddf8f909 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java
@@ -149,7 +149,7 @@ public class ClientCodeWrapper {
return fo;
}
- DiagnosticListener wrap(DiagnosticListener dl) {
+ public DiagnosticListener wrap(DiagnosticListener dl) {
if (isTrusted(dl))
return dl;
return new WrappedDiagnosticListener(dl);
diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
index a9661c77727..4cc7075f310 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
@@ -74,7 +74,7 @@ public class JavacTaskImpl extends BasicJavacTask {
private List fileObjects;
private Map notYetEntered;
private ListBuffer> genList;
- private AtomicBoolean used = new AtomicBoolean();
+ private final AtomicBoolean used = new AtomicBoolean();
private Iterable extends Processor> processors;
private Main.Result result = null;
@@ -99,11 +99,11 @@ public class JavacTaskImpl extends BasicJavacTask {
}
JavacTaskImpl(Main compilerMain,
- Iterable flags,
+ Iterable args,
Context context,
Iterable classes,
Iterable extends JavaFileObject> fileObjects) {
- this(compilerMain, toArray(flags), toArray(classes), context, toList(fileObjects));
+ this(compilerMain, toArray(args), toArray(classes), context, toList(fileObjects));
}
static private String[] toArray(Iterable iter) {
@@ -485,22 +485,6 @@ public class JavacTaskImpl extends BasicJavacTask {
abstract void process(Env env);
}
- /**
- * For internal use only. This method will be
- * removed without warning.
- */
- public Context getContext() {
- return context;
- }
-
- /**
- * For internal use only. This method will be
- * removed without warning.
- */
- public void updateContext(Context newContext) {
- context = newContext;
- }
-
/**
* For internal use only. This method will be
* removed without warning.
diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
index 174b3ffa971..8a7db1f181c 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
@@ -26,6 +26,8 @@
package com.sun.tools.javac.api;
import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
@@ -40,19 +42,31 @@ import javax.tools.Diagnostic;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.ReferenceTree;
import com.sun.source.tree.CatchTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.Scope;
import com.sun.source.tree.Tree;
+import com.sun.source.util.DocTrees;
import com.sun.source.util.JavacTask;
import com.sun.source.util.SourcePositions;
import com.sun.source.util.TreePath;
-import com.sun.source.util.Trees;
import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Kinds;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.MethodSymbol;
+import com.sun.tools.javac.code.Symbol.PackageSymbol;
import com.sun.tools.javac.code.Symbol.TypeSymbol;
+import com.sun.tools.javac.code.Symbol.VarSymbol;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.ArrayType;
+import com.sun.tools.javac.code.Type.ClassType;
+import com.sun.tools.javac.code.Type.ErrorType;
import com.sun.tools.javac.code.Type.UnionClassType;
+import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.code.Types.TypeRelation;
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Enter;
@@ -61,6 +75,9 @@ import com.sun.tools.javac.comp.MemberEnter;
import com.sun.tools.javac.comp.Resolve;
import com.sun.tools.javac.model.JavacElements;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.tree.DCTree;
+import com.sun.tools.javac.tree.DCTree.DCDocComment;
+import com.sun.tools.javac.tree.DCTree.DCReference;
import com.sun.tools.javac.tree.EndPosTable;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.*;
@@ -71,8 +88,12 @@ import com.sun.tools.javac.util.Assert;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.JCDiagnostic;
import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
import com.sun.tools.javac.util.Pair;
+import static com.sun.tools.javac.code.TypeTag.*;
/**
* Provides an implementation of Trees.
@@ -84,7 +105,7 @@ import com.sun.tools.javac.util.Pair;
*
* @author Peter von der Ahé
*/
-public class JavacTrees extends Trees {
+public class JavacTrees extends DocTrees {
// in a world of a single context per compilation, these would all be final
private Resolve resolve;
@@ -95,12 +116,14 @@ public class JavacTrees extends Trees {
private TreeMaker treeMaker;
private JavacElements elements;
private JavacTaskImpl javacTaskImpl;
+ private Names names;
+ private Types types;
// called reflectively from Trees.instance(CompilationTask task)
public static JavacTrees instance(JavaCompiler.CompilationTask task) {
- if (!(task instanceof JavacTaskImpl))
+ if (!(task instanceof BasicJavacTask))
throw new IllegalArgumentException();
- return instance(((JavacTaskImpl)task).getContext());
+ return instance(((BasicJavacTask)task).getContext());
}
// called reflectively from Trees.instance(ProcessingEnvironment env)
@@ -134,6 +157,8 @@ public class JavacTrees extends Trees {
resolve = Resolve.instance(context);
treeMaker = TreeMaker.instance(context);
memberEnter = MemberEnter.instance(context);
+ names = Names.instance(context);
+ types = Types.instance(context);
JavacTask t = context.get(JavacTask.class);
if (t instanceof JavacTaskImpl)
@@ -229,6 +254,324 @@ public class JavacTrees extends Trees {
return sym;
}
+ @Override
+ public Element getElement(TreePath path, ReferenceTree reference) {
+ if (!(reference instanceof DCReference))
+ return null;
+ DCReference ref = (DCReference) reference;
+
+ Env env = getAttrContext(path);
+
+ Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
+ new Log.DeferredDiagnosticHandler(log);
+ try {
+ final ClassSymbol tsym;
+ final Name memberName;
+ if (ref.qualifierExpression == null) {
+ tsym = env.enclClass.sym;
+ memberName = ref.memberName;
+ } else {
+ // See if the qualifierExpression is a type or package name.
+ // javac does not provide the exact method required, so
+ // we first check if qualifierExpression identifies a type,
+ // and if not, then we check to see if it identifies a package.
+ Type t = attr.attribType(ref.qualifierExpression, env);
+ if (t.isErroneous()) {
+ if (ref.memberName == null) {
+ // Attr/Resolve assume packages exist and create symbols as needed
+ // so use getPackageElement to restrict search to existing packages
+ PackageSymbol pck = elements.getPackageElement(ref.qualifierExpression.toString());
+ if (pck != null) {
+ return pck;
+ } else if (ref.qualifierExpression.hasTag(JCTree.Tag.IDENT)) {
+ // fixup: allow "identifier" instead of "#identifier"
+ // for compatibility with javadoc
+ tsym = env.enclClass.sym;
+ memberName = ((JCIdent) ref.qualifierExpression).name;
+ } else
+ return null;
+ } else {
+ return null;
+ }
+ } else {
+ tsym = (ClassSymbol) t.tsym;
+ memberName = ref.memberName;
+ }
+ }
+
+ if (memberName == null)
+ return tsym;
+
+ final List paramTypes;
+ if (ref.paramTypes == null)
+ paramTypes = null;
+ else {
+ ListBuffer lb = new ListBuffer();
+ for (List l = ref.paramTypes; l.nonEmpty(); l = l.tail) {
+ JCTree tree = l.head;
+ Type t = attr.attribType(tree, env);
+ lb.add(t);
+ }
+ paramTypes = lb.toList();
+ }
+
+ Symbol msym = (memberName == tsym.name)
+ ? findConstructor(tsym, paramTypes)
+ : findMethod(tsym, memberName, paramTypes);
+ if (paramTypes != null) {
+ // explicit (possibly empty) arg list given, so cannot be a field
+ return msym;
+ }
+
+ VarSymbol vsym = (ref.paramTypes != null) ? null : findField(tsym, memberName);
+ // prefer a field over a method with no parameters
+ if (vsym != null &&
+ (msym == null ||
+ types.isSubtypeUnchecked(vsym.enclClass().asType(), msym.enclClass().asType()))) {
+ return vsym;
+ } else {
+ return msym;
+ }
+ } finally {
+ log.popDiagnosticHandler(deferredDiagnosticHandler);
+ }
+ }
+
+ /** @see com.sun.tools.javadoc.ClassDocImpl#findField */
+ private VarSymbol findField(ClassSymbol tsym, Name fieldName) {
+ return searchField(tsym, fieldName, new HashSet());
+ }
+
+ /** @see com.sun.tools.javadoc.ClassDocImpl#searchField */
+ private VarSymbol searchField(ClassSymbol tsym, Name fieldName, Set searched) {
+ if (searched.contains(tsym)) {
+ return null;
+ }
+ searched.add(tsym);
+
+ for (com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(fieldName);
+ e.scope != null; e = e.next()) {
+ if (e.sym.kind == Kinds.VAR) {
+ return (VarSymbol)e.sym;
+ }
+ }
+
+ //### If we found a VarSymbol above, but which did not pass
+ //### the modifier filter, we should return failure here!
+
+ ClassSymbol encl = tsym.owner.enclClass();
+ if (encl != null) {
+ VarSymbol vsym = searchField(encl, fieldName, searched);
+ if (vsym != null) {
+ return vsym;
+ }
+ }
+
+ // search superclass
+ Type superclass = tsym.getSuperclass();
+ if (superclass.tsym != null) {
+ VarSymbol vsym = searchField((ClassSymbol) superclass.tsym, fieldName, searched);
+ if (vsym != null) {
+ return vsym;
+ }
+ }
+
+ // search interfaces
+ List intfs = tsym.getInterfaces();
+ for (List l = intfs; l.nonEmpty(); l = l.tail) {
+ Type intf = l.head;
+ if (intf.isErroneous()) continue;
+ VarSymbol vsym = searchField((ClassSymbol) intf.tsym, fieldName, searched);
+ if (vsym != null) {
+ return vsym;
+ }
+ }
+
+ return null;
+ }
+
+ /** @see com.sun.tools.javadoc.ClassDocImpl#findConstructor */
+ MethodSymbol findConstructor(ClassSymbol tsym, List paramTypes) {
+ for (com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(names.init);
+ e.scope != null; e = e.next()) {
+ if (e.sym.kind == Kinds.MTH) {
+ if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) {
+ return (MethodSymbol) e.sym;
+ }
+ }
+ }
+ return null;
+ }
+
+ /** @see com.sun.tools.javadoc.ClassDocImpl#findMethod */
+ private MethodSymbol findMethod(ClassSymbol tsym, Name methodName, List paramTypes) {
+ return searchMethod(tsym, methodName, paramTypes, new HashSet());
+ }
+
+ /** @see com.sun.tools.javadoc.ClassDocImpl#searchMethod */
+ private MethodSymbol searchMethod(ClassSymbol tsym, Name methodName,
+ List paramTypes, Set searched) {
+ //### Note that this search is not necessarily what the compiler would do!
+
+ // do not match constructors
+ if (methodName == names.init)
+ return null;
+
+ if (searched.contains(tsym))
+ return null;
+ searched.add(tsym);
+
+ // search current class
+ com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(methodName);
+
+ //### Using modifier filter here isn't really correct,
+ //### but emulates the old behavior. Instead, we should
+ //### apply the normal rules of visibility and inheritance.
+
+ if (paramTypes == null) {
+ // If no parameters specified, we are allowed to return
+ // any method with a matching name. In practice, the old
+ // code returned the first method, which is now the last!
+ // In order to provide textually identical results, we
+ // attempt to emulate the old behavior.
+ MethodSymbol lastFound = null;
+ for (; e.scope != null; e = e.next()) {
+ if (e.sym.kind == Kinds.MTH) {
+ if (e.sym.name == methodName) {
+ lastFound = (MethodSymbol)e.sym;
+ }
+ }
+ }
+ if (lastFound != null) {
+ return lastFound;
+ }
+ } else {
+ for (; e.scope != null; e = e.next()) {
+ if (e.sym != null &&
+ e.sym.kind == Kinds.MTH) {
+ if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) {
+ return (MethodSymbol) e.sym;
+ }
+ }
+ }
+ }
+
+ //### If we found a MethodSymbol above, but which did not pass
+ //### the modifier filter, we should return failure here!
+
+ // search superclass
+ Type superclass = tsym.getSuperclass();
+ if (superclass.tsym != null) {
+ MethodSymbol msym = searchMethod((ClassSymbol) superclass.tsym, methodName, paramTypes, searched);
+ if (msym != null) {
+ return msym;
+ }
+ }
+
+ // search interfaces
+ List intfs = tsym.getInterfaces();
+ for (List l = intfs; l.nonEmpty(); l = l.tail) {
+ Type intf = l.head;
+ if (intf.isErroneous()) continue;
+ MethodSymbol msym = searchMethod((ClassSymbol) intf.tsym, methodName, paramTypes, searched);
+ if (msym != null) {
+ return msym;
+ }
+ }
+
+ // search enclosing class
+ ClassSymbol encl = tsym.owner.enclClass();
+ if (encl != null) {
+ MethodSymbol msym = searchMethod(encl, methodName, paramTypes, searched);
+ if (msym != null) {
+ return msym;
+ }
+ }
+
+ return null;
+ }
+
+ /** @see com.sun.tools.javadoc.ClassDocImpl */
+ private boolean hasParameterTypes(MethodSymbol method, List paramTypes) {
+ if (paramTypes == null)
+ return true;
+
+ if (method.params().size() != paramTypes.size())
+ return false;
+
+ List methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes();
+
+ return (Type.isErroneous(paramTypes))
+ ? fuzzyMatch(paramTypes, methodParamTypes)
+ : types.isSameTypes(paramTypes, methodParamTypes);
+ }
+
+ boolean fuzzyMatch(List paramTypes, List methodParamTypes) {
+ List l1 = paramTypes;
+ List l2 = methodParamTypes;
+ while (l1.nonEmpty()) {
+ if (!fuzzyMatch(l1.head, l2.head))
+ return false;
+ l1 = l1.tail;
+ l2 = l2.tail;
+ }
+ return true;
+ }
+
+ boolean fuzzyMatch(Type paramType, Type methodParamType) {
+ Boolean b = fuzzyMatcher.visit(paramType, methodParamType);
+ return (b == Boolean.TRUE);
+ }
+
+ TypeRelation fuzzyMatcher = new TypeRelation() {
+ @Override
+ public Boolean visitType(Type t, Type s) {
+ if (t == s)
+ return true;
+
+ if (s.isPartial())
+ return visit(s, t);
+
+ switch (t.getTag()) {
+ case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT:
+ case DOUBLE: case BOOLEAN: case VOID: case BOT: case NONE:
+ return t.getTag() == s.getTag();
+
+ default:
+ throw new AssertionError("fuzzyMatcher " + t.getTag());
+ }
+ }
+
+ @Override
+ public Boolean visitArrayType(ArrayType t, Type s) {
+ if (t == s)
+ return true;
+
+ if (s.isPartial())
+ return visit(s, t);
+
+ return s.getTag() == ARRAY
+ && visit(t.elemtype, types.elemtype(s));
+ }
+
+ @Override
+ public Boolean visitClassType(ClassType t, Type s) {
+ if (t == s)
+ return true;
+
+ if (s.isPartial())
+ return visit(s, t);
+
+ return t.tsym == s.tsym;
+ }
+
+ @Override
+ public Boolean visitErrorType(ErrorType t, Type s) {
+ return s.getTag() == CLASS
+ && t.tsym.name == ((ClassType) s).tsym.name;
+ }
+ };
+
public TypeMirror getTypeMirror(TreePath path) {
Tree t = path.getLeaf();
return ((JCTree)t).type;
@@ -250,6 +593,18 @@ public class JavacTrees extends Trees {
return null;
}
+ public DocCommentTree getDocCommentTree(TreePath path) {
+ CompilationUnitTree t = path.getCompilationUnit();
+ Tree leaf = path.getLeaf();
+ if (t instanceof JCTree.JCCompilationUnit && leaf instanceof JCTree) {
+ JCCompilationUnit cu = (JCCompilationUnit) t;
+ if (cu.docComments != null) {
+ return cu.docComments.getCommentTree((JCTree) leaf);
+ }
+ }
+ return null;
+ }
+
public boolean isAccessible(Scope scope, TypeElement type) {
if (scope instanceof JavacScope && type instanceof ClassSymbol) {
Env env = ((JavacScope) scope).env;
@@ -418,14 +773,27 @@ public class JavacTrees extends Trees {
public void printMessage(Diagnostic.Kind kind, CharSequence msg,
com.sun.source.tree.Tree t,
com.sun.source.tree.CompilationUnitTree root) {
+ printMessage(kind, msg, ((JCTree) t).pos(), root);
+ }
+
+ public void printMessage(Diagnostic.Kind kind, CharSequence msg,
+ com.sun.source.doctree.DocTree t,
+ com.sun.source.doctree.DocCommentTree c,
+ com.sun.source.tree.CompilationUnitTree root) {
+ printMessage(kind, msg, ((DCTree) t).pos((DCDocComment) c), root);
+ }
+
+ private void printMessage(Diagnostic.Kind kind, CharSequence msg,
+ JCDiagnostic.DiagnosticPosition pos,
+ com.sun.source.tree.CompilationUnitTree root) {
JavaFileObject oldSource = null;
JavaFileObject newSource = null;
- JCDiagnostic.DiagnosticPosition pos = null;
newSource = root.getSourceFile();
- if (newSource != null) {
+ if (newSource == null) {
+ pos = null;
+ } else {
oldSource = log.useSource(newSource);
- pos = ((JCTree) t).pos();
}
try {
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java
index 1a71cab46ee..36b669b6337 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java
@@ -67,6 +67,7 @@ public class Flags {
if ((mask&NATIVE) != 0) flags.add(Flag.NATIVE);
if ((mask&INTERFACE) != 0) flags.add(Flag.INTERFACE);
if ((mask&ABSTRACT) != 0) flags.add(Flag.ABSTRACT);
+ if ((mask&DEFAULT) != 0) flags.add(Flag.DEFAULT);
if ((mask&STRICTFP) != 0) flags.add(Flag.STRICTFP);
if ((mask&BRIDGE) != 0) flags.add(Flag.BRIDGE);
if ((mask&SYNTHETIC) != 0) flags.add(Flag.SYNTHETIC);
@@ -261,7 +262,7 @@ public class Flags {
* Flag that marks class as auxiliary, ie a non-public class following
* the public class in a source file, that could block implicit compilation.
*/
- public static final long AUXILIARY = 1L<<43;
+ public static final long AUXILIARY = 1L<<44;
/** Modifier masks.
*/
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java
index 09b38d68587..2248f47e0e0 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java
@@ -438,7 +438,8 @@ public abstract class Symbol implements Element {
}
public Set getModifiers() {
- return Flags.asModifierSet(flags());
+ long flags = flags();
+ return Flags.asModifierSet((flags & DEFAULT) != 0 ? flags & ~ABSTRACT : flags);
}
public Name getSimpleName() {
@@ -475,6 +476,7 @@ public abstract class Symbol implements Element {
public String toString() { return other.toString(); }
public Symbol location() { return other.location(); }
public Symbol location(Type site, Types types) { return other.location(site, types); }
+ public Symbol baseSymbol() { return other; }
public Type erasure(Types types) { return other.erasure(types); }
public Type externalType(Types types) { return other.externalType(types); }
public boolean isLocal() { return other.isLocal(); }
@@ -1192,7 +1194,7 @@ public abstract class Symbol implements Element {
// check for an inherited implementation
if ((flags() & ABSTRACT) != 0 ||
- (other.flags() & ABSTRACT) == 0 ||
+ ((other.flags() & ABSTRACT) == 0 && (other.flags() & DEFAULT) == 0) ||
!other.isOverridableIn(origin) ||
!this.isMemberOf(origin, types))
return false;
@@ -1202,7 +1204,7 @@ public abstract class Symbol implements Element {
Type ot = types.memberType(origin.type, other);
return
types.isSubSignature(mt, ot) &&
- (!checkResult || types.resultSubtype(mt, ot, Warner.noWarnings));
+ (!checkResult || types.resultSubtype(mt, ot, types.noWarnings));
}
private boolean isOverridableIn(TypeSymbol origin) {
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java
index 3002a9dfc2d..00d6b69db94 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java
@@ -130,6 +130,7 @@ public class Symtab {
public final Type methodHandleLookupType;
public final Type methodTypeType;
public final Type nativeHeaderType;
+ public final Type nativeHeaderType_old;
public final Type throwableType;
public final Type errorType;
public final Type interruptedExceptionType;
@@ -505,7 +506,8 @@ public class Symtab {
List.of(exceptionType), methodClass),
autoCloseableType.tsym);
trustMeType = enterClass("java.lang.SafeVarargs");
- nativeHeaderType = enterClass("javax.tools.annotation.GenerateNativeHeader");
+ nativeHeaderType = enterClass("java.lang.annotation.Native");
+ nativeHeaderType_old = enterClass("javax.tools.annotation.GenerateNativeHeader");
lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
synthesizeEmptyInterfaceIfMissing(autoCloseableType);
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java
index c8b6b258462..22063dcbf16 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java
@@ -83,6 +83,8 @@ public class Types {
final Name capturedName;
private final FunctionDescriptorLookupError functionDescriptorLookupError;
+ public final Warner noWarnings;
+
//
public static Types instance(Context context) {
Types instance = context.get(typesKey);
@@ -106,6 +108,7 @@ public class Types {
messages = JavacMessages.instance(context);
diags = JCDiagnostic.Factory.instance(context);
functionDescriptorLookupError = new FunctionDescriptorLookupError();
+ noWarnings = new Warner(null);
}
//
@@ -296,7 +299,7 @@ public class Types {
* convertions to s?
*/
public boolean isConvertible(Type t, Type s) {
- return isConvertible(t, s, Warner.noWarnings);
+ return isConvertible(t, s, noWarnings);
}
//
@@ -394,15 +397,10 @@ public class Types {
@Override
public boolean accepts(Symbol sym) {
- return sym.kind == Kinds.MTH &&
- (sym.flags() & ABSTRACT) != 0 &&
- !overridesObjectMethod(origin, sym) &&
- notOverridden(sym);
- }
-
- private boolean notOverridden(Symbol msym) {
- Symbol impl = ((MethodSymbol)msym).implementation(origin, Types.this, false);
- return impl == null || (impl.flags() & ABSTRACT) != 0;
+ return sym.kind == Kinds.MTH &&
+ (sym.flags() & (ABSTRACT | DEFAULT)) == ABSTRACT &&
+ !overridesObjectMethod(origin, sym) &&
+ (interfaceCandidates(origin.type, (MethodSymbol)sym).head.flags() & DEFAULT) == 0;
}
};
@@ -593,7 +591,7 @@ public class Types {
* Is t an unchecked subtype of s?
*/
public boolean isSubtypeUnchecked(Type t, Type s) {
- return isSubtypeUnchecked(t, s, Warner.noWarnings);
+ return isSubtypeUnchecked(t, s, noWarnings);
}
/**
* Is t an unchecked subtype of s?
@@ -1196,7 +1194,7 @@ public class Types {
//
public boolean isCastable(Type t, Type s) {
- return isCastable(t, s, Warner.noWarnings);
+ return isCastable(t, s, noWarnings);
}
/**
@@ -1259,7 +1257,7 @@ public class Types {
return true;
if (s.tag == TYPEVAR) {
- if (isCastable(t, s.getUpperBound(), Warner.noWarnings)) {
+ if (isCastable(t, s.getUpperBound(), noWarnings)) {
warnStack.head.warn(LintCategory.UNCHECKED);
return true;
} else {
@@ -1269,7 +1267,7 @@ public class Types {
if (t.isCompound()) {
Warner oldWarner = warnStack.head;
- warnStack.head = Warner.noWarnings;
+ warnStack.head = noWarnings;
if (!visit(supertype(t), s))
return false;
for (Type intf : interfaces(t)) {
@@ -1368,7 +1366,7 @@ public class Types {
case BOT:
return true;
case TYPEVAR:
- if (isCastable(s, t, Warner.noWarnings)) {
+ if (isCastable(s, t, noWarnings)) {
warnStack.head.warn(LintCategory.UNCHECKED);
return true;
} else {
@@ -1396,7 +1394,7 @@ public class Types {
case TYPEVAR:
if (isSubtype(t, s)) {
return true;
- } else if (isCastable(t.bound, s, Warner.noWarnings)) {
+ } else if (isCastable(t.bound, s, noWarnings)) {
warnStack.head.warn(LintCategory.UNCHECKED);
return true;
} else {
@@ -1535,7 +1533,7 @@ public class Types {
TypeVar tv = (TypeVar) t;
return !isCastable(tv.bound,
relaxBound(s),
- Warner.noWarnings);
+ noWarnings);
}
if (s.tag != WILDCARD)
s = upperBound(s);
@@ -1838,7 +1836,7 @@ public class Types {
//
public boolean isAssignable(Type t, Type s) {
- return isAssignable(t, s, Warner.noWarnings);
+ return isAssignable(t, s, noWarnings);
}
/**
@@ -2149,9 +2147,9 @@ public class Types {
}
};
- public boolean isDirectSuperInterface(Type t, TypeSymbol tsym) {
- for (Type t2 : interfaces(tsym.type)) {
- if (isSameType(t, t2)) return true;
+ public boolean isDirectSuperInterface(TypeSymbol isym, TypeSymbol origin) {
+ for (Type i2 : interfaces(origin.type)) {
+ if (isym == i2.tsym) return true;
}
return false;
}
@@ -2224,7 +2222,9 @@ public class Types {
* Return list of bounds of the given type variable.
*/
public List getBounds(TypeVar t) {
- if (t.bound.isErroneous() || !t.bound.isCompound())
+ if (t.bound.hasTag(NONE))
+ return List.nil();
+ else if (t.bound.isErroneous() || !t.bound.isCompound())
return List.of(t.bound);
else if ((erasure(t).tsym.flags() & INTERFACE) == 0)
return interfaces(t).prepend(supertype(t));
@@ -2319,10 +2319,6 @@ public class Types {
return false;
}
- public boolean overridesObjectMethod(Symbol msym) {
- return ((MethodSymbol)msym).implementation(syms.objectType.tsym, this, true) != null;
- }
-
//
class ImplementationCache {
@@ -2471,11 +2467,7 @@ public class Types {
//where
public List interfaceCandidates(Type site, MethodSymbol ms) {
- return interfaceCandidates(site, ms, false);
- }
-
- public List interfaceCandidates(Type site, MethodSymbol ms, boolean intfOnly) {
- Filter filter = new MethodFilter(ms, site, intfOnly);
+ Filter filter = new MethodFilter(ms, site);
List candidates = List.nil();
for (Symbol s : membersClosure(site, false).getElements(filter)) {
if (!site.tsym.isInterface() && !s.owner.isInterface()) {
@@ -2514,17 +2506,14 @@ public class Types {
Symbol msym;
Type site;
- boolean intfOnly;
- MethodFilter(Symbol msym, Type site, boolean intfOnly) {
+ MethodFilter(Symbol msym, Type site) {
this.msym = msym;
this.site = site;
- this.intfOnly = intfOnly;
}
public boolean accepts(Symbol s) {
return s.kind == Kinds.MTH &&
- (!intfOnly || s.owner.isInterface()) &&
s.name == msym.name &&
s.isInheritedIn(site.tsym, Types.this) &&
overrideEquivalent(memberType(site, s), memberType(site, msym));
@@ -3462,11 +3451,11 @@ public class Types {
*/
public boolean returnTypeSubstitutable(Type r1, Type r2) {
if (hasSameArgs(r1, r2))
- return resultSubtype(r1, r2, Warner.noWarnings);
+ return resultSubtype(r1, r2, noWarnings);
else
return covariantReturnType(r1.getReturnType(),
erasure(r2.getReturnType()),
- Warner.noWarnings);
+ noWarnings);
}
public boolean returnTypeSubstitutable(Type r1,
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
index 6e0027b5a64..0d743da7be4 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -133,7 +133,7 @@ public class Attr extends JCTree.Visitor {
allowCovariantReturns = source.allowCovariantReturns();
allowAnonOuterThis = source.allowAnonOuterThis();
allowStringsInSwitch = source.allowStringsInSwitch();
- allowPoly = source.allowPoly() && options.isSet("allowPoly");
+ allowPoly = source.allowPoly();
allowLambda = source.allowLambda();
allowDefaultMethods = source.allowDefaultMethods();
sourceName = source.name;
@@ -179,14 +179,14 @@ public class Attr extends JCTree.Visitor {
*/
boolean allowCovariantReturns;
- /** Switch: support default methods ?
- */
- boolean allowDefaultMethods;
-
/** Switch: support lambda expressions ?
*/
boolean allowLambda;
+ /** Switch: support default methods ?
+ */
+ boolean allowDefaultMethods;
+
/** Switch: allow references to surrounding object from anonymous
* objects during constructor call?
*/
@@ -524,6 +524,10 @@ public class Attr extends JCTree.Visitor {
protected ResultInfo dup(Type newPt) {
return new ResultInfo(pkind, newPt, checkContext);
}
+
+ protected ResultInfo dup(CheckContext newContext) {
+ return new ResultInfo(pkind, pt, newContext);
+ }
}
class RecoveryInfo extends ResultInfo {
@@ -540,7 +544,7 @@ public class Attr extends JCTree.Visitor {
}
@Override
public void report(DiagnosticPosition pos, JCDiagnostic details) {
- //do nothing
+ chk.basicHandler.report(pos, details);
}
});
}
@@ -595,8 +599,10 @@ public class Attr extends JCTree.Visitor {
this.env = env;
this.resultInfo = resultInfo;
tree.accept(this);
- if (tree == breakTree)
+ if (tree == breakTree &&
+ resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
throw new BreakAttr(env);
+ }
return result;
} catch (CompletionFailure ex) {
tree.type = syms.errType;
@@ -616,13 +622,13 @@ public class Attr extends JCTree.Visitor {
/** Derived visitor method: attribute an expression tree with
* no constraints on the computed type.
*/
- Type attribExpr(JCTree tree, Env env) {
+ public Type attribExpr(JCTree tree, Env env) {
return attribTree(tree, env, unknownExprInfo);
}
/** Derived visitor method: attribute a type tree.
*/
- Type attribType(JCTree tree, Env env) {
+ public Type attribType(JCTree tree, Env env) {
Type result = attribType(tree, env, Type.noType);
return result;
}
@@ -903,7 +909,7 @@ public class Attr extends JCTree.Visitor {
localEnv.info.lint = lint;
- if (isDefaultMethod && types.overridesObjectMethod(m)) {
+ if (isDefaultMethod && types.overridesObjectMethod(m.enclClass(), m)) {
log.error(tree, "default.overrides.object.member", m.name, Kinds.kindName(m.location()), m.location());
}
@@ -1360,11 +1366,8 @@ public class Attr extends JCTree.Visitor {
types.asSuper(resource, syms.autoCloseableType.tsym) != null &&
!types.isSameType(resource, syms.autoCloseableType)) { // Don't emit warning for AutoCloseable itself
Symbol close = syms.noSymbol;
- Filter prevDeferDiagsFilter = log.deferredDiagFilter;
- Queue prevDeferredDiags = log.deferredDiagnostics;
+ Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log);
try {
- log.deferAll();
- log.deferredDiagnostics = ListBuffer.lb();
close = rs.resolveQualifiedMethod(pos,
env,
resource,
@@ -1373,8 +1376,7 @@ public class Attr extends JCTree.Visitor {
List.nil());
}
finally {
- log.deferredDiagFilter = prevDeferDiagsFilter;
- log.deferredDiagnostics = prevDeferredDiags;
+ log.popDiagnosticHandler(discardHandler);
}
if (close.kind == MTH &&
close.overrides(syms.autoCloseableClose, resource.tsym, types, true) &&
@@ -1394,13 +1396,14 @@ public class Attr extends JCTree.Visitor {
if (!standaloneConditional && resultInfo.pt.hasTag(VOID)) {
//cannot get here (i.e. it means we are returning from void method - which is already an error)
+ resultInfo.checkContext.report(tree, diags.fragment("conditional.target.cant.be.void"));
result = tree.type = types.createErrorType(resultInfo.pt);
return;
}
ResultInfo condInfo = standaloneConditional ?
unknownExprInfo :
- new ResultInfo(VAL, pt(), new Check.NestedCheckContext(resultInfo.checkContext) {
+ resultInfo.dup(new Check.NestedCheckContext(resultInfo.checkContext) {
//this will use enclosing check context to check compatibility of
//subexpression against target type; if we are in a method check context,
//depending on whether boxing is allowed, we could have incompatibilities
@@ -1423,11 +1426,11 @@ public class Attr extends JCTree.Visitor {
result = check(tree, owntype, VAL, resultInfo);
}
//where
- @SuppressWarnings("fallthrough")
private boolean isBooleanOrNumeric(Env env, JCExpression tree) {
switch (tree.getTag()) {
case LITERAL: return ((JCLiteral)tree).typetag.isSubRangeOf(DOUBLE) ||
- ((JCLiteral)tree).typetag == BOOLEAN;
+ ((JCLiteral)tree).typetag == BOOLEAN ||
+ ((JCLiteral)tree).typetag == BOT;
case LAMBDA: case REFERENCE: return false;
case PARENS: return isBooleanOrNumeric(env, ((JCParens)tree).expr);
case CONDEXPR:
@@ -1616,19 +1619,23 @@ public class Attr extends JCTree.Visitor {
// it conforms to result type of enclosing method.
if (tree.expr != null) {
if (env.info.returnResult.pt.hasTag(VOID)) {
- log.error(tree.expr.pos(),
- "cant.ret.val.from.meth.decl.void");
+ env.info.returnResult.checkContext.report(tree.expr.pos(),
+ diags.fragment("unexpected.ret.val"));
}
attribTree(tree.expr, env, env.info.returnResult);
} else if (!env.info.returnResult.pt.hasTag(VOID)) {
- log.error(tree.pos(), "missing.ret.val");
+ env.info.returnResult.checkContext.report(tree.pos(),
+ diags.fragment("missing.ret.val"));
}
}
result = null;
}
public void visitThrow(JCThrow tree) {
- attribExpr(tree.expr, env, syms.throwableType);
+ Type owntype = attribExpr(tree.expr, env, allowPoly ? Type.noType : syms.throwableType);
+ if (allowPoly) {
+ chk.checkType(tree, owntype, syms.throwableType);
+ }
result = null;
}
@@ -2072,7 +2079,7 @@ public class Attr extends JCTree.Visitor {
resultInfo.checkContext.inferenceContext().free(resultInfo.pt) ? Type.noType : pt());
Type inferred = deferredAttr.attribSpeculative(tree, env, findDiamondResult).type;
if (!inferred.isErroneous() &&
- types.isAssignable(inferred, pt().hasTag(NONE) ? syms.objectType : pt(), Warner.noWarnings)) {
+ types.isAssignable(inferred, pt().hasTag(NONE) ? syms.objectType : pt(), types.noWarnings)) {
String key = types.isSameType(clazztype, inferred) ?
"diamond.redundant.args" :
"diamond.redundant.args.1";
@@ -2176,7 +2183,7 @@ public class Attr extends JCTree.Visitor {
}
//create an environment for attribution of the lambda expression
final Env localEnv = lambdaEnv(that, env);
- boolean needsRecovery = resultInfo.checkContext.deferredAttrContext() == deferredAttr.emptyDeferredAttrContext ||
+ boolean needsRecovery =
resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK;
try {
List explicitParamTypes = null;
@@ -2186,10 +2193,16 @@ public class Attr extends JCTree.Visitor {
explicitParamTypes = TreeInfo.types(that.params);
}
- Type target = infer.instantiateFunctionalInterface(that, pt(), explicitParamTypes, resultInfo.checkContext);
- Type lambdaType = (target == Type.recoveryType) ?
- fallbackDescriptorType(that) :
- types.findDescriptorType(target);
+ Type target;
+ Type lambdaType;
+ if (pt() != Type.recoveryType) {
+ target = infer.instantiateFunctionalInterface(that, pt(), explicitParamTypes, resultInfo.checkContext);
+ lambdaType = types.findDescriptorType(target);
+ chk.checkFunctionalInterface(that, target);
+ } else {
+ target = Type.recoveryType;
+ lambdaType = fallbackDescriptorType(that);
+ }
if (!TreeInfo.isExplicitLambda(that)) {
//add param type info in the AST
@@ -2254,7 +2267,7 @@ public class Attr extends JCTree.Visitor {
checkLambdaCompatible(that, lambdaType, resultInfo.checkContext, isSpeculativeRound);
if (!isSpeculativeRound) {
- checkAccessibleFunctionalDescriptor(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType);
+ checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType, target);
}
result = check(that, target, VAL, resultInfo);
} catch (Types.FunctionDescriptorLookupError ex) {
@@ -2289,17 +2302,22 @@ public class Attr extends JCTree.Visitor {
return null;
}
- private void checkAccessibleFunctionalDescriptor(final DiagnosticPosition pos,
- final Env env, final InferenceContext inferenceContext, final Type desc) {
- if (inferenceContext.free(desc)) {
- inferenceContext.addFreeTypeListener(List.of(desc), new FreeTypeListener() {
+ private void checkAccessibleTypes(final DiagnosticPosition pos, final Env env, final InferenceContext inferenceContext, final Type... ts) {
+ checkAccessibleTypes(pos, env, inferenceContext, List.from(ts));
+ }
+
+ private void checkAccessibleTypes(final DiagnosticPosition pos, final Env env, final InferenceContext inferenceContext, final List ts) {
+ if (inferenceContext.free(ts)) {
+ inferenceContext.addFreeTypeListener(ts, new FreeTypeListener() {
@Override
public void typesInferred(InferenceContext inferenceContext) {
- checkAccessibleFunctionalDescriptor(pos, env, inferenceContext, inferenceContext.asInstType(desc, types));
+ checkAccessibleTypes(pos, env, inferenceContext, inferenceContext.asInstTypes(ts, types));
}
});
} else {
- chk.checkAccessibleFunctionalDescriptor(pos, env, desc);
+ for (Type t : ts) {
+ rs.checkAccessibleType(env, t);
+ }
}
}
@@ -2415,15 +2433,20 @@ public class Attr extends JCTree.Visitor {
typeargtypes = attribTypes(that.typeargs, localEnv);
}
- Type target = infer.instantiateFunctionalInterface(that, pt(), null, resultInfo.checkContext);
- Type desc = (target == Type.recoveryType) ?
- fallbackDescriptorType(that) :
- types.findDescriptorType(target);
+ Type target;
+ Type desc;
+ if (pt() != Type.recoveryType) {
+ target = infer.instantiateFunctionalInterface(that, pt(), null, resultInfo.checkContext);
+ desc = types.findDescriptorType(target);
+ chk.checkFunctionalInterface(that, target);
+ } else {
+ target = Type.recoveryType;
+ desc = fallbackDescriptorType(that);
+ }
List argtypes = desc.getParameterTypes();
boolean allowBoxing =
- resultInfo.checkContext.deferredAttrContext() == deferredAttr.emptyDeferredAttrContext ||
resultInfo.checkContext.deferredAttrContext().phase.isBoxingRequired();
Pair refResult = rs.resolveMemberReference(that.pos(), localEnv, that,
that.expr.type, that.name, argtypes, typeargtypes, allowBoxing);
@@ -2459,18 +2482,25 @@ public class Attr extends JCTree.Visitor {
JCDiagnostic diag = diags.create(diagKind, log.currentSource(), that,
"invalid.mref", Kinds.kindName(that.getMode()), detailsDiag);
- if (targetError) {
- resultInfo.checkContext.report(that, diag);
+ if (targetError && target == Type.recoveryType) {
+ //a target error doesn't make sense during recovery stage
+ //as we don't know what actual parameter types are
+ result = that.type = target;
+ return;
} else {
- log.report(diag);
+ if (targetError) {
+ resultInfo.checkContext.report(that, diag);
+ } else {
+ log.report(diag);
+ }
+ result = that.type = types.createErrorType(target);
+ return;
}
- result = that.type = types.createErrorType(target);
- return;
}
if (desc.getReturnType() == Type.recoveryType) {
// stop here
- result = that.type = types.createErrorType(target);
+ result = that.type = target;
return;
}
@@ -2496,7 +2526,7 @@ public class Attr extends JCTree.Visitor {
resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
checkReferenceCompatible(that, desc, refType, resultInfo.checkContext, isSpeculativeRound);
if (!isSpeculativeRound) {
- checkAccessibleFunctionalDescriptor(that, localEnv, resultInfo.checkContext.inferenceContext(), desc);
+ checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, target);
}
result = check(that, target, VAL, resultInfo);
} catch (Types.FunctionDescriptorLookupError ex) {
@@ -2530,7 +2560,7 @@ public class Attr extends JCTree.Visitor {
if (!returnType.hasTag(VOID) && !resType.hasTag(VOID)) {
if (resType.isErroneous() ||
- new LambdaReturnContext(checkContext).compatible(resType, returnType, Warner.noWarnings)) {
+ new LambdaReturnContext(checkContext).compatible(resType, returnType, types.noWarnings)) {
incompatibleReturnType = null;
}
}
@@ -3043,15 +3073,52 @@ public class Attr extends JCTree.Visitor {
Symbol sym,
Env env,
ResultInfo resultInfo) {
- Type pt = resultInfo.pt.hasTag(FORALL) || resultInfo.pt.hasTag(METHOD) ?
- resultInfo.pt.map(deferredAttr.new DeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase)) :
- resultInfo.pt;
+ return (resultInfo.pt.hasTag(FORALL) || resultInfo.pt.hasTag(METHOD)) ?
+ checkMethodId(tree, site, sym, env, resultInfo) :
+ checkIdInternal(tree, site, sym, resultInfo.pt, env, resultInfo);
+ }
- DeferredAttr.DeferredTypeMap recoveryMap =
- deferredAttr.new RecoveryDeferredTypeMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase);
+ Type checkMethodId(JCTree tree,
+ Type site,
+ Symbol sym,
+ Env env,
+ ResultInfo resultInfo) {
+ boolean isPolymorhicSignature =
+ sym.kind == MTH && ((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types);
+ return isPolymorhicSignature ?
+ checkSigPolyMethodId(tree, site, sym, env, resultInfo) :
+ checkMethodIdInternal(tree, site, sym, env, resultInfo);
+ }
+ Type checkSigPolyMethodId(JCTree tree,
+ Type site,
+ Symbol sym,
+ Env env,
+ ResultInfo resultInfo) {
+ //recover original symbol for signature polymorphic methods
+ checkMethodIdInternal(tree, site, sym.baseSymbol(), env, resultInfo);
+ env.info.pendingResolutionPhase = Resolve.MethodResolutionPhase.BASIC;
+ return sym.type;
+ }
+
+ Type checkMethodIdInternal(JCTree tree,
+ Type site,
+ Symbol sym,
+ Env env,
+ ResultInfo resultInfo) {
+ Type pt = resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase));
+ Type owntype = checkIdInternal(tree, site, sym, pt, env, resultInfo);
+ resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase));
+ return owntype;
+ }
+
+ Type checkIdInternal(JCTree tree,
+ Type site,
+ Symbol sym,
+ Type pt,
+ Env env,
+ ResultInfo resultInfo) {
if (pt.isErroneous()) {
- Type.map(resultInfo.pt.getParameterTypes(), recoveryMap);
return types.createErrorType(site);
}
Type owntype; // The computed type of this identifier occurrence.
@@ -3136,7 +3203,6 @@ public class Attr extends JCTree.Visitor {
break;
}
case PCK: case ERR:
- Type.map(resultInfo.pt.getParameterTypes(), recoveryMap);
owntype = sym.type;
break;
default:
@@ -3292,21 +3358,21 @@ public class Attr extends JCTree.Visitor {
}
}
- if (env.info.defaultSuperCallSite != null &&
- !types.interfaceCandidates(env.enclClass.type, (MethodSymbol)sym, true).contains(sym)) {
- Symbol ovSym = null;
- for (MethodSymbol msym : types.interfaceCandidates(env.enclClass.type, (MethodSymbol)sym, true)) {
- if (msym.overrides(sym, msym.enclClass(), types, true)) {
- for (Type i : types.interfaces(env.enclClass.type)) {
- if (i.tsym.isSubClass(msym.owner, types)) {
- ovSym = i.tsym;
- break;
- }
- }
+ if (env.info.defaultSuperCallSite != null) {
+ for (Type sup : types.interfaces(env.enclClass.type).prepend(types.supertype((env.enclClass.type)))) {
+ if (!sup.tsym.isSubClass(sym.enclClass(), types) ||
+ types.isSameType(sup, env.info.defaultSuperCallSite)) continue;
+ List icand_sup =
+ types.interfaceCandidates(sup, (MethodSymbol)sym);
+ if (icand_sup.nonEmpty() &&
+ icand_sup.head != sym &&
+ icand_sup.head.overrides(sym, icand_sup.head.enclClass(), types, true)) {
+ log.error(env.tree.pos(), "illegal.default.super.call", env.info.defaultSuperCallSite,
+ diags.fragment("overridden.default", sym, sup));
+ break;
}
}
- log.error(env.tree.pos(), "illegal.default.super.call", env.info.defaultSuperCallSite,
- diags.fragment("overridden.default", sym, ovSym));
+ env.info.defaultSuperCallSite = null;
}
// Compute the identifier's instantiated type.
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java b/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java
index cbc79e223bd..2a43e8fdc54 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java
@@ -109,6 +109,7 @@ public class AttrContext {
pendingResolutionPhase.isVarargsRequired();
}
+ @Override
public String toString() {
return "AttrContext[" + scope.toString() + "]";
}
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
index 52dccced8a6..78ba105984f 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
@@ -120,8 +120,7 @@ public class Check {
allowCovariantReturns = source.allowCovariantReturns();
allowSimplifiedVarargs = source.allowSimplifiedVarargs();
allowDefaultMethods = source.allowDefaultMethods();
- allowStrictMethodClashCheck = source.allowStrictMethodClashCheck() &&
- options.isSet("strictMethodClashCheck"); //pre-lambda guard
+ allowStrictMethodClashCheck = source.allowStrictMethodClashCheck();
complexInference = options.isSet("complexinference");
warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
@@ -451,8 +450,6 @@ public class Check {
public Infer.InferenceContext inferenceContext();
public DeferredAttr.DeferredAttrContext deferredAttrContext();
-
- public boolean allowBoxing();
}
/**
@@ -487,10 +484,6 @@ public class Check {
public DeferredAttrContext deferredAttrContext() {
return enclosingContext.deferredAttrContext();
}
-
- public boolean allowBoxing() {
- return enclosingContext.allowBoxing();
- }
}
/**
@@ -515,10 +508,6 @@ public class Check {
public DeferredAttrContext deferredAttrContext() {
return deferredAttr.emptyDeferredAttrContext;
}
-
- public boolean allowBoxing() {
- return true;
- }
};
/** Check that a given type is assignable to a given proto-type.
@@ -625,7 +614,7 @@ public class Check {
a = types.upperBound(a);
return types.isSubtype(a, bound);
} else if (a.isExtendsBound()) {
- return types.isCastable(bound, types.upperBound(a), Warner.noWarnings);
+ return types.isCastable(bound, types.upperBound(a), types.noWarnings);
} else if (a.isSuperBound()) {
return !types.notSoftSubtype(types.lowerBound(a), bound);
}
@@ -909,19 +898,21 @@ public class Check {
"unchecked.generic.array.creation",
argtype);
}
- Type elemtype = types.elemtype(argtype);
- switch (tree.getTag()) {
- case APPLY:
- ((JCMethodInvocation) tree).varargsElement = elemtype;
- break;
- case NEWCLASS:
- ((JCNewClass) tree).varargsElement = elemtype;
- break;
- case REFERENCE:
- ((JCMemberReference) tree).varargsElement = elemtype;
- break;
- default:
- throw new AssertionError(""+tree);
+ if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) {
+ Type elemtype = types.elemtype(argtype);
+ switch (tree.getTag()) {
+ case APPLY:
+ ((JCMethodInvocation) tree).varargsElement = elemtype;
+ break;
+ case NEWCLASS:
+ ((JCNewClass) tree).varargsElement = elemtype;
+ break;
+ case REFERENCE:
+ ((JCMemberReference) tree).varargsElement = elemtype;
+ break;
+ default:
+ throw new AssertionError(""+tree);
+ }
}
}
return owntype;
@@ -937,65 +928,6 @@ public class Check {
return;
}
- void checkAccessibleFunctionalDescriptor(DiagnosticPosition pos, Env env, Type desc) {
- AccessChecker accessChecker = new AccessChecker(env);
- //check args accessibility (only if implicit parameter types)
- for (Type arg : desc.getParameterTypes()) {
- if (!accessChecker.visit(arg)) {
- log.error(pos, "cant.access.arg.type.in.functional.desc", arg);
- return;
- }
- }
- //check return type accessibility
- if (!accessChecker.visit(desc.getReturnType())) {
- log.error(pos, "cant.access.return.in.functional.desc", desc.getReturnType());
- return;
- }
- //check thrown types accessibility
- for (Type thrown : desc.getThrownTypes()) {
- if (!accessChecker.visit(thrown)) {
- log.error(pos, "cant.access.thrown.in.functional.desc", thrown);
- return;
- }
- }
- }
-
- class AccessChecker extends Types.UnaryVisitor {
-
- Env env;
-
- AccessChecker(Env env) {
- this.env = env;
- }
-
- Boolean visit(List ts) {
- for (Type t : ts) {
- if (!visit(t))
- return false;
- }
- return true;
- }
-
- public Boolean visitType(Type t, Void s) {
- return true;
- }
-
- @Override
- public Boolean visitArrayType(ArrayType t, Void s) {
- return visit(t.elemtype);
- }
-
- @Override
- public Boolean visitClassType(ClassType t, Void s) {
- return rs.isAccessible(env, t, true) &&
- visit(t.getTypeArguments());
- }
-
- @Override
- public Boolean visitWildcardType(WildcardType t, Void s) {
- return visit(t.type);
- }
- };
/**
* Check that type 't' is a valid instantiation of a generic class
* (see JLS 4.5)
@@ -1919,8 +1851,8 @@ public class Check {
types.isSameType(rt1, rt2) ||
!rt1.isPrimitiveOrVoid() &&
!rt2.isPrimitiveOrVoid() &&
- (types.covariantReturnType(rt1, rt2, Warner.noWarnings) ||
- types.covariantReturnType(rt2, rt1, Warner.noWarnings)) ||
+ (types.covariantReturnType(rt1, rt2, types.noWarnings) ||
+ types.covariantReturnType(rt2, rt1, types.noWarnings)) ||
checkCommonOverriderIn(s1,s2,site);
if (!compat) {
log.error(pos, "types.incompatible.diff.ret",
@@ -1965,8 +1897,8 @@ public class Check {
boolean compat =
!rt13.isPrimitiveOrVoid() &&
!rt23.isPrimitiveOrVoid() &&
- (types.covariantReturnType(rt13, rt1, Warner.noWarnings) &&
- types.covariantReturnType(rt23, rt2, Warner.noWarnings));
+ (types.covariantReturnType(rt13, rt1, types.noWarnings) &&
+ types.covariantReturnType(rt23, rt2, types.noWarnings));
if (compat)
return true;
}
@@ -2280,19 +2212,33 @@ public class Check {
c.flags_field |= ACYCLIC;
}
+ /**
+ * Check that functional interface methods would make sense when seen
+ * from the perspective of the implementing class
+ */
+ void checkFunctionalInterface(JCTree tree, Type funcInterface) {
+ ClassType c = new ClassType(Type.noType, List.nil(), null);
+ ClassSymbol csym = new ClassSymbol(0, names.empty, c, syms.noSymbol);
+ c.interfaces_field = List.of(funcInterface);
+ c.supertype_field = syms.objectType;
+ c.tsym = csym;
+ csym.members_field = new Scope(csym);
+ csym.completer = null;
+ checkImplementations(tree, csym, csym);
+ }
+
/** Check that all methods which implement some
* method conform to the method they implement.
* @param tree The class definition whose members are checked.
*/
void checkImplementations(JCClassDecl tree) {
- checkImplementations(tree, tree.sym);
+ checkImplementations(tree, tree.sym, tree.sym);
}
//where
/** Check that all methods which implement some
* method in `ic' conform to the method they implement.
*/
- void checkImplementations(JCClassDecl tree, ClassSymbol ic) {
- ClassSymbol origin = tree.sym;
+ void checkImplementations(JCTree tree, ClassSymbol origin, ClassSymbol ic) {
for (List l = types.closure(ic.type); l.nonEmpty(); l = l.tail) {
ClassSymbol lc = (ClassSymbol)l.head.tsym;
if ((allowGenerics || origin != lc) && (lc.flags() & ABSTRACT) != 0) {
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
index d9ef24ffedc..cf81fc6f5dd 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
@@ -38,14 +38,13 @@ import com.sun.tools.javac.tree.JCTree.*;
import javax.tools.JavaFileObject;
import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.WeakHashMap;
-import static com.sun.tools.javac.code.TypeTag.DEFERRED;
-import static com.sun.tools.javac.code.TypeTag.NONE;
+import static com.sun.tools.javac.code.TypeTag.*;
import static com.sun.tools.javac.tree.JCTree.Tag.*;
/**
@@ -136,19 +135,6 @@ public class DeferredAttr extends JCTree.Visitor {
}
}
- /**
- * Clone a speculative cache entry as a fresh entry associated
- * with a new method (this maybe required to fixup speculative cache
- * misses after Resolve.access())
- */
- void dupAllTo(Symbol from, Symbol to) {
- Assert.check(cache.get(to) == null);
- List entries = cache.get(from);
- if (entries != null) {
- cache.put(to, entries);
- }
- }
-
/**
* Retrieve a speculative cache entry corresponding to given symbol
* and resolution phase
@@ -194,7 +180,7 @@ public class DeferredAttr extends JCTree.Visitor {
DeferredAttrContext deferredAttrContext =
resultInfo.checkContext.deferredAttrContext();
Assert.check(deferredAttrContext != emptyDeferredAttrContext);
- List stuckVars = stuckVars(tree, resultInfo);
+ List stuckVars = stuckVars(tree, env, resultInfo);
if (stuckVars.nonEmpty()) {
deferredAttrContext.addDeferredAttrNode(this, resultInfo, stuckVars);
return Type.noType;
@@ -249,28 +235,25 @@ public class DeferredAttr extends JCTree.Visitor {
JCTree newTree = new TreeCopier