8167967: javadoc should identify the ordinal value of enum constants
authorksrini
Mon, 14 Nov 2016 16:33:48 -0800
changeset 42000 8b7412f7eecd
parent 41999 dbf796210eff
child 42001 b91683ebc1ba
8167967: javadoc should identify the ordinal value of enum constants Reviewed-by: jjg
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractMemberBuilder.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberMap.java
langtools/test/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java
langtools/test/jdk/javadoc/doclet/testOrdering/TestOrdering.java
langtools/test/jdk/javadoc/doclet/testOrdering/order/MethodOrder.java
langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/AnnoFieldTest.java
langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/AnnoOptionalTest.java
langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/AnnoRequiredTest.java
langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/CtorTest.java
langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/EnumTest.java
langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/FieldTest.java
langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/IntfTest.java
langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/MethodTest.java
langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/PropertyTest.java
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Mon Nov 14 16:33:48 2016 -0800
@@ -535,7 +535,7 @@
 
         TypeElement superClass = utils.getSuperClass(typeElement);
         while (superClass != null) {
-            if (visibleMemberMap.hasMembersFor(superClass)) {
+            if (visibleMemberMap.hasMembers(superClass)) {
                 liNav.addContent(getNavSummaryLink(superClass, true));
                 return;
             }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Mon Nov 14 16:33:48 2016 -0800
@@ -135,8 +135,6 @@
      */
     public String docrootparent = "";
 
-    public boolean sortedMethodDetails = false;
-
     /**
      * True if command line option "-nohelp" is used. Default value is false.
      */
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java	Mon Nov 14 16:33:48 2016 -0800
@@ -72,7 +72,7 @@
         VisibleMemberMap visibleMemberMap = new VisibleMemberMap(
                 typeElement,
                 VisibleMemberMap.Kind.CONSTRUCTORS, configuration);
-        SortedSet<Element> constructors = visibleMemberMap.getMembersFor(typeElement);
+        List<Element> constructors = visibleMemberMap.getMembers(typeElement);
         for (Element constructor : constructors) {
             if (utils.isProtected(constructor) || utils.isPrivate(constructor)) {
                 setFoundNonPubConstructor(true);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractMemberBuilder.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractMemberBuilder.java	Mon Nov 14 16:33:48 2016 -0800
@@ -25,6 +25,15 @@
 
 package jdk.javadoc.internal.doclets.toolkit.builders;
 
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.lang.model.element.Element;
+
+import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.DocletException;
 
@@ -42,6 +51,7 @@
  */
 public abstract class AbstractMemberBuilder extends AbstractBuilder {
 
+    public final Comparator<Element> comparator;
     /**
      * Construct a SubBuilder.
      * @param context a context object, providing information used in this run
@@ -49,6 +59,7 @@
      */
     public AbstractMemberBuilder(Context context) {
         super(context);
+        comparator = utils.makeGeneralPurposeComparator();
     }
 
     /**
@@ -83,4 +94,10 @@
      * @return true if this subbuilder has anything to document
      */
     public abstract boolean hasMembersToDocument();
+
+    public SortedSet<Element> asSortedSet(Collection<Element> members) {
+        SortedSet<Element> out = new TreeSet<>(comparator);
+        out.addAll(members);
+        return out;
+    }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java	Mon Nov 14 16:33:48 2016 -0800
@@ -67,7 +67,7 @@
     /**
      * The list of members being documented.
      */
-    protected SortedSet<Element> members;
+    protected List<Element> members;
 
     /**
      * The index of the current member that is being documented at this point
@@ -91,7 +91,7 @@
         this.typeElement = typeElement;
         this.writer = writer;
         this.visibleMemberMap = new VisibleMemberMap(typeElement, memberType, configuration);
-        this.members = this.visibleMemberMap.getMembersFor(typeElement);
+        this.members = this.visibleMemberMap.getMembers(typeElement);
     }
 
 
@@ -118,26 +118,6 @@
         return "AnnotationTypeFieldDetails";
     }
 
-    /**
-     * Returns a list of members that will be documented for the given class.
-     * This information can be used for doclet specific documentation
-     * generation.
-     *
-     * @param typeElement the TypeElement we want to check.
-     * @return a list of members that will be documented.
-     */
-    public SortedSet<Element> members(TypeElement typeElement) {
-        return visibleMemberMap.getMembersFor(typeElement);
-    }
-
-    /**
-     * Returns the visible member map for the members of this class.
-     *
-     * @return the visible member map for the members of this class.
-     */
-    public VisibleMemberMap getVisibleMemberMap() {
-        return visibleMemberMap;
-    }
 
     /**
      * Returns whether or not there are members to document.
@@ -145,7 +125,7 @@
      */
     @Override
     public boolean hasMembersToDocument() {
-        return members.size() > 0;
+        return !members.isEmpty();
     }
 
     /**
@@ -172,16 +152,19 @@
         if (writer == null) {
             return;
         }
-        if (!members.isEmpty()) {
+        if (hasMembersToDocument()) {
             writer.addAnnotationFieldDetailsMarker(memberDetailsTree);
-            for (Element element : members) {
-                currentMember = element;
+
+            Element lastElement = members.get(members.size() - 1);
+            for (Element member : members) {
+                currentMember = member;
                 Content detailsTree = writer.getMemberTreeHeader();
                 writer.addAnnotationDetailsTreeHeader(typeElement, detailsTree);
-                Content annotationDocTree = writer.getAnnotationDocTreeHeader(element, detailsTree);
+                Content annotationDocTree = writer.getAnnotationDocTreeHeader(currentMember,
+                        detailsTree);
                 buildChildren(node, annotationDocTree);
                 detailsTree.addContent(writer.getAnnotationDoc(
-                        annotationDocTree, currentMember == members.last()));
+                        annotationDocTree, currentMember == lastElement));
                 memberDetailsTree.addContent(writer.getAnnotationDetails(detailsTree));
             }
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java	Mon Nov 14 16:33:48 2016 -0800
@@ -68,7 +68,7 @@
     /**
      * The list of members being documented.
      */
-    protected SortedSet<Element> members;
+    protected List<Element> members;
 
     /**
      * The index of the current member that is being documented at this point
@@ -82,6 +82,7 @@
      * @param context  the build context.
      * @param typeElement the class whose members are being documented.
      * @param writer the doclet specific writer.
+     * @param memberType the kind of member this builder processes.
      */
     protected AnnotationTypeRequiredMemberBuilder(Context context,
             TypeElement typeElement,
@@ -91,7 +92,7 @@
         this.typeElement = typeElement;
         this.writer = writer;
         this.visibleMemberMap = new VisibleMemberMap(typeElement, memberType, configuration);
-        this.members = this.visibleMemberMap.getMembersFor(typeElement);
+        this.members = this.visibleMemberMap.getMembers(typeElement);
     }
 
 
@@ -101,6 +102,7 @@
      * @param context  the build context.
      * @param typeElement the class whose members are being documented.
      * @param writer the doclet specific writer.
+     * @return an instance of this object
      */
     public static AnnotationTypeRequiredMemberBuilder getInstance(
             Context context, TypeElement typeElement,
@@ -119,33 +121,12 @@
     }
 
     /**
-     * Returns a list of members that will be documented for the given class.
-     * This information can be used for doclet specific documentation
-     * generation.
-     *
-     * @param typeElement the {@link TypeElement} we want to check.
-     * @return a list of members that will be documented.
-     */
-    public SortedSet<Element> members(TypeElement typeElement) {
-        return visibleMemberMap.getMembersFor(typeElement);
-    }
-
-    /**
-     * Returns the visible member map for the members of this class.
-     *
-     * @return the visible member map for the members of this class.
-     */
-    public VisibleMemberMap getVisibleMemberMap() {
-        return visibleMemberMap;
-    }
-
-    /**
      * Returns whether or not there are members to document.
      * @return whether or not there are members to document
      */
     @Override
     public boolean hasMembersToDocument() {
-        return members.size() > 0;
+        return !members.isEmpty();
     }
 
     /**
@@ -165,24 +146,25 @@
      *
      * @param node the XML element that specifies which components to document
      * @param memberDetailsTree the content tree to which the documentation will be added
+     * @throws DocletException if an error occurs
      */
     public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree)
             throws DocletException {
         if (writer == null) {
             return;
         }
-        int size = members.size();
-        if (size > 0) {
+        if (hasMembersToDocument()) {
             writer.addAnnotationDetailsMarker(memberDetailsTree);
-            for (Element element : members) {
-                currentMember = element;
+            Element lastMember = members.get((members.size() - 1));
+            for (Element member : members) {
+                currentMember = member;
                 Content detailsTree = writer.getMemberTreeHeader();
                 writer.addAnnotationDetailsTreeHeader(typeElement, detailsTree);
                 Content annotationDocTree = writer.getAnnotationDocTreeHeader(
-                        element, detailsTree);
+                        currentMember, detailsTree);
                 buildChildren(node, annotationDocTree);
                 detailsTree.addContent(writer.getAnnotationDoc(
-                        annotationDocTree, currentMember == members.last()));
+                        annotationDocTree, currentMember == lastMember));
                 memberDetailsTree.addContent(writer.getAnnotationDetails(detailsTree));
             }
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java	Mon Nov 14 16:33:48 2016 -0800
@@ -275,7 +275,7 @@
     private boolean hasConstantField (TypeElement typeElement) {
         VisibleMemberMap visibleMemberMapFields = new VisibleMemberMap(typeElement,
             VisibleMemberMap.Kind.FIELDS, configuration);
-        SortedSet<Element> fields = visibleMemberMapFields.getLeafClassMembers();
+        List<Element> fields = visibleMemberMapFields.getLeafMembers();
         for (Element f : fields) {
             VariableElement field = (VariableElement)f;
             if (field.getConstantValue() != null) {
@@ -350,21 +350,21 @@
         }
 
         /**
-         * Return the list of visible constant fields for the given TypeElement.
-         * @return the list of visible constant fields for the given TypeElement.
+         * Returns a set of visible constant fields for the given type.
+         * @return the set of visible constant fields for the given type.
          */
         protected SortedSet<VariableElement> members() {
-            SortedSet<Element> list = visibleMemberMapFields.getLeafClassMembers();
-            list.addAll(visibleMemberMapEnumConst.getLeafClassMembers());
-            SortedSet<VariableElement> inclList =
+            List<Element> members = visibleMemberMapFields.getLeafMembers();
+            members.addAll(visibleMemberMapEnumConst.getLeafMembers());
+            SortedSet<VariableElement> includes =
                     new TreeSet<>(utils.makeGeneralPurposeComparator());
-            for (Element element : list) {
+            for (Element element : members) {
                 VariableElement member = (VariableElement)element;
                 if (member.getConstantValue() != null) {
-                    inclList.add(member);
+                    includes.add(member);
                 }
             }
-            return inclList;
+            return includes;
         }
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java	Mon Nov 14 16:33:48 2016 -0800
@@ -59,7 +59,7 @@
     /**
      * The current constructor that is being documented at this point in time.
      */
-    private ExecutableElement constructor;
+    private ExecutableElement currentConstructor;
 
     /**
      * The class whose constructors are being documented.
@@ -79,7 +79,7 @@
     /**
      * The constructors being documented.
      */
-    private final SortedSet<Element> constructors;
+    private final List<Element> constructors;
 
     /**
      * Construct a new ConstructorBuilder.
@@ -99,7 +99,7 @@
                 typeElement,
                 VisibleMemberMap.Kind.CONSTRUCTORS,
                 configuration);
-        constructors = visibleMemberMap.getMembersFor(typeElement);
+        constructors = visibleMemberMap.getMembers(typeElement);
         for (Element ctor : constructors) {
             if (utils.isProtected(ctor) || utils.isPrivate(ctor)) {
                 writer.setFoundNonPubConstructor(true);
@@ -137,18 +137,6 @@
     }
 
     /**
-     * Returns a list of constructors that will be documented for the given class.
-     * This information can be used for doclet specific documentation
-     * generation.
-     *
-     * @param typeElement the class
-     * @return a list of constructors that will be documented.
-     */
-    public SortedSet<Element> members(TypeElement typeElement) {
-        return visibleMemberMap.getMembersFor(typeElement);
-    }
-
-    /**
      * Return the constructor writer for this builder.
      *
      * @return the constructor writer for this builder.
@@ -168,17 +156,17 @@
         if (writer == null) {
             return;
         }
-        int size = constructors.size();
-        if (size > 0) {
+        if (hasMembersToDocument()) {
             Content constructorDetailsTree = writer.getConstructorDetailsTreeHeader(typeElement,
                     memberDetailsTree);
-            for (Element ctor : constructors) {
-                constructor = (ExecutableElement)ctor;
-                Content constructorDocTree = writer.getConstructorDocTreeHeader(
-                        constructor, constructorDetailsTree);
+
+            Element lastElement = constructors.get(constructors.size() - 1);
+            for (Element contructor : constructors) {
+                currentConstructor = (ExecutableElement)contructor;
+                Content constructorDocTree = writer.getConstructorDocTreeHeader(currentConstructor, constructorDetailsTree);
                 buildChildren(node, constructorDocTree);
                 constructorDetailsTree.addContent(writer.getConstructorDoc(constructorDocTree,
-                        constructors.last().equals(constructor)));
+                        currentConstructor == lastElement));
             }
             memberDetailsTree.addContent(
                     writer.getConstructorDetails(constructorDetailsTree));
@@ -192,7 +180,7 @@
      * @param constructorDocTree the content tree to which the documentation will be added
      */
     public void buildSignature(XMLNode node, Content constructorDocTree) {
-        constructorDocTree.addContent(writer.getSignature(constructor));
+        constructorDocTree.addContent(writer.getSignature(currentConstructor));
     }
 
     /**
@@ -202,7 +190,7 @@
      * @param constructorDocTree the content tree to which the documentation will be added
      */
     public void buildDeprecationInfo(XMLNode node, Content constructorDocTree) {
-        writer.addDeprecated(constructor, constructorDocTree);
+        writer.addDeprecated(currentConstructor, constructorDocTree);
     }
 
     /**
@@ -214,7 +202,7 @@
      */
     public void buildConstructorComments(XMLNode node, Content constructorDocTree) {
         if (!configuration.nocomment) {
-            writer.addComments(constructor, constructorDocTree);
+            writer.addComments(currentConstructor, constructorDocTree);
         }
     }
 
@@ -225,6 +213,6 @@
      * @param constructorDocTree the content tree to which the documentation will be added
      */
     public void buildTagInfo(XMLNode node, Content constructorDocTree) {
-        writer.addTags(constructor, constructorDocTree);
+        writer.addTags(currentConstructor, constructorDocTree);
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java	Mon Nov 14 16:33:48 2016 -0800
@@ -67,9 +67,9 @@
     private final EnumConstantWriter writer;
 
     /**
-     * The list of enum constants being documented.
+     * The set of enum constants being documented.
      */
-    private final SortedSet<Element> enumConstants;
+    private final List<Element> enumConstants;
 
     /**
      * The current enum constant that is being documented at this point
@@ -94,7 +94,7 @@
                 typeElement,
                 VisibleMemberMap.Kind.ENUM_CONSTANTS,
                 configuration);
-        enumConstants = visibleMemberMap.getMembersFor(typeElement);
+        enumConstants = visibleMemberMap.getMembers(typeElement);
     }
 
     /**
@@ -119,34 +119,13 @@
     }
 
     /**
-     * Returns a list of enum constants that will be documented for the given class.
-     * This information can be used for doclet specific documentation
-     * generation.
-     *
-     * @param typeElement the {@link TypeElement} we want to check.
-     * @return a list of enum constants that will be documented.
-     */
-    public SortedSet<Element> members(TypeElement typeElement) {
-        return visibleMemberMap.getMembersFor(typeElement);
-    }
-
-    /**
-     * Returns the visible member map for the enum constants of this class.
-     *
-     * @return the visible member map for the enum constants of this class.
-     */
-    public VisibleMemberMap getVisibleMemberMap() {
-        return visibleMemberMap;
-    }
-
-    /**
      * Returns whether or not there are members to document.
      *
      * @return whether or not there are members to document
      */
     @Override
     public boolean hasMembersToDocument() {
-        return enumConstants.size() > 0;
+        return !enumConstants.isEmpty();
     }
 
     /**
@@ -160,16 +139,17 @@
         if (writer == null) {
             return;
         }
-        if (!enumConstants.isEmpty()) {
+        if (hasMembersToDocument()) {
             Content enumConstantsDetailsTree = writer.getEnumConstantsDetailsTreeHeader(typeElement,
                     memberDetailsTree);
-            for (Element element : enumConstants) {
-                currentElement = (VariableElement)element;
+            Element lastElement = enumConstants.get(enumConstants.size() - 1);
+            for (Element enumConstant : enumConstants) {
+                currentElement = (VariableElement)enumConstant;
                 Content enumConstantsTree = writer.getEnumConstantsTreeHeader(currentElement,
                         enumConstantsDetailsTree);
                 buildChildren(node, enumConstantsTree);
                 enumConstantsDetailsTree.addContent(writer.getEnumConstants(
-                        enumConstantsTree, currentElement.equals(enumConstants.last())));
+                        enumConstantsTree, currentElement == lastElement));
             }
             memberDetailsTree.addContent(
                     writer.getEnumConstantsDetails(enumConstantsDetailsTree));
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java	Mon Nov 14 16:33:48 2016 -0800
@@ -69,7 +69,7 @@
     /**
      * The list of fields being documented.
      */
-    private final SortedSet<Element> fields;
+    private final List<Element> fields;
 
     /**
      * The index of the current field that is being documented at this point
@@ -95,7 +95,7 @@
                 typeElement,
                 VisibleMemberMap.Kind.FIELDS,
                 configuration);
-        fields = visibleMemberMap.getLeafClassMembers();
+        fields = visibleMemberMap.getLeafMembers();
     }
 
     /**
@@ -121,27 +121,6 @@
     }
 
     /**
-     * Returns a list of fields that will be documented for the given class.
-     * This information can be used for doclet specific documentation
-     * generation.
-     *
-     * @param typeElement the {@link TypeElement} we want to check.
-     * @return a list of fields that will be documented.
-     */
-    public SortedSet<Element> members(TypeElement typeElement) {
-        return visibleMemberMap.getMembersFor(typeElement);
-    }
-
-    /**
-     * Returns the visible member map for the fields of this class.
-     *
-     * @return the visible member map for the fields of this class.
-     */
-    public VisibleMemberMap getVisibleMemberMap() {
-        return visibleMemberMap;
-    }
-
-    /**
      * Returns whether or not there are members to document.
      *
      * @return whether or not there are members to document
@@ -164,12 +143,14 @@
         }
         if (!fields.isEmpty()) {
             Content fieldDetailsTree = writer.getFieldDetailsTreeHeader(typeElement, memberDetailsTree);
+
+            Element lastElement = fields.get(fields.size() - 1);
             for (Element element : fields) {
                 currentElement = (VariableElement)element;
                 Content fieldDocTree = writer.getFieldDocTreeHeader(currentElement, fieldDetailsTree);
                 buildChildren(node, fieldDocTree);
                 fieldDetailsTree.addContent(writer.getFieldDoc(
-                        fieldDocTree, currentElement.equals(fields.last())));
+                        fieldDocTree, currentElement == lastElement));
             }
             memberDetailsTree.addContent(
                     writer.getFieldDetails(fieldDetailsTree));
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java	Mon Nov 14 16:33:48 2016 -0800
@@ -182,7 +182,9 @@
      * @see VisibleMemberMap
      */
     public SortedSet<Element> members(VisibleMemberMap.Kind type) {
-        return visibleMemberMaps.get(type).getLeafClassMembers();
+        TreeSet<Element> out = new TreeSet<>(comparator);
+        out.addAll(visibleMemberMaps.get(type).getLeafMembers());
+        return out;
     }
 
     /**
@@ -336,7 +338,7 @@
      */
     private void buildSummary(MemberSummaryWriter writer,
             VisibleMemberMap visibleMemberMap, LinkedList<Content> summaryTreeList) {
-        SortedSet<Element> members = visibleMemberMap.getLeafClassMembers();
+        SortedSet<Element> members = asSortedSet(visibleMemberMap.getLeafMembers());
         if (!members.isEmpty()) {
             List<Content> tableContents = new LinkedList<>();
             int counter = 0;
@@ -492,7 +494,7 @@
             if (inhclass == typeElement) {
                 continue;
             }
-            SortedSet<Element> inhmembers = visibleMemberMap.getMembersFor(inhclass);
+            SortedSet<Element> inhmembers = asSortedSet(visibleMemberMap.getMembers(inhclass));
             if (!inhmembers.isEmpty()) {
                 Content inheritedTree = writer.getInheritedSummaryHeader(inhclass);
                 Content linksTree = writer.getInheritedSummaryLinksTree();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java	Mon Nov 14 16:33:48 2016 -0800
@@ -78,7 +78,7 @@
     /**
      * The methods being documented.
      */
-    private final SortedSet<Element> methods;
+    private final List<Element> methods;
 
 
     /**
@@ -98,7 +98,7 @@
                 typeElement,
                 VisibleMemberMap.Kind.METHODS,
                 configuration);
-        methods = visibleMemberMap.getLeafClassMembers();
+        methods = visibleMemberMap.getLeafMembers();
     }
 
     /**
@@ -124,27 +124,6 @@
     }
 
     /**
-     * Returns a list of methods that will be documented for the given class.
-     * This information can be used for doclet specific documentation
-     * generation.
-     *
-     * @param typeElement the {@link TypeElement} we want to check.
-     * @return a list of methods that will be documented.
-     */
-    public SortedSet<Element> members(TypeElement typeElement) {
-        return visibleMemberMap.getMembersFor(typeElement);
-    }
-
-    /**
-     * Returns the visible member map for the methods of this class.
-     *
-     * @return the visible member map for the methods of this class.
-     */
-    public VisibleMemberMap getVisibleMemberMap() {
-        return visibleMemberMap;
-    }
-
-    /**
      * {@inheritDoc}
      */
     @Override
@@ -163,18 +142,17 @@
         if (writer == null) {
             return;
         }
-        if (!methods.isEmpty()) {
+        if (hasMembersToDocument()) {
             Content methodDetailsTree = writer.getMethodDetailsTreeHeader(typeElement,
                     memberDetailsTree);
-            Set<Element> methodDetailSet = ((ConfigurationImpl)configuration).sortedMethodDetails
-                    ? methods
-                    : visibleMemberMap.getLeafClassMembersSourceOrder();
-            for (Element e : methodDetailSet) {
-                currentMethod = (ExecutableElement) e;
+
+            Element lastElement = methods.get(methods.size() - 1);
+            for (Element method : methods) {
+                currentMethod = (ExecutableElement)method;
                 Content methodDocTree = writer.getMethodDocTreeHeader(currentMethod, methodDetailsTree);
                 buildChildren(node, methodDocTree);
                 methodDetailsTree.addContent(writer.getMethodDoc(
-                        methodDocTree, currentMethod == methods.last()));
+                        methodDocTree, currentMethod == lastElement));
             }
             memberDetailsTree.addContent(writer.getMethodDetails(methodDetailsTree));
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java	Mon Nov 14 16:33:48 2016 -0800
@@ -69,7 +69,7 @@
     /**
      * The list of properties being documented.
      */
-    private final SortedSet<Element> properties;
+    private final List<Element> properties;
 
     /**
      * The index of the current property that is being documented at this point
@@ -95,7 +95,7 @@
                 typeElement,
                 VisibleMemberMap.Kind.PROPERTIES,
                 configuration);
-        properties = visibleMemberMap.getMembersFor(typeElement);
+        properties = visibleMemberMap.getMembers(typeElement);
     }
 
     /**
@@ -121,27 +121,6 @@
     }
 
     /**
-     * Returns a list of properties that will be documented for the given class.
-     * This information can be used for doclet specific documentation
-     * generation.
-     *
-     * @param typeElement the {@link TypeElement} we want to check.
-     * @return a list of properties that will be documented.
-     */
-    public SortedSet<Element> members(TypeElement typeElement) {
-        return visibleMemberMap.getMembersFor(typeElement);
-    }
-
-    /**
-     * Returns the visible member map for the properties of this class.
-     *
-     * @return the visible member map for the properties of this class.
-     */
-    public VisibleMemberMap getVisibleMemberMap() {
-        return visibleMemberMap;
-    }
-
-    /**
      * Returns whether or not there are members to document.
      *
      * @return whether or not there are members to document
@@ -162,17 +141,17 @@
         if (writer == null) {
             return;
         }
-        int size = properties.size();
-        if (size > 0) {
+        if (hasMembersToDocument()) {
             Content propertyDetailsTree = writer.getPropertyDetailsTreeHeader(typeElement,
                     memberDetailsTree);
-            for (Element e : properties) {
-                currentProperty = (ExecutableElement) e;
+            Element lastElement = properties.get(properties.size() - 1);
+            for (Element property : properties) {
+                currentProperty = (ExecutableElement)property;
                 Content propertyDocTree = writer.getPropertyDocTreeHeader(currentProperty,
                         propertyDetailsTree);
                 buildChildren(node, propertyDocTree);
                 propertyDetailsTree.addContent(writer.getPropertyDoc(
-                        propertyDocTree, currentProperty == properties.last()));
+                        propertyDocTree, currentProperty == lastElement));
             }
             memberDetailsTree.addContent(
                     writer.getPropertyDetails(propertyDetailsTree));
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Mon Nov 14 16:33:48 2016 -0800
@@ -25,7 +25,6 @@
 
 package jdk.javadoc.internal.doclets.toolkit.util;
 
-import java.io.IOException;
 import java.lang.annotation.Documented;
 import java.lang.ref.SoftReference;
 import java.text.CollationKey;
@@ -77,9 +76,7 @@
 import com.sun.source.util.TreePath;
 import jdk.javadoc.internal.doclets.toolkit.CommentUtils.DocCommentDuo;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
-import jdk.javadoc.internal.doclets.toolkit.DocletException;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
-import jdk.javadoc.internal.doclets.toolkit.Resources;
 import jdk.javadoc.internal.doclets.toolkit.WorkArounds;
 
 import static javax.lang.model.element.ElementKind.*;
@@ -258,14 +255,6 @@
         return getEnclosingTypeElement(e) == null || isStatic(e);
     }
 
-    public boolean matches(Element e1, Element e2) {
-        if (isExecutableElement(e1) && isExecutableElement(e1)) {
-            return executableMembersEqual((ExecutableElement)e1, (ExecutableElement)e2);
-        } else {
-            return e1.getSimpleName().equals(e2.getSimpleName());
-        }
-    }
-
     /**
      * Copy doc-files directory and its contents from the source
      * package directory to the generated documentation directory.
@@ -2161,6 +2150,13 @@
         return convertToExecutableElement(getItems(e, false, METHOD));
     }
 
+    public int getOrdinalValue(VariableElement member) {
+        if (member == null || member.getKind() != ENUM_CONSTANT) {
+            throw new IllegalArgumentException("must be an enum constant: " + member);
+        }
+        return member.getEnclosingElement().getEnclosedElements().indexOf(member);
+    }
+
     public long getLineNumber(Element e) {
         TreePath path = getTreePath(e);
         if (path == null) { // maybe null if synthesized
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberMap.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberMap.java	Mon Nov 14 16:33:48 2016 -0800
@@ -220,48 +220,36 @@
     }
 
     /**
-     * Return the visible members of the class being mapped.  Also append at the
-     * end of the list members that are inherited by inaccessible parents. We
-     * document these members in the child because the parent is not documented.
+     * Returns a list of visible enclosed members of the type being mapped.
+     * This list may also contain appended members, inherited by inaccessible
+     * super types. These members are documented in the subtype when the
+     * super type is not documented.
      *
-     * @param configuration the current configuration of the doclet.
+     * @return a list of visible enclosed members
      */
-    public SortedSet<Element> getLeafClassMembers() {
-        SortedSet<Element> result = getMembersFor(typeElement);
-        result.addAll(getInheritedPackagePrivateMethods());
-        return result;
-    }
 
-    public Set<Element> getLeafClassMembersSourceOrder() {
-        Set<Element> result = new LinkedHashSet<>(classMap.get(typeElement).members);
+    public List<Element> getLeafMembers() {
+        List<Element> result = new ArrayList<>();
+        result.addAll(classMap.get(typeElement).members);
         result.addAll(getInheritedPackagePrivateMethods());
         return result;
     }
 
     /**
-     * Retrn the list of members for the given class.
+     * Returns a list of enclosed members for the given type.
      *
-     * @param typeElement the class to retrieve the list of visible members for.
+     * @param typeElement the given type
      *
-     * @return the list of members for the given class.
+     * @return a list of enclosed members
      */
-    public SortedSet<Element> getMembersFor(TypeElement typeElement) {
-        return asSortedSet(classMap.get(typeElement).members);
+    public List<Element> getMembers(TypeElement typeElement) {
+        return classMap.get(typeElement).members;
     }
 
-    public boolean hasMembersFor(TypeElement typeElement) {
+    public boolean hasMembers(TypeElement typeElement) {
         return !classMap.get(typeElement).members.isEmpty();
     }
 
-    private SortedSet<Element> asSortedSet(Collection<Element> in) {
-        if (in == null) {
-            return Collections.emptySortedSet();
-        }
-        TreeSet<Element> out = new TreeSet<>(comparator);
-        out.addAll(in);
-        return out;
-    }
-
     private void fillMemberLevelMap(List<? extends Element> list, String level) {
         for (Element element : list) {
             Object key = getMemberKey(element);
@@ -318,9 +306,9 @@
         private final TypeElement typeElement;
 
         /**
-         * List of inherited members from the mapping class.
+         * List of members from the mapping class.
          */
-        private Set<Element> members = new LinkedHashSet<>();
+        private List<Element> members = null;
 
         /**
          * Level/Depth of inheritance.
@@ -379,23 +367,23 @@
          * Adjust member-level-map, class-map.
          */
         private void addMembers(TypeElement fromClass) {
-            List<? extends Element> classMembers = getClassMembers(fromClass, true);
-            List<Element> incllist = new ArrayList<>();
-            for (Element element : classMembers) {
-                if (!found(members, element)) {
-                    if (memberIsVisible(element)) {
-                        if (!isOverridden(element, level)) {
-                            if (!utils.isHidden(element)) {
-                                incllist.add(element);
-                            }
+            List<Element> result = new ArrayList<>();
+            for (Element element : getClassMembers(fromClass, true)) {
+                if (memberIsVisible(element)) {
+                    if (!isOverridden(element, level)) {
+                        if (!utils.isHidden(element)) {
+                            result.add(element);
                         }
                     }
                 }
             }
-            if (!incllist.isEmpty()) {
+            if (members != null) {
+                throw new AssertionError("members should not be null");
+            }
+            members = Collections.unmodifiableList(result);
+            if (!members.isEmpty()) {
                 noVisibleMembers = false;
             }
-            members.addAll(incllist);
             fillMemberLevelMap(getClassMembers(fromClass, false), level);
         }
 
@@ -513,16 +501,6 @@
             return targetMembers;
         }
 
-        private boolean found(Iterable<Element> list, Element elem) {
-            for (Element pgmelem : list) {
-                if (utils.matches(pgmelem, elem)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-
         /**
          * Is member overridden? The member is overridden if it is found in the
          * same level hierarchy e.g. member at level "11" overrides member at
--- a/langtools/test/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/test/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java	Mon Nov 14 16:33:48 2016 -0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7112427 8012295 8025633 8026567 8061305 8081854 8150130 8162363
+ * @bug 7112427 8012295 8025633 8026567 8061305 8081854 8150130 8162363 8167967
  * @summary Test of the JavaFX doclet features.
  * @author jvalenta
  * @library ../lib
@@ -163,10 +163,7 @@
                 "pkg2");
         checkExit(Exit.OK);
         checkOutput("pkg2/Test.html", true,
-                "<li class=\"blockList\"><a name=\"property.detail\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<h3>Property Detail</h3>\n"
+                "<h3>Property Detail</h3>\n"
                 + "<a name=\"betaProperty\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
@@ -176,27 +173,27 @@
                 + "<pre>public&nbsp;java.lang.Object betaProperty</pre>\n"
                 + "</li>\n"
                 + "</ul>\n"
+                + "<a name=\"gammaProperty\">\n"
+                + "<!--   -->\n"
+                + "</a>\n"
+                + "<ul class=\"blockList\">\n"
+                + "<li class=\"blockList\">\n"
+                + "<h4>gamma</h4>\n"
+                + "<pre>public final&nbsp;java.util.List&lt;java.lang.String&gt; gammaProperty</pre>\n"
+                + "</li>\n"
+                + "</ul>\n"
                 + "<a name=\"deltaProperty\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
-                + "<ul class=\"blockList\">\n"
+                + "<ul class=\"blockListLast\">\n"
                 + "<li class=\"blockList\">\n"
                 + "<h4>delta</h4>\n"
                 + "<pre>public final&nbsp;java.util.List&lt;"
                 + "java.util.Set&lt;? super java.lang.Object&gt;&gt; deltaProperty</pre>\n"
                 + "</li>\n"
                 + "</ul>\n"
-                + "<a name=\"gammaProperty\">\n"
-                + "<!--   -->\n"
-                + "</a>\n"
-                + "<ul class=\"blockListLast\">\n"
-                + "<li class=\"blockList\">\n"
-                + "<h4>gamma</h4>\n"
-                + "<pre>public final&nbsp;java.util.List&lt;"
-                + "java.lang.String&gt; gammaProperty</pre>\n"
                 + "</li>\n"
-                + "</ul>\n"
-                + "</li>");
+                + "</ul>");
     }
 
     /*
--- a/langtools/test/jdk/javadoc/doclet/testOrdering/TestOrdering.java	Mon Nov 14 19:45:41 2016 +0530
+++ b/langtools/test/jdk/javadoc/doclet/testOrdering/TestOrdering.java	Mon Nov 14 16:33:48 2016 -0800
@@ -23,9 +23,8 @@
 
 /*
  * @test
- * @bug 8039410 8042601 8042829 8049393 8050031 8155061 8155995
+ * @bug 8039410 8042601 8042829 8049393 8050031 8155061 8155995 8167967
  * @summary test to determine if members are ordered correctly
- * @author ksrini
  * @library ../lib/
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
  * @build JavadocTester
@@ -51,492 +50,640 @@
 
     @Test
     void testUnnamedPackagesForClassUse() {
-        javadoc("-d", "out",
-                "-sourcepath", testSrc,
-                "-use",
-                testSrc("C.java"), testSrc("UsedInC.java"));
-        checkExit(Exit.OK);
-        checkExecutableMemberOrdering("class-use/UsedInC.html");
+        new UnnamedPackageForClassUseTest(this).run();
     }
 
     @Test
     void testNamedPackagesForClassUse() {
-        javadoc("-d", "out-1",
-                "-sourcepath", testSrc,
-                "-use",
-                "pkg1");
-        checkExit(Exit.OK);
-        checkClassUseOrdering("pkg1/class-use/UsedClass.html");
-        checkOrder("pkg1/class-use/UsedClass.html", expectedClassUseMethodOrdering);
-        checkOrder("pkg1/class-use/UsedClass.html", expectedClassUseWithTypeParams);
-        checkOrder("pkg1/class-use/UsedClass.html", expectedInnerClassContructors);
-        checkOrder("pkg1/ImplementsOrdering.html", expectedImplementsOrdering);
-        checkOrder("pkg1/OverrideOrdering.html", expectedOverrideOrdering);
-        checkOrder("allclasses-noframe.html", expectedAllClasses);
-        checkOrder("allclasses-frame.html", expectedAllClasses);
+        new NamedPackagesForClassUseTest(this).run();
     }
 
-    enum ListOrder { NONE, REVERSE, SHUFFLE };
-    /*
-     * By default we do not shuffle the input list, in order to keep the list deterministic,
-     * and the test predictable. However, we can turn on the stress mode, by setting the following
-     * property if required.
-     */
-    static final ListOrder STRESS_MODE = Boolean.getBoolean("TestOrder.STRESS")
-            ? ListOrder.SHUFFLE
-            : ListOrder.REVERSE;
-
-    /*
-     * Controls the number of sibling packages,  pkg0, pkg1, pkg2, .....
-     */
-    static final int MAX_PACKAGES = 4;
-
-    /*
-     * Controls the number of children packages, pkg0, pkg0.pkg, pkg0.pkg.pkg, .....
-     * Note: having too long a depth (> 256 chars on Windows), will likely lead to
-     * cause problems with automated build and test systems.
-     */
-    static final int MAX_SUBPACKAGES_DEPTH = 4;
     @Test
     void testIndexOrdering() throws IOException {
-        final String clsname = "Add";
-        List<String> cmdArgs = new ArrayList();
-        cmdArgs.add("-d");
-        cmdArgs.add("out-2");
-        cmdArgs.add("-sourcepath");
-        cmdArgs.add("src");
-        cmdArgs.add("-package");
-        System.out.println("STRESS_MODE: " + STRESS_MODE);
-        emitFile(null, clsname, STRESS_MODE);
-        for (int width = 0 ; width < MAX_PACKAGES ; width++) {
-            String wpkgname = "add" + width;
-            String dpkgname = wpkgname;
-            emitFile(wpkgname, clsname, ListOrder.NONE); // list as-is
-            cmdArgs.add(wpkgname);
-            for (int depth = 1 ; depth < MAX_SUBPACKAGES_DEPTH ; depth++) {
-                dpkgname = dpkgname + ".add";
-                emitFile(dpkgname, clsname, STRESS_MODE);
-                cmdArgs.add(dpkgname);
-            }
-        }
-        File srcDir = new File(new File("."), "src");
-        cmdArgs.add(new File(srcDir, clsname + ".java").getPath());
-        javadoc(cmdArgs.toArray(new String[cmdArgs.size()]));
-        checkExit(Exit.OK);
-        checkOrder("index-all.html", composeTestVectors());
-        checkOrder("add0/add/package-tree.html", expectedPackageTreeOrdering);
-        checkOrder("overview-tree.html", expectedOverviewOrdering);
-        checkOrder("overview-frame.html", expectedOverviewFrameOrdering);
+        new IndexOrderingTest(this).run();
     }
 
     @Test
     void testIndexTypeClustering() {
-        javadoc("-d", "out-3",
-                "-sourcepath", testSrc("src-2"),
-                "-use",
-                "a",
-                "b",
-                "e",
-                "something");
-        checkOrder("index-all.html", typeTestVectors);
-        checkExit(Exit.OK);
+        new IndexTypeClusteringTest(this).run();
     }
 
     @Test
-    void testMethodDetailOrdering() {
-        javadoc("-d", "out-4",
-                "-sourcepath", testSrc(new File(".").getPath()),
-                "order"
-        );
-        checkOrder("order/MethodOrder.html", methodSourceOrderVectors);
-        checkExit(Exit.OK);
+    void testTypeElementMemberOrdering() {
+        new TypeElementMemberOrderingTest(this).run();
     }
 
-    String[] methodSourceOrderVectors = {
-        "<pre>public&nbsp;void&nbsp;d()</pre>\n" +
-        "<div class=\"block\">Method d.\n" +
-        " Second line.</div>",
-        "<pre>public&nbsp;void&nbsp;b()</pre>\n" +
-        "<div class=\"block\">Method b.\n" +
-        " Second line.</div>",
-        "<pre>public&nbsp;void&nbsp;c()</pre>\n" +
-        "<div class=\"block\">Method c.\n" +
-        " Second line.</div>",
-        "<pre>public&nbsp;void&nbsp;a()</pre>\n" +
-        "<div class=\"block\">Method a.\n" +
-        " Second line.</div>"
-    };
+    static class UnnamedPackageForClassUseTest {
+        final JavadocTester tester;
+
+        UnnamedPackageForClassUseTest(JavadocTester tester) {
+            this.tester = tester;
+        }
+
+        void run() {
+            tester.javadoc("-d", "out",
+                    "-sourcepath", testSrc,
+                    "-use",
+                    tester.testSrc("C.java"), tester.testSrc("UsedInC.java"));
+            tester.checkExit(Exit.OK);
+            checkExecutableMemberOrdering("class-use/UsedInC.html");
+        }
 
-    String[] typeTestVectors = {
-        "something</a> - package something</dt>",
-        "something</span></a> - Class in",
-        "something</span></a> - Enum in",
-        "something</span></a> - Interface in",
-        "something</span></a> - Annotation Type in",
-        "something</a></span> - Variable in class",
-        "something()</a></span> - Constructor",
-        "something()</a></span> - Method in class a.<a href=\"a/A.html\"",
-        "something()</a></span> - Method in class a.<a href=\"a/something.html\"",
-        "something()</a></span> - Method in class something.<a href=\"something/J.html\""
-    };
+        void checkExecutableMemberOrdering(String usePage) {
+            String contents = tester.readFile(usePage);
+            // check constructors
+            tester.checking("constructors");
+            int idx1 = contents.indexOf("C.html#C-UsedInC");
+            int idx2 = contents.indexOf("C.html#C-UsedInC-int");
+            int idx3 = contents.indexOf("C.html#C-UsedInC-java.lang.String");
+            if (idx1 == -1 || idx2 == -1 || idx3 == -1) {
+                tester.failed("ctor strings not found");
+            } else if (idx1 > idx2 || idx2 > idx3 || idx1 > idx3) {
+                tester.failed("ctor strings are out of order");
+            } else {
+                tester.passed("ctor strings are in order");
+            }
 
-    String[] composeTestVectors() {
-        List<String> testList = new ArrayList<>();
+            // check methods
+            tester.checking("methods");
+            idx1 = contents.indexOf("C.html#ymethod-int");
+            idx2 = contents.indexOf("C.html#ymethod-java.lang.String");
+            if (idx1 == -1 || idx2 == -1) {
+                tester.failed("#ymethod strings not found");
+            } else if (idx1 > idx2) {
+                tester.failed("#ymethod strings are out of order");
+            } else {
+                tester.passed("Executable Member Ordering: OK");
+            }
+        }
+    }
 
-        testList.addAll(Arrays.asList(expectedPackageOrdering));
-        for (String x : expectedEnumOrdering) {
-            testList.add(x.replace("REPLACE_ME", "&lt;Unnamed&gt;"));
-            for (int i = 0; i < MAX_PACKAGES; i++) {
-                String wpkg = "add" + i;
-                testList.add(wpkg + "/" + x.replace("REPLACE_ME",
-                        wpkg));
-                String dpkg = wpkg;
-                for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
-                    dpkg = dpkg + "/" + "add";
-                    testList.add(dpkg + "/" + x.replace("REPLACE_ME",
-                            pathToPackage(dpkg)));
-                }
-            }
+    static class NamedPackagesForClassUseTest {
+        final JavadocTester tester;
+
+        NamedPackagesForClassUseTest(JavadocTester tester) {
+            this.tester = tester;
         }
 
-        testList.addAll(Arrays.asList(expectedFieldOrdering));
+        public void run() {
+            tester.javadoc("-d", "out-1",
+                    "-sourcepath", tester.testSrc,
+                    "-use",
+                    "pkg1");
+            tester.checkExit(Exit.OK);
+
+            checkClassUseOrdering("pkg1/class-use/UsedClass.html");
+
+            tester.checkOrder("pkg1/class-use/UsedClass.html",
+                    "../../pkg1/MethodOrder.html#m--",
+                    "../../pkg1/MethodOrder.html#m-byte:A-",
+                    "../../pkg1/MethodOrder.html#m-double-",
+                    "../../pkg1/MethodOrder.html#m-double-double-",
+                    "../../pkg1/MethodOrder.html#m-double-java.lang.Double-",
+                    "../../pkg1/MethodOrder.html#m-int-",
+                    "../../pkg1/MethodOrder.html#m-int-int-",
+                    "../../pkg1/MethodOrder.html#m-int-java.lang.Integer-",
+                    "../../pkg1/MethodOrder.html#m-long-",
+                    "../../pkg1/MethodOrder.html#m-long-long-",
+                    "../../pkg1/MethodOrder.html#m-long-java.lang.Long-",
+                    "../../pkg1/MethodOrder.html#m-long-java.lang.Long...-",
+                    "../../pkg1/MethodOrder.html#m-java.lang.Double-",
+                    "../../pkg1/MethodOrder.html#m-java.lang.Double-double-",
+                    "../../pkg1/MethodOrder.html#m-java.lang.Double-java.lang.Double-",
+                    "../../pkg1/MethodOrder.html#m-java.lang.Integer-",
+                    "../../pkg1/MethodOrder.html#m-java.lang.Integer-int-",
+                    "../../pkg1/MethodOrder.html#m-java.lang.Integer-java.lang.Integer-",
+                    "../../pkg1/MethodOrder.html#m-java.lang.Object:A-",
+                    "../../pkg1/MethodOrder.html#m-java.util.ArrayList-",
+                    "../../pkg1/MethodOrder.html#m-java.util.Collection-",
+                    "../../pkg1/MethodOrder.html#m-java.util.List-");
+
+            tester.checkOrder("pkg1/class-use/UsedClass.html",
+                    "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-",
+                    "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-pkg1.UsedClass-",
+                    "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-pkg1.UsedClass:A-",
+                    "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-java.lang.String-");
 
-        for (String x : expectedMethodOrdering) {
-            testList.add(x);
-            for (int i = 0; i < MAX_PACKAGES; i++) {
-                String wpkg = "add" + i;
-                testList.add(wpkg + "/" + x);
-                String dpkg = wpkg;
-                for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
-                    dpkg = dpkg + "/" + "add";
-                    testList.add(dpkg + "/" + x);
-                }
-            }
+            tester.checkOrder("pkg1/class-use/UsedClass.html",
+                    "../../pkg1/A.html#A-pkg1.UsedClass-",
+                    "../../pkg1/B.A.html#A-pkg1.UsedClass-",
+                    "../../pkg1/B.html#B-pkg1.UsedClass-",
+                    "../../pkg1/A.C.html#C-pkg1.UsedClass-java.lang.Object:A-",
+                    "../../pkg1/A.C.html#C-pkg1.UsedClass-java.util.Collection-",
+                    "../../pkg1/A.C.html#C-pkg1.UsedClass-java.util.List-");
+
+            tester.checkOrder("pkg1/ImplementsOrdering.html",
+                    "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.lang.AutoCloseable</code></dd>",
+                    "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.nio.channels.Channel</code></dd>",
+                    "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.io.Closeable</code></dd>");
+
+            tester.checkOrder("pkg1/OverrideOrdering.html",
+                    "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.util.Collection&lt;",
+                    "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.lang.Iterable&lt;");
+
+            tester.checkOrder("allclasses-noframe.html",
+                    "pkg1/A.html\" title=\"class in pkg1",
+                    "pkg1/A.C.html\" title=\"class in pkg1",
+                    "pkg1/B.html\" title=\"class in pkg1",
+                    "pkg1/B.A.html\" title=\"class in pkg1",
+                    "pkg1/C1.html\" title=\"class in pkg1",
+                    "pkg1/C2.html\" title=\"class in pkg1",
+                    "pkg1/C3.html\" title=\"class in pkg1",
+                    "pkg1/C4.html\" title=\"class in pkg1",
+                    "pkg1/ImplementsOrdering.html\" title=\"interface in pkg1",
+                    "pkg1/MethodOrder.html\" title=\"class in pkg1",
+                    "pkg1/OverrideOrdering.html\" title=\"class in pkg1",
+                    "pkg1/UsedClass.html\" title=\"class in pkg1");
+
+            tester.checkOrder("allclasses-frame.html",
+                    "pkg1/A.html\" title=\"class in pkg1",
+                    "pkg1/A.C.html\" title=\"class in pkg1",
+                    "pkg1/B.html\" title=\"class in pkg1",
+                    "pkg1/B.A.html\" title=\"class in pkg1",
+                    "pkg1/C1.html\" title=\"class in pkg1",
+                    "pkg1/C2.html\" title=\"class in pkg1",
+                    "pkg1/C3.html\" title=\"class in pkg1",
+                    "pkg1/C4.html\" title=\"class in pkg1",
+                    "pkg1/ImplementsOrdering.html\" title=\"interface in pkg1",
+                    "pkg1/MethodOrder.html\" title=\"class in pkg1",
+                    "pkg1/OverrideOrdering.html\" title=\"class in pkg1",
+                    "pkg1/UsedClass.html\" title=\"class in pkg1");
         }
 
-        return testList.toArray(new String[testList.size()]);
-    }
-
-    void checkExecutableMemberOrdering(String usePage) {
-        String contents = readFile(usePage);
-        // check constructors
-        checking("constructors");
-        int idx1 = contents.indexOf("C.html#C-UsedInC");
-        int idx2 = contents.indexOf("C.html#C-UsedInC-int");
-        int idx3 = contents.indexOf("C.html#C-UsedInC-java.lang.String");
-        if (idx1 == -1 || idx2 == -1 || idx3 == -1) {
-            failed("ctor strings not found");
-        } else if (idx1 > idx2 || idx2 > idx3 || idx1 > idx3) {
-            failed("ctor strings are out of order");
-        } else
-            passed("ctor strings are in order");
+        void checkClassUseOrdering(String usePage) {
+            checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zfield");
+            checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#fieldInC#ITERATION#");
+            checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zmethod-pkg1.UsedClass");
+            checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#methodInC#ITERATION#");
+        }
 
-        // check methods
-        checking("methods");
-        idx1 = contents.indexOf("C.html#ymethod-int");
-        idx2 = contents.indexOf("C.html#ymethod-java.lang.String");
-        if (idx1 == -1 || idx2 == -1) {
-            failed("#ymethod strings not found");
-        } else if (idx1 > idx2) {
-            failed("#ymethod strings are out of order");
-        } else
-            passed("Executable Member Ordering: OK");
-    }
-
-    void checkClassUseOrdering(String usePage) {
-        checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zfield");
-        checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#fieldInC#ITERATION#");
-        checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zmethod-pkg1.UsedClass");
-        checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#methodInC#ITERATION#");
-    }
-
-    void checkClassUseOrdering(String usePage, String searchString) {
-        String contents = readFile(usePage);
-        int lastidx = 0;
-        System.out.println("testing for " + searchString);
-        for (int i = 1; i < 5; i++) {
-            String s = searchString.replaceAll("#ITERATION#", Integer.toString(i));
-            checking(s);
-            int idx = contents.indexOf(s);
-            if (idx < lastidx) {
-                failed(s + ", member ordering error, last:" + lastidx + ", got:" + idx);
-            } else {
-                passed("\tlast: " + lastidx + " got:" + idx);
+        void checkClassUseOrdering(String usePage, String searchString) {
+            String contents = tester.readFile(usePage);
+            int lastidx = 0;
+            System.out.println("testing for " + searchString);
+            for (int i = 1; i < 5; i++) {
+                String s = searchString.replaceAll("#ITERATION#", Integer.toString(i));
+                tester.checking(s);
+                int idx = contents.indexOf(s);
+                if (idx < lastidx) {
+                    tester.failed(s + ", member ordering error, last:" + lastidx + ", got:" + idx);
+                } else {
+                    tester.passed("\tlast: " + lastidx + " got:" + idx);
+                }
+                lastidx = idx;
             }
-            lastidx = idx;
         }
     }
 
-    static String[] contents = {
-        "public add ADDADD;",
-        "public add AddAdd;",
-        "public add addadd;",
-        "public enum add {add, ADD, addd, ADDD};",
-        "public enum ADD {ADD, add, addd, ADDD};",
-        "public void   add(){}",
-        "public void   add(double d){}",
-        "public void   add(int i, float f){}",
-        "public void   add(float f, int i){}",
-        "public void   add(double d, byte b){}",
-        "public Double add(Double d) {return (double) 22/7;}",
-        "public double add(double d1, double d2) {return d1 + d2;}",
-        "public double add(double d1, Double  d2) {return d1 + d2;}",
-        "public Float  add(float f) {return (float) 22/7;}",
-        "public void   add(int i){}",
-        "public int    add(Integer i) {return 0;}"
-    };
+    static class IndexOrderingTest {
+        private final JavadocTester tester;
+
+        IndexOrderingTest(JavadocTester tester) {
+            this.tester = tester;
+        }
+
+        enum ListOrder {
+            NONE, REVERSE, SHUFFLE
+        };
+
+        /*
+         * By default we do not shuffle the input list, in order to keep the list deterministic,
+         * and the test predictable. However, we can turn on the stress mode, by setting the following
+         * property if required.
+         */
+        static final ListOrder STRESS_MODE = Boolean.getBoolean("TestOrder.STRESS")
+                ? ListOrder.SHUFFLE
+                : ListOrder.REVERSE;
+
+        /*
+         * Controls the number of children packages, pkg0, pkg0.pkg, pkg0.pkg.pkg, .....
+         * Note: having too long a depth (> 256 chars on Windows), will likely lead to
+         * cause problems with automated build and test systems.
+         */
+        static final int MAX_SUBPACKAGES_DEPTH = 4;
+
+        /*
+         * Controls the number of sibling packages,  pkg0, pkg1, pkg2, .....
+         */
+        static final int MAX_PACKAGES = 4;
+
+        static String[] contents = {
+            "public add ADDADD;",
+            "public add AddAdd;",
+            "public add addadd;",
+            "public enum add {add, ADD, addd, ADDD};",
+            "public enum ADD {ADD, add, addd, ADDD};",
+            "public void   add(){}",
+            "public void   add(double d){}",
+            "public void   add(int i, float f){}",
+            "public void   add(float f, int i){}",
+            "public void   add(double d, byte b){}",
+            "public Double add(Double d) {return (double) 22/7;}",
+            "public double add(double d1, double d2) {return d1 + d2;}",
+            "public double add(double d1, Double  d2) {return d1 + d2;}",
+            "public Float  add(float f) {return (float) 22/7;}",
+            "public void   add(int i){}",
+            "public int    add(Integer i) {return 0;}"
+        };
+
+        static String expectedEnumOrdering[] = {
+            "Add.add.html\" title=\"enum in REPLACE_ME\"",
+            "Add.ADD.html\" title=\"enum in REPLACE_ME\""
+        };
+
+        static String expectedFieldOrdering[] = {
+            "Add.html#addadd\"",
+            "add0/add/add/add/Add.html#addadd\"",
+            "add0/add/add/Add.html#addadd\"",
+            "add0/add/Add.html#addadd\"",
+            "add0/Add.html#addadd\"",
+            "add1/add/add/add/Add.html#addadd\"",
+            "add1/add/add/Add.html#addadd\"",
+            "add1/add/Add.html#addadd\"",
+            "add1/Add.html#addadd\"",
+            "add2/add/add/add/Add.html#addadd\"",
+            "add2/add/add/Add.html#addadd\"",
+            "add2/add/Add.html#addadd\"",
+            "add2/Add.html#addadd\"",
+            "add3/add/add/add/Add.html#addadd\"",
+            "add3/add/add/Add.html#addadd\"",
+            "add3/add/Add.html#addadd\"",
+            "add3/Add.html#addadd\"",
+            "Add.html#AddAdd\"",
+            "add0/add/add/add/Add.html#AddAdd\"",
+            "add0/add/add/Add.html#AddAdd\"",
+            "add0/add/Add.html#AddAdd\"",
+            "add0/Add.html#AddAdd\"",
+            "add1/add/add/add/Add.html#AddAdd\"",
+            "add1/add/add/Add.html#AddAdd\"",
+            "add1/add/Add.html#AddAdd\"",
+            "add1/Add.html#AddAdd\"",
+            "add2/add/add/add/Add.html#AddAdd\"",
+            "add2/add/add/Add.html#AddAdd\"",
+            "add2/add/Add.html#AddAdd\"",
+            "add2/Add.html#AddAdd\"",
+            "add3/add/add/add/Add.html#AddAdd\"",
+            "add3/add/add/Add.html#AddAdd\"",
+            "add3/add/Add.html#AddAdd\"",
+            "add3/Add.html#AddAdd\"",
+            "Add.html#ADDADD\"",
+            "add0/add/add/add/Add.html#ADDADD\"",
+            "add0/add/add/Add.html#ADDADD\"",
+            "add0/add/Add.html#ADDADD\"",
+            "add0/Add.html#ADDADD\"",
+            "add1/add/add/add/Add.html#ADDADD\"",
+            "add1/add/add/Add.html#ADDADD\"",
+            "add1/add/Add.html#ADDADD\"",
+            "add1/Add.html#ADDADD\"",
+            "add2/add/add/add/Add.html#ADDADD\"",
+            "add2/add/add/Add.html#ADDADD\"",
+            "add2/add/Add.html#ADDADD\"",
+            "add2/Add.html#ADDADD\"",
+            "add3/add/add/add/Add.html#ADDADD\"",
+            "add3/add/add/Add.html#ADDADD\"",
+            "add3/add/Add.html#ADDADD\"",
+            "add3/Add.html#ADDADD\""
+        };
+
+        static String expectedMethodOrdering[] = {
+            "Add.html#add--",
+            "Add.html#add-double-",
+            "Add.html#add-double-byte-",
+            "Add.html#add-double-double-",
+            "Add.html#add-double-java.lang.Double-",
+            "Add.html#add-float-",
+            "Add.html#add-float-int-",
+            "Add.html#add-int-",
+            "Add.html#add-int-float-",
+            "Add.html#add-java.lang.Double-",
+            "Add.html#add-java.lang.Integer-"
+        };
+
+        static String expectedPackageOrdering[] = {
+            "\"add0/package-summary.html\">add0</a> - package add0",
+            "\"add0/add/package-summary.html\">add0.add</a> - package add0.add",
+            "\"add0/add/add/package-summary.html\">add0.add.add</a> - package add0.add.add",
+            "\"add0/add/add/add/package-summary.html\">add0.add.add.add</a> - package add0.add.add.add",
+            "\"add1/package-summary.html\">add1</a> - package add1",
+            "\"add1/add/package-summary.html\">add1.add</a> - package add1.add",
+            "\"add1/add/add/package-summary.html\">add1.add.add</a> - package add1.add.add",
+            "\"add1/add/add/add/package-summary.html\">add1.add.add.add</a> - package add1.add.add.add",
+            "\"add2/package-summary.html\">add2</a> - package add2",
+            "\"add2/add/package-summary.html\">add2.add</a> - package add2.add",
+            "\"add2/add/add/package-summary.html\">add2.add.add</a> - package add2.add.add",
+            "\"add2/add/add/add/package-summary.html\">add2.add.add.add</a> - package add2.add.add.add",
+            "\"add3/package-summary.html\">add3</a> - package add3",
+            "\"add3/add/package-summary.html\">add3.add</a> - package add3.add",
+            "\"add3/add/add/package-summary.html\">add3.add.add</a> - package add3.add.add",
+            "\"add3/add/add/add/package-summary.html\">add3.add.add.add</a> - package add3.add.add.add"
+        };
 
-    void emitFile(String pkgname, String clsname, ListOrder order) throws IOException {
-        File srcDir = new File("src");
-        File outDir = pkgname == null
-            ? srcDir
-            : new File(srcDir, pkgname.replace(".", File.separator));
-        File outFile = new File(outDir, clsname + ".java");
-        outDir.mkdirs();
-        List<String> scratch = new ArrayList<>(Arrays.asList(contents));
-        switch (order) {
-            case SHUFFLE:
-                Collections.shuffle(scratch);
-                break;
-            case REVERSE:
-                Collections.reverse(scratch);
-                break;
-            default:
+        void run() throws IOException {
+            final String clsname = "Add";
+            List<String> cmdArgs = new ArrayList();
+            cmdArgs.add("-d");
+            cmdArgs.add("out-2");
+            cmdArgs.add("-sourcepath");
+            cmdArgs.add("src");
+            cmdArgs.add("-package");
+            System.out.println("STRESS_MODE: " + STRESS_MODE);
+            emitFile(null, clsname, STRESS_MODE);
+            for (int width = 0; width < MAX_PACKAGES; width++) {
+                String wpkgname = "add" + width;
+                String dpkgname = wpkgname;
+                emitFile(wpkgname, clsname, ListOrder.NONE); // list as-is
+                cmdArgs.add(wpkgname);
+                for (int depth = 1; depth < MAX_SUBPACKAGES_DEPTH; depth++) {
+                    dpkgname = dpkgname + ".add";
+                    emitFile(dpkgname, clsname, STRESS_MODE);
+                    cmdArgs.add(dpkgname);
+                }
+            }
+            File srcDir = new File(new File("."), "src");
+            cmdArgs.add(new File(srcDir, clsname + ".java").getPath());
+            tester.javadoc(cmdArgs.toArray(new String[cmdArgs.size()]));
+            tester.checkExit(Exit.OK);
+            tester.checkOrder("index-all.html", composeTestVectors());
+            tester.checkOrder("add0/add/package-tree.html",
+                    "<a href=\"../../add0/add/Add.add.html\" title=\"enum in add0.add\">",
+                    "<a href=\"../../add0/add/Add.ADD.html\" title=\"enum in add0.add\">");
+            tester.checkOrder("overview-tree.html",
+                    "<a href=\"Add.add.html\" title=\"enum in &lt;Unnamed&gt;\">",
+                    "<a href=\"add0/Add.add.html\" title=\"enum in add0\">",
+                    "<a href=\"add0/add/Add.add.html\" title=\"enum in add0.add\">",
+                    "<a href=\"add0/add/add/Add.add.html\" title=\"enum in add0.add.add\">",
+                    "<a href=\"add0/add/add/add/Add.add.html\" title=\"enum in add0.add.add.add\">",
+                    "<a href=\"add1/Add.add.html\" title=\"enum in add1\">",
+                    "<a href=\"add1/add/Add.add.html\" title=\"enum in add1.add\">",
+                    "<a href=\"add1/add/add/Add.add.html\" title=\"enum in add1.add.add\">",
+                    "<a href=\"add1/add/add/add/Add.add.html\" title=\"enum in add1.add.add.add\">",
+                    "<a href=\"add2/Add.add.html\" title=\"enum in add2\">",
+                    "<a href=\"add2/add/Add.add.html\" title=\"enum in add2.add\">",
+                    "<a href=\"add2/add/add/Add.add.html\" title=\"enum in add2.add.add\">",
+                    "<a href=\"add2/add/add/add/Add.add.html\" title=\"enum in add2.add.add.add\">",
+                    "<a href=\"add3/Add.add.html\" title=\"enum in add3\">",
+                    "<a href=\"add3/add/Add.add.html\" title=\"enum in add3.add\">",
+                    "<a href=\"add3/add/add/Add.add.html\" title=\"enum in add3.add.add\">",
+                    "<a href=\"add3/add/add/add/Add.add.html\" title=\"enum in add3.add.add.add\">",
+                    "<a href=\"Add.ADD.html\" title=\"enum in &lt;Unnamed&gt;\">",
+                    "<a href=\"add0/Add.ADD.html\" title=\"enum in add0\">",
+                    "<a href=\"add0/add/Add.ADD.html\" title=\"enum in add0.add\">",
+                    "<a href=\"add0/add/add/Add.ADD.html\" title=\"enum in add0.add.add\">",
+                    "<a href=\"add0/add/add/add/Add.ADD.html\" title=\"enum in add0.add.add.add\">",
+                    "<a href=\"add1/Add.ADD.html\" title=\"enum in add1\">",
+                    "<a href=\"add1/add/Add.ADD.html\" title=\"enum in add1.add\">",
+                    "<a href=\"add1/add/add/Add.ADD.html\" title=\"enum in add1.add.add\">",
+                    "<a href=\"add1/add/add/add/Add.ADD.html\" title=\"enum in add1.add.add.add\">",
+                    "<a href=\"add2/Add.ADD.html\" title=\"enum in add2\">",
+                    "<a href=\"add2/add/Add.ADD.html\" title=\"enum in add2.add\">",
+                    "<a href=\"add2/add/add/Add.ADD.html\" title=\"enum in add2.add.add\">",
+                    "<a href=\"add2/add/add/add/Add.ADD.html\" title=\"enum in add2.add.add.add\">",
+                    "<a href=\"add3/Add.ADD.html\" title=\"enum in add3\">",
+                    "<a href=\"add3/add/Add.ADD.html\" title=\"enum in add3.add\">",
+                    "<a href=\"add3/add/add/Add.ADD.html\" title=\"enum in add3.add.add\">",
+                    "<a href=\"add3/add/add/add/Add.ADD.html\" title=\"enum in add3.add.add.add\">");
+
+            tester.checkOrder("overview-frame.html",
+                    "<a href=\"package-frame.html\" target=\"packageFrame\">&lt;unnamed package&gt;</a>",
+                    "<a href=\"add0/package-frame.html\" target=\"packageFrame\">add0</a>",
+                    "<a href=\"add0/add/package-frame.html\" target=\"packageFrame\">add0.add</a>",
+                    "<a href=\"add0/add/add/package-frame.html\" target=\"packageFrame\">add0.add.add</a>",
+                    "<a href=\"add0/add/add/add/package-frame.html\" target=\"packageFrame\">add0.add.add.add</a>",
+                    "<a href=\"add1/package-frame.html\" target=\"packageFrame\">add1</a>",
+                    "<a href=\"add1/add/package-frame.html\" target=\"packageFrame\">add1.add</a>",
+                    "<a href=\"add1/add/add/package-frame.html\" target=\"packageFrame\">add1.add.add</a>",
+                    "<a href=\"add1/add/add/add/package-frame.html\" target=\"packageFrame\">add1.add.add.add</a>",
+                    "<a href=\"add2/package-frame.html\" target=\"packageFrame\">add2</a>",
+                    "<a href=\"add2/add/package-frame.html\" target=\"packageFrame\">add2.add</a>",
+                    "<a href=\"add2/add/add/package-frame.html\" target=\"packageFrame\">add2.add.add</a>",
+                    "<a href=\"add2/add/add/add/package-frame.html\" target=\"packageFrame\">add2.add.add.add</a>",
+                    "<a href=\"add3/package-frame.html\" target=\"packageFrame\">add3</a>",
+                    "<a href=\"add3/add/package-frame.html\" target=\"packageFrame\">add3.add</a>",
+                    "<a href=\"add3/add/add/package-frame.html\" target=\"packageFrame\">add3.add.add</a>",
+                    "<a href=\"add3/add/add/add/package-frame.html\" target=\"packageFrame\">add3.add.add.add</a></li>");
+        }
+
+        void emitFile(String pkgname, String clsname, ListOrder order) throws IOException {
+            File srcDir = new File("src");
+            File outDir = pkgname == null
+                    ? srcDir
+                    : new File(srcDir, pkgname.replace(".", File.separator));
+            File outFile = new File(outDir, clsname + ".java");
+            outDir.mkdirs();
+            List<String> scratch = new ArrayList<>(Arrays.asList(contents));
+            switch (order) {
+                case SHUFFLE:
+                    Collections.shuffle(scratch);
+                    break;
+                case REVERSE:
+                    Collections.reverse(scratch);
+                    break;
+                default:
                 // leave list as-is
-        }
-        // insert the header
-        scratch.add(0, "public class " + clsname + " {");
-        if (pkgname != null) {
-            scratch.add(0, "package " + pkgname + ";");
+            }
+            // insert the header
+            scratch.add(0, "public class " + clsname + " {");
+            if (pkgname != null) {
+                scratch.add(0, "package " + pkgname + ";");
+            }
+            // append the footer
+            scratch.add("}");
+            Files.write(outFile.toPath(), scratch, CREATE, TRUNCATE_EXISTING);
         }
-        // append the footer
-        scratch.add("}");
-        Files.write(outFile.toPath(), scratch, CREATE, TRUNCATE_EXISTING);
-    }
+
+        String[] composeTestVectors() {
+            List<String> testList = new ArrayList<>();
+
+            testList.addAll(Arrays.asList(expectedPackageOrdering));
+            for (String x : expectedEnumOrdering) {
+                testList.add(x.replace("REPLACE_ME", "&lt;Unnamed&gt;"));
+                for (int i = 0; i < MAX_PACKAGES; i++) {
+                    String wpkg = "add" + i;
+                    testList.add(wpkg + "/" + x.replace("REPLACE_ME",
+                            wpkg));
+                    String dpkg = wpkg;
+                    for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
+                        dpkg = dpkg + "/" + "add";
+                        testList.add(dpkg + "/" + x.replace("REPLACE_ME", pathToPackage(dpkg)));
+                    }
+                }
+            }
 
-    String pathToPackage(String in) {
-        return in.replace("/", ".");
+            testList.addAll(Arrays.asList(expectedFieldOrdering));
+
+            for (String x : expectedMethodOrdering) {
+                testList.add(x);
+                for (int i = 0; i < MAX_PACKAGES; i++) {
+                    String wpkg = "add" + i;
+                    testList.add(wpkg + "/" + x);
+                    String dpkg = wpkg;
+                    for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
+                        dpkg = dpkg + "/" + "add";
+                        testList.add(dpkg + "/" + x);
+                    }
+                }
+            }
+
+            return testList.toArray(new String[testList.size()]);
+        }
+
+        String pathToPackage(String in) {
+            return in.replace("/", ".");
+        }
     }
 
-    final String expectedAllClasses[] = {
-        "pkg1/A.html\" title=\"class in pkg1",
-        "pkg1/A.C.html\" title=\"class in pkg1",
-        "pkg1/B.html\" title=\"class in pkg1",
-        "pkg1/B.A.html\" title=\"class in pkg1",
-        "pkg1/C1.html\" title=\"class in pkg1",
-        "pkg1/C2.html\" title=\"class in pkg1",
-        "pkg1/C3.html\" title=\"class in pkg1",
-        "pkg1/C4.html\" title=\"class in pkg1",
-        "pkg1/ImplementsOrdering.html\" title=\"interface in pkg1",
-        "pkg1/MethodOrder.html\" title=\"class in pkg1",
-        "pkg1/OverrideOrdering.html\" title=\"class in pkg1",
-        "pkg1/UsedClass.html\" title=\"class in pkg1"
+    static class IndexTypeClusteringTest {
+
+        private final JavadocTester tester;
+
+        IndexTypeClusteringTest(JavadocTester tester) {
+            this.tester = tester;
+        }
 
-    };
+        void run() {
+            tester.javadoc("-d", "out-3",
+                    "-sourcepath", tester.testSrc("src-2"),
+                    "-use",
+                    "a",
+                    "b",
+                    "e",
+                    "something");
+
+            tester.checkExit(Exit.OK);
 
-    final String expectedInnerClassContructors[] = {
-        "../../pkg1/A.html#A-pkg1.UsedClass-",
-        "../../pkg1/B.A.html#A-pkg1.UsedClass-",
-        "../../pkg1/B.html#B-pkg1.UsedClass-",
-        "../../pkg1/A.C.html#C-pkg1.UsedClass-java.lang.Object:A-",
-        "../../pkg1/A.C.html#C-pkg1.UsedClass-java.util.Collection-",
-        "../../pkg1/A.C.html#C-pkg1.UsedClass-java.util.List-"
-    };
+            tester.checkOrder("index-all.html",
+                    "something</a> - package something</dt>",
+                    "something</span></a> - Class in",
+                    "something</span></a> - Enum in",
+                    "something</span></a> - Interface in",
+                    "something</span></a> - Annotation Type in",
+                    "something</a></span> - Variable in class",
+                    "something()</a></span> - Constructor",
+                    "something()</a></span> - Method in class a.<a href=\"a/A.html\"",
+                    "something()</a></span> - Method in class a.<a href=\"a/something.html\"",
+                    "something()</a></span> - Method in class something.<a href=\"something/J.html\"");
+        }
+    }
 
-    final String expectedClassUseMethodOrdering[] = {
-        "../../pkg1/MethodOrder.html#m--",
-        "../../pkg1/MethodOrder.html#m-byte:A-",
-        "../../pkg1/MethodOrder.html#m-double-",
-        "../../pkg1/MethodOrder.html#m-double-double-",
-        "../../pkg1/MethodOrder.html#m-double-java.lang.Double-",
-        "../../pkg1/MethodOrder.html#m-int-",
-        "../../pkg1/MethodOrder.html#m-int-int-",
-        "../../pkg1/MethodOrder.html#m-int-java.lang.Integer-",
-        "../../pkg1/MethodOrder.html#m-long-",
-        "../../pkg1/MethodOrder.html#m-long-long-",
-        "../../pkg1/MethodOrder.html#m-long-java.lang.Long-",
-        "../../pkg1/MethodOrder.html#m-long-java.lang.Long...-",
-        "../../pkg1/MethodOrder.html#m-java.lang.Double-",
-        "../../pkg1/MethodOrder.html#m-java.lang.Double-double-",
-        "../../pkg1/MethodOrder.html#m-java.lang.Double-java.lang.Double-",
-        "../../pkg1/MethodOrder.html#m-java.lang.Integer-",
-        "../../pkg1/MethodOrder.html#m-java.lang.Integer-int-",
-        "../../pkg1/MethodOrder.html#m-java.lang.Integer-java.lang.Integer-",
-        "../../pkg1/MethodOrder.html#m-java.lang.Object:A-",
-        "../../pkg1/MethodOrder.html#m-java.util.ArrayList-",
-        "../../pkg1/MethodOrder.html#m-java.util.Collection-",
-        "../../pkg1/MethodOrder.html#m-java.util.List-"
-    };
+    static class TypeElementMemberOrderingTest {
+
+        final JavadocTester tester;
+
+        TypeElementMemberOrderingTest(JavadocTester tester) {
+            this.tester = tester;
+        }
 
-    final String expectedClassUseWithTypeParams[] = {
-        "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-",
-        "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-pkg1.UsedClass-",
-        "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-pkg1.UsedClass:A-",
-        "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-java.lang.String-"
-    };
+        void run() {
+            tester.javadoc("-d", "out-5",
+                    "-javafx",
+                    "-sourcepath", tester.testSrc(new File(".").getPath()),
+                    "pkg5"
+            );
+
+            tester.checkExit(Exit.OK);
 
-    final String expectedPackageOrdering[] = {
-        "\"add0/package-summary.html\">add0</a> - package add0",
-        "\"add0/add/package-summary.html\">add0.add</a> - package add0.add",
-        "\"add0/add/add/package-summary.html\">add0.add.add</a> - package add0.add.add",
-        "\"add0/add/add/add/package-summary.html\">add0.add.add.add</a> - package add0.add.add.add",
-        "\"add1/package-summary.html\">add1</a> - package add1",
-        "\"add1/add/package-summary.html\">add1.add</a> - package add1.add",
-        "\"add1/add/add/package-summary.html\">add1.add.add</a> - package add1.add.add",
-        "\"add1/add/add/add/package-summary.html\">add1.add.add.add</a> - package add1.add.add.add",
-        "\"add2/package-summary.html\">add2</a> - package add2",
-        "\"add2/add/package-summary.html\">add2.add</a> - package add2.add",
-        "\"add2/add/add/package-summary.html\">add2.add.add</a> - package add2.add.add",
-        "\"add2/add/add/add/package-summary.html\">add2.add.add.add</a> - package add2.add.add.add",
-        "\"add3/package-summary.html\">add3</a> - package add3",
-        "\"add3/add/package-summary.html\">add3.add</a> - package add3.add",
-        "\"add3/add/add/package-summary.html\">add3.add.add</a> - package add3.add.add",
-        "\"add3/add/add/add/package-summary.html\">add3.add.add.add</a> - package add3.add.add.add"
-    };
+            tester.checkOrder("pkg5/AnnoFieldTest.html",
+                    "<h3>Field Detail</h3>",
+                    "<pre>static final&nbsp;int&nbsp;one</pre>",
+                    "<pre>static final&nbsp;int&nbsp;two</pre>",
+                    "<pre>static final&nbsp;int&nbsp;three</pre>",
+                    "<pre>static final&nbsp;int&nbsp;four</pre>");
 
-    final String expectedMethodOrdering[] = {
-        "Add.html#add--",
-        "Add.html#add-double-",
-        "Add.html#add-double-byte-",
-        "Add.html#add-double-double-",
-        "Add.html#add-double-java.lang.Double-",
-        "Add.html#add-float-",
-        "Add.html#add-float-int-",
-        "Add.html#add-int-",
-        "Add.html#add-int-float-",
-        "Add.html#add-java.lang.Double-",
-        "Add.html#add-java.lang.Integer-"
-    };
-
-    final String expectedEnumOrdering[] = {
-        "Add.add.html\" title=\"enum in REPLACE_ME\"",
-        "Add.ADD.html\" title=\"enum in REPLACE_ME\""
-    };
+            tester.checkOrder("pkg5/AnnoOptionalTest.html",
+                    "<h3>Optional Element Summary</h3>",
+                    "<a href=\"../pkg5/AnnoOptionalTest.html#four--\">four</a>",
+                    "<a href=\"../pkg5/AnnoOptionalTest.html#one--\">one</a>",
+                    "<a href=\"../pkg5/AnnoOptionalTest.html#three--\">three</a>",
+                    "<a href=\"../pkg5/AnnoOptionalTest.html#two--\">two</a>",
+                    "<h3>Element Detail</h3>",
+                    "<h4>one</h4>",
+                    "<h4>two</h4>",
+                    "<h4>three</h4>",
+                    "<h4>four</h4>");
 
-    final String expectedFieldOrdering[] = {
-        "Add.html#addadd\"",
-        "add0/add/add/add/Add.html#addadd\"",
-        "add0/add/add/Add.html#addadd\"",
-        "add0/add/Add.html#addadd\"",
-        "add0/Add.html#addadd\"",
-        "add1/add/add/add/Add.html#addadd\"",
-        "add1/add/add/Add.html#addadd\"",
-        "add1/add/Add.html#addadd\"",
-        "add1/Add.html#addadd\"",
-        "add2/add/add/add/Add.html#addadd\"",
-        "add2/add/add/Add.html#addadd\"",
-        "add2/add/Add.html#addadd\"",
-        "add2/Add.html#addadd\"",
-        "add3/add/add/add/Add.html#addadd\"",
-        "add3/add/add/Add.html#addadd\"",
-        "add3/add/Add.html#addadd\"",
-        "add3/Add.html#addadd\"",
-        "Add.html#AddAdd\"",
-        "add0/add/add/add/Add.html#AddAdd\"",
-        "add0/add/add/Add.html#AddAdd\"",
-        "add0/add/Add.html#AddAdd\"",
-        "add0/Add.html#AddAdd\"",
-        "add1/add/add/add/Add.html#AddAdd\"",
-        "add1/add/add/Add.html#AddAdd\"",
-        "add1/add/Add.html#AddAdd\"",
-        "add1/Add.html#AddAdd\"",
-        "add2/add/add/add/Add.html#AddAdd\"",
-        "add2/add/add/Add.html#AddAdd\"",
-        "add2/add/Add.html#AddAdd\"",
-        "add2/Add.html#AddAdd\"",
-        "add3/add/add/add/Add.html#AddAdd\"",
-        "add3/add/add/Add.html#AddAdd\"",
-        "add3/add/Add.html#AddAdd\"",
-        "add3/Add.html#AddAdd\"",
-        "Add.html#ADDADD\"",
-        "add0/add/add/add/Add.html#ADDADD\"",
-        "add0/add/add/Add.html#ADDADD\"",
-        "add0/add/Add.html#ADDADD\"",
-        "add0/Add.html#ADDADD\"",
-        "add1/add/add/add/Add.html#ADDADD\"",
-        "add1/add/add/Add.html#ADDADD\"",
-        "add1/add/Add.html#ADDADD\"",
-        "add1/Add.html#ADDADD\"",
-        "add2/add/add/add/Add.html#ADDADD\"",
-        "add2/add/add/Add.html#ADDADD\"",
-        "add2/add/Add.html#ADDADD\"",
-        "add2/Add.html#ADDADD\"",
-        "add3/add/add/add/Add.html#ADDADD\"",
-        "add3/add/add/Add.html#ADDADD\"",
-        "add3/add/Add.html#ADDADD\"",
-        "add3/Add.html#ADDADD\""
-    };
+            tester.checkOrder("pkg5/AnnoRequiredTest.html",
+                    "<h3>Required Element Summary</h3>",
+                    "<a href=\"../pkg5/AnnoRequiredTest.html#four--\">four</a>",
+                    "<a href=\"../pkg5/AnnoRequiredTest.html#one--\">one</a>",
+                    "<a href=\"../pkg5/AnnoRequiredTest.html#three--\">three</a>",
+                    "<a href=\"../pkg5/AnnoRequiredTest.html#two--\">two</a>",
+                    "<h3>Element Detail</h3>",
+                    "<h4>one</h4>",
+                    "<h4>two</h4>",
+                    "<h4>three</h4>",
+                    "<h4>four</h4>");
 
-    final String expectedPackageTreeOrdering[] = {
-        "<a href=\"../../add0/add/Add.add.html\" title=\"enum in add0.add\">",
-        "<a href=\"../../add0/add/Add.ADD.html\" title=\"enum in add0.add\">"
-    };
+            tester.checkOrder("pkg5/CtorTest.html",
+                    "<h3>Constructor Summary</h3>",
+                    "<a href=\"../pkg5/CtorTest.html#CtorTest-int-\"",
+                    "<a href=\"../pkg5/CtorTest.html#CtorTest-int-int-\"",
+                    "<a href=\"../pkg5/CtorTest.html#CtorTest-int-int-int-\"",
+                    "<a href=\"../pkg5/CtorTest.html#CtorTest-int-int-int-int-\"",
+                    "<h3>Constructor Detail</h3>",
+                    "<a name=\"CtorTest-int-int-int-int-\">",
+                    "<a name=\"CtorTest-int-int-int-\">",
+                    "<a name=\"CtorTest-int-int-\">",
+                    "<a name=\"CtorTest-int-\">");
+
+            tester.checkOrder("pkg5/EnumTest.html",
+                    "<h3>Enum Constant Summary</h3>",
+                    "<a href=\"../pkg5/EnumTest.html#FOUR\">FOUR</a>",
+                    "<a href=\"../pkg5/EnumTest.html#ONE\">ONE</a>",
+                    "<a href=\"../pkg5/EnumTest.html#THREE\">THREE</a>",
+                    "<a href=\"../pkg5/EnumTest.html#TWO\">TWO</a>",
+                    "<h3>Enum Constant Detail</h3>",
+                    "<h4>ONE</h4>",
+                    "<h4>TWO</h4>",
+                    "<h4>THREE</h4>",
+                    "<h4>FOUR</h4>");
 
-    final String expectedOverviewOrdering[] = {
-        "<a href=\"Add.add.html\" title=\"enum in &lt;Unnamed&gt;\">",
-        "<a href=\"add0/Add.add.html\" title=\"enum in add0\">",
-        "<a href=\"add0/add/Add.add.html\" title=\"enum in add0.add\">",
-        "<a href=\"add0/add/add/Add.add.html\" title=\"enum in add0.add.add\">",
-        "<a href=\"add0/add/add/add/Add.add.html\" title=\"enum in add0.add.add.add\">",
-        "<a href=\"add1/Add.add.html\" title=\"enum in add1\">",
-        "<a href=\"add1/add/Add.add.html\" title=\"enum in add1.add\">",
-        "<a href=\"add1/add/add/Add.add.html\" title=\"enum in add1.add.add\">",
-        "<a href=\"add1/add/add/add/Add.add.html\" title=\"enum in add1.add.add.add\">",
-        "<a href=\"add2/Add.add.html\" title=\"enum in add2\">",
-        "<a href=\"add2/add/Add.add.html\" title=\"enum in add2.add\">",
-        "<a href=\"add2/add/add/Add.add.html\" title=\"enum in add2.add.add\">",
-        "<a href=\"add2/add/add/add/Add.add.html\" title=\"enum in add2.add.add.add\">",
-        "<a href=\"add3/Add.add.html\" title=\"enum in add3\">",
-        "<a href=\"add3/add/Add.add.html\" title=\"enum in add3.add\">",
-        "<a href=\"add3/add/add/Add.add.html\" title=\"enum in add3.add.add\">",
-        "<a href=\"add3/add/add/add/Add.add.html\" title=\"enum in add3.add.add.add\">",
-        "<a href=\"Add.ADD.html\" title=\"enum in &lt;Unnamed&gt;\">",
-        "<a href=\"add0/Add.ADD.html\" title=\"enum in add0\">",
-        "<a href=\"add0/add/Add.ADD.html\" title=\"enum in add0.add\">",
-        "<a href=\"add0/add/add/Add.ADD.html\" title=\"enum in add0.add.add\">",
-        "<a href=\"add0/add/add/add/Add.ADD.html\" title=\"enum in add0.add.add.add\">",
-        "<a href=\"add1/Add.ADD.html\" title=\"enum in add1\">",
-        "<a href=\"add1/add/Add.ADD.html\" title=\"enum in add1.add\">",
-        "<a href=\"add1/add/add/Add.ADD.html\" title=\"enum in add1.add.add\">",
-        "<a href=\"add1/add/add/add/Add.ADD.html\" title=\"enum in add1.add.add.add\">",
-        "<a href=\"add2/Add.ADD.html\" title=\"enum in add2\">",
-        "<a href=\"add2/add/Add.ADD.html\" title=\"enum in add2.add\">",
-        "<a href=\"add2/add/add/Add.ADD.html\" title=\"enum in add2.add.add\">",
-        "<a href=\"add2/add/add/add/Add.ADD.html\" title=\"enum in add2.add.add.add\">",
-        "<a href=\"add3/Add.ADD.html\" title=\"enum in add3\">",
-        "<a href=\"add3/add/Add.ADD.html\" title=\"enum in add3.add\">",
-        "<a href=\"add3/add/add/Add.ADD.html\" title=\"enum in add3.add.add\">",
-        "<a href=\"add3/add/add/add/Add.ADD.html\" title=\"enum in add3.add.add.add\">",
-    };
+            tester.checkOrder("pkg5/FieldTest.html",
+                    "<h3>Field Summary</h3>",
+                    "<a href=\"../pkg5/FieldTest.html#four\">four</a>",
+                    "<a href=\"../pkg5/FieldTest.html#one\">one</a>",
+                    "<a href=\"../pkg5/FieldTest.html#three\">three</a>",
+                    "<a href=\"../pkg5/FieldTest.html#two\">two</a>",
+                    "<h3>Field Detail</h3>",
+                    "<h4>one</h4>",
+                    "<h4>two</h4>",
+                    "<h4>three</h4>",
+                    "<h4>four</h4>");
+
+            tester.checkOrder("pkg5/IntfTest.html",
+                    "<h3>Method Summary</h3>",
+                    "<a href=\"../pkg5/IntfTest.html#four--\">four</a>",
+                    "<a href=\"../pkg5/IntfTest.html#one--\">one</a>",
+                    "<a href=\"../pkg5/IntfTest.html#three--\">three</a>",
+                    "<a href=\"../pkg5/IntfTest.html#two--\">two</a>",
+                    "<h3>Method Detail</h3>",
+                    "<h4>one</h4>",
+                    "<h4>two</h4>",
+                    "<h4>three</h4>",
+                    "<h4>four</h4>");
 
-    final static String expectedOverviewFrameOrdering[] = {
-        "<a href=\"package-frame.html\" target=\"packageFrame\">&lt;unnamed package&gt;</a>",
-        "<a href=\"add0/package-frame.html\" target=\"packageFrame\">add0</a>",
-        "<a href=\"add0/add/package-frame.html\" target=\"packageFrame\">add0.add</a>",
-        "<a href=\"add0/add/add/package-frame.html\" target=\"packageFrame\">add0.add.add</a>",
-        "<a href=\"add0/add/add/add/package-frame.html\" target=\"packageFrame\">add0.add.add.add</a>",
-        "<a href=\"add1/package-frame.html\" target=\"packageFrame\">add1</a>",
-        "<a href=\"add1/add/package-frame.html\" target=\"packageFrame\">add1.add</a>",
-        "<a href=\"add1/add/add/package-frame.html\" target=\"packageFrame\">add1.add.add</a>",
-        "<a href=\"add1/add/add/add/package-frame.html\" target=\"packageFrame\">add1.add.add.add</a>",
-        "<a href=\"add2/package-frame.html\" target=\"packageFrame\">add2</a>",
-        "<a href=\"add2/add/package-frame.html\" target=\"packageFrame\">add2.add</a>",
-        "<a href=\"add2/add/add/package-frame.html\" target=\"packageFrame\">add2.add.add</a>",
-        "<a href=\"add2/add/add/add/package-frame.html\" target=\"packageFrame\">add2.add.add.add</a>",
-        "<a href=\"add3/package-frame.html\" target=\"packageFrame\">add3</a>",
-        "<a href=\"add3/add/package-frame.html\" target=\"packageFrame\">add3.add</a>",
-        "<a href=\"add3/add/add/package-frame.html\" target=\"packageFrame\">add3.add.add</a>",
-        "<a href=\"add3/add/add/add/package-frame.html\" target=\"packageFrame\">add3.add.add.add</a></li>"
-    };
+            tester.checkOrder("pkg5/MethodTest.html",
+                    "<h3>Method Summary</h3>",
+                    "<a href=\"../pkg5/MethodTest.html#four--\">four</a>",
+                    "<a href=\"../pkg5/MethodTest.html#one--\">one</a>",
+                    "<a href=\"../pkg5/MethodTest.html#three--\">three</a>",
+                    "<a href=\"../pkg5/MethodTest.html#two--\">two</a>",
+                    "<h3>Method Detail</h3>",
+                    "<h4>one</h4>",
+                    "<h4>two</h4>",
+                    "<h4>three</h4>",
+                    "<h4>four</h4>");
 
-    final static String expectedImplementsOrdering[] = {
-        "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.lang.AutoCloseable</code></dd>",
-        "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.nio.channels.Channel</code></dd>",
-        "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.io.Closeable</code></dd>"
-    };
-
-    final static String expectedOverrideOrdering[] = {
-        "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.util.Collection&lt;",
-        "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.lang.Iterable&lt;"
-    };
+            tester.checkOrder("pkg5/PropertyTest.html",
+                    "<h3>Property Summary</h3>",
+                    "<a href=\"../pkg5/PropertyTest.html#fourProperty\">four</a>",
+                    "<a href=\"../pkg5/PropertyTest.html#oneProperty\">one</a>",
+                    "<a href=\"../pkg5/PropertyTest.html#threeProperty\">three</a>",
+                    "<a href=\"../pkg5/PropertyTest.html#twoProperty\">two</a>",
+                    "<h3>Property Detail</h3>",
+                    "<h4>oneProperty</h4>",
+                    "<h4>twoProperty</h4>",
+                    "<h4>threeProperty</h4>",
+                    "<h4>fourProperty</h4>");
+        }
+    }
 }
--- a/langtools/test/jdk/javadoc/doclet/testOrdering/order/MethodOrder.java	Mon Nov 14 19:45:41 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package order;
-
-/**
- * This class ensures the method detail section contains the methods
- * in the order as it appears in the source.
- * @author kumasrin
- */
-public class MethodOrder {
-    /**
-     * Method d.
-     * Second line.
-     */
-    public void d(){}
-    /**
-     * Method b.
-     * Second line.
-     */
-    public void b() {}
-    /**
-     * Method c.
-     * Second line.
-     */
-    public void c() {}
-    /**
-     * Method a.
-     * Second line.
-     */
-    public void a() {}
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/AnnoFieldTest.java	Mon Nov 14 16:33:48 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg5;
+
+public @interface AnnoFieldTest {
+    public int one = 1;
+    public int two = 2;
+    public int three = 3;
+    public int four = 4;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/AnnoOptionalTest.java	Mon Nov 14 16:33:48 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg5;
+
+public @interface AnnoOptionalTest {
+    int one() default 1;
+    int two() default 2;
+    int three() default 3;
+    int four() default 4;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/AnnoRequiredTest.java	Mon Nov 14 16:33:48 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg5;
+
+public @interface AnnoRequiredTest {
+    int one();
+    int two();
+    int three();
+    int four();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/CtorTest.java	Mon Nov 14 16:33:48 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg5;
+
+public class CtorTest {
+    public CtorTest(int one, int two, int three, int four) {}
+    public CtorTest(int one, int two, int three) {}
+    public CtorTest(int one, int two) {}
+    public CtorTest(int one) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/EnumTest.java	Mon Nov 14 16:33:48 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg5;
+
+public enum EnumTest {
+    ONE,
+    TWO,
+    THREE,
+    FOUR
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/FieldTest.java	Mon Nov 14 16:33:48 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg5;
+
+public class FieldTest {
+    public int one;
+    public int two;
+    public int three;
+    public int four;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/IntfTest.java	Mon Nov 14 16:33:48 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg5;
+
+public interface IntfTest {
+    void one();
+    void two();
+    void three();
+    void four();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/MethodTest.java	Mon Nov 14 16:33:48 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg5;
+
+public class MethodTest {
+    public void one(){}
+    public void two(){}
+    public void three(){}
+    public void four(){}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOrdering/pkg5/PropertyTest.java	Mon Nov 14 16:33:48 2016 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg5;
+
+public class PropertyTest {
+    public int oneProperty() { return 1; }
+    public int twoProperty() { return 2; }
+    public int threeProperty() { return 3; }
+    public int fourProperty() { return 4; }
+}