src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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.  Oracle designates this

@@ -21,24 +21,36 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
-package com.sun.tools.doclets.internal.toolkit.taglets;
+package jdk.javadoc.internal.doclets.toolkit.taglets;
 
 import java.io.*;
-import java.lang.reflect.*;
-import java.net.*;
 import java.util.*;
 
-import javax.tools.DocumentationTool;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.util.SimpleElementVisitor9;
 import javax.tools.JavaFileManager;
+import javax.tools.StandardJavaFileManager;
 
-import com.sun.javadoc.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.javac.util.StringUtils;
+import com.sun.source.doctree.DocTree;
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
 
+import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
+import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+
+import static javax.tools.DocumentationTool.Location.*;
+
+import static com.sun.source.doctree.DocTree.Kind.*;
+
 /**
  * Manages the<code>Taglet</code>s used by doclets.
  *
  *  <p><b>This is NOT part of any supported API.
  *  If you write code that depends on this, you do so at your own risk.

@@ -64,112 +76,113 @@
     public static final String ALT_SIMPLE_TAGLET_OPT_SEPARATOR = "-";
 
     /**
      * The map of custom tags.
      */
-    private LinkedHashMap<String,Taglet> customTags;
+    private final LinkedHashMap<String,Taglet> customTags;
 
     /**
      * The array of custom tags that can appear in packages.
      */
-    private Taglet[] packageTags;
+    private List<Taglet> packageTags;
 
     /**
      * The array of custom tags that can appear in classes or interfaces.
      */
-    private Taglet[] typeTags;
+    private List<Taglet> typeTags;
 
     /**
      * The array of custom tags that can appear in fields.
      */
-    private Taglet[] fieldTags;
+    private List<Taglet> fieldTags;
 
     /**
      * The array of custom tags that can appear in constructors.
      */
-    private Taglet[] constructorTags;
+    private List<Taglet> constructorTags;
 
     /**
      * The array of custom tags that can appear in methods.
      */
-    private Taglet[] methodTags;
+    private List<Taglet> methodTags;
 
     /**
      * The array of custom tags that can appear in the overview.
      */
-    private Taglet[] overviewTags;
+    private List<Taglet> overviewTags;
 
     /**
      * The array of custom tags that can appear in comments.
      */
-    private Taglet[] inlineTags;
+    private List<Taglet> inlineTags;
 
     /**
      * The array of custom tags that can appear in the serialized form.
      */
-    private Taglet[] serializedFormTags;
+    private List<Taglet> serializedFormTags;
 
     /**
      * The message retriever that will be used to print error messages.
      */
-    private MessageRetriever message;
+    private final MessageRetriever message;
 
     /**
      * Keep track of standard tags.
      */
-    private Set<String> standardTags;
+    private final Set<String> standardTags;
 
     /**
      * Keep track of standard tags in lowercase to compare for better
      * error messages when a tag like @docRoot is mistakenly spelled
      * lowercase @docroot.
      */
-    private Set<String> standardTagsLowercase;
+    private final Set<String> standardTagsLowercase;
 
     /**
      * Keep track of overriden standard tags.
      */
-    private Set<String> overridenStandardTags;
+    private final Set<String> overridenStandardTags;
 
     /**
      * Keep track of the tags that may conflict
      * with standard tags in the future (any custom tag without
      * a period in its name).
      */
-    private Set<String> potentiallyConflictingTags;
+    private final Set<String> potentiallyConflictingTags;
 
     /**
      * The set of unseen custom tags.
      */
-    private Set<String> unseenCustomTags;
+    private final Set<String> unseenCustomTags;
 
     /**
      * True if we do not want to use @since tags.
      */
-    private boolean nosince;
+    private final boolean nosince;
 
     /**
      * True if we want to use @version tags.
      */
-    private boolean showversion;
+    private final boolean showversion;
 
     /**
      * True if we want to use @author tags.
      */
-    private boolean showauthor;
+    private final boolean showauthor;
 
     /**
      * True if we want to use JavaFX-related tags (@propertyGetter,
      * @propertySetter, @propertyDescription, @defaultValue, @treatAsPrivate).
      */
-    private boolean javafx;
+    private final boolean javafx;
 
     /**
      * Construct a new <code>TagletManager</code>.
      * @param nosince true if we do not want to use @since tags.
      * @param showversion true if we want to use @version tags.
      * @param showauthor true if we want to use @author tags.
+     * @param javafx indicates whether javafx is active.
      * @param message the message retriever to print warnings.
      */
     public TagletManager(boolean nosince, boolean showversion,
                          boolean showauthor, boolean javafx,
                          MessageRetriever message) {

@@ -212,86 +225,42 @@
 
     /**
      * Add a new <code>Taglet</code>.  Print a message to indicate whether or not
      * the Taglet was registered properly.
      * @param classname  the name of the class representing the custom tag.
+     * @param fileManager the filemanager to load classes and resources.
      * @param tagletPath  the path to the class representing the custom tag.
      */
     public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) {
         try {
-            Class<?> customTagClass = null;
-            // construct class loader
-            String cpString = null;   // make sure env.class.path defaults to dot
-
             ClassLoader tagClassLoader;
-            if (fileManager != null && fileManager.hasLocation(DocumentationTool.Location.TAGLET_PATH)) {
-                tagClassLoader = fileManager.getClassLoader(DocumentationTool.Location.TAGLET_PATH);
-            } else {
-                // do prepends to get correct ordering
-                cpString = appendPath(System.getProperty("env.class.path"), cpString);
-                cpString = appendPath(System.getProperty("java.class.path"), cpString);
-                cpString = appendPath(tagletPath, cpString);
-                tagClassLoader = new URLClassLoader(pathToURLs(cpString));
+            if (!fileManager.hasLocation(TAGLET_PATH)) {
+                List<File> paths = new ArrayList<>();
+                if (tagletPath != null) {
+                    for (String pathname : tagletPath.split(File.pathSeparator)) {
+                        paths.add(new File(pathname));
             }
-
-            customTagClass = tagClassLoader.loadClass(classname);
-            Method meth = customTagClass.getMethod("register",
-                                                   Map.class);
-            Object[] list = customTags.values().toArray();
-            Taglet lastTag = (list != null && list.length > 0)
-                ? (Taglet) list[list.length-1] : null;
-            meth.invoke(null, customTags);
-            list = customTags.values().toArray();
-            Object newLastTag = (list != null&& list.length > 0)
-                ? list[list.length-1] : null;
-            if (lastTag != newLastTag) {
-                //New taglets must always be added to the end of the LinkedHashMap.
-                //If the current and previous last taglet are not equal, that
-                //means a new Taglet has been added.
-                message.notice("doclet.Notice_taglet_registered", classname);
-                if (newLastTag != null) {
-                    checkTaglet(newLastTag);
                 }
+                ((StandardJavaFileManager)fileManager).setLocation(TAGLET_PATH, paths);
             }
+            tagClassLoader = fileManager.getClassLoader(TAGLET_PATH);
+            Class<?> customTagClass = tagClassLoader.loadClass(classname);
+            Object instance = customTagClass.newInstance();
+            Taglet newLegacy = new UserTaglet((jdk.javadoc.doclet.taglet.Taglet)instance);
+            String tname = newLegacy.getName();
+            Taglet t = customTags.get(tname);
+            if (t != null) {
+                customTags.remove(tname);
+            }
+            customTags.put(tname, newLegacy);
+            message.notice("doclet.Notice_taglet_registered", classname);
         } catch (Exception exc) {
             message.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname);
         }
-
     }
 
-    private String appendPath(String path1, String path2) {
-        if (path1 == null || path1.length() == 0) {
-            return path2 == null ? "." : path2;
-        } else if (path2 == null || path2.length() == 0) {
-            return path1;
-        } else {
-            return path1  + File.pathSeparator + path2;
-        }
-    }
-
     /**
-     * Utility method for converting a search path string to an array
-     * of directory and JAR file URLs.
-     *
-     * @param path the search path string
-     * @return the resulting array of directory and JAR file URLs
-     */
-    private URL[] pathToURLs(String path) {
-        Set<URL> urls = new LinkedHashSet<>();
-        for (String s: path.split(File.pathSeparator)) {
-            if (s.isEmpty()) continue;
-            try {
-                urls.add(new File(s).getAbsoluteFile().toURI().toURL());
-            } catch (MalformedURLException e) {
-                message.error("doclet.MalformedURL", s);
-            }
-        }
-        return urls.toArray(new URL[urls.size()]);
-    }
-
-
-    /**
      * Add a new <code>SimpleTaglet</code>.  If this tag already exists
      * and the header passed as an argument is null, move tag to the back of the
      * list. If this tag already exists and the header passed as an argument is
      * not null, overwrite previous tag with new one.  Otherwise, add new
      * SimpleTaglet to list.

@@ -303,11 +272,11 @@
     public void addNewSimpleCustomTag(String tagName, String header, String locations) {
         if (tagName == null || locations == null) {
             return;
         }
         Taglet tag = customTags.get(tagName);
-        locations = StringUtils.toLowerCase(locations);
+        locations = Utils.toLowerCase(locations);
         if (tag == null || header != null) {
             customTags.remove(tagName);
             customTags.put(tagName, new SimpleTaglet(tagName, header, locations));
             if (locations != null && locations.indexOf('x') == -1) {
                 checkTagName(tagName);

@@ -338,14 +307,14 @@
      * check its name for errors.
      */
     private void checkTaglet(Object taglet) {
         if (taglet instanceof Taglet) {
             checkTagName(((Taglet) taglet).getName());
-        } else if (taglet instanceof com.sun.tools.doclets.Taglet) {
-            com.sun.tools.doclets.Taglet legacyTaglet = (com.sun.tools.doclets.Taglet) taglet;
+        } else if (taglet instanceof jdk.javadoc.doclet.taglet.Taglet) {
+            jdk.javadoc.doclet.taglet.Taglet legacyTaglet = (jdk.javadoc.doclet.taglet.Taglet) taglet;
             customTags.remove(legacyTaglet.getName());
-            customTags.put(legacyTaglet.getName(), new LegacyTaglet(legacyTaglet));
+            customTags.put(legacyTaglet.getName(), new UserTaglet(legacyTaglet));
             checkTagName(legacyTaglet.getName());
         } else {
             throw new IllegalArgumentException("Given object is not a taglet.");
         }
     }

@@ -359,63 +328,108 @@
         unseenCustomTags.remove(name);
     }
 
     /**
      * Given an array of <code>Tag</code>s, check for spelling mistakes.
-     * @param doc the Doc object that holds the tags.
-     * @param tags the list of <code>Tag</code>s to check.
+     * @param utils the utility class to use
+     * @param element the tags holder
+     * @param trees the trees containing the comments
      * @param areInlineTags true if the array of tags are inline and false otherwise.
      */
-    public void checkTags(Doc doc, Tag[] tags, boolean areInlineTags) {
-        if (tags == null) {
+    public void checkTags(final Utils utils, Element element,
+                          Iterable<? extends DocTree> trees, boolean areInlineTags) {
+        if (trees == null) {
             return;
         }
-        Taglet taglet;
-        for (Tag tag : tags) {
-            String name = tag.name();
+        CommentHelper ch = utils.getCommentHelper(element);
+        for (DocTree tag : trees) {
+            String name = tag.getKind().tagName;
+            if (name == null) {
+                continue;
+            }
             if (name.length() > 0 && name.charAt(0) == '@') {
                 name = name.substring(1, name.length());
             }
             if (! (standardTags.contains(name) || customTags.containsKey(name))) {
-                if (standardTagsLowercase.contains(StringUtils.toLowerCase(name))) {
-                    message.warning(tag.position(), "doclet.UnknownTagLowercase", tag.name());
+                if (standardTagsLowercase.contains(Utils.toLowerCase(name))) {
+                    message.warning(ch.getDocTreePath(tag), "doclet.UnknownTagLowercase", ch.getTagName(tag));
                     continue;
                 } else {
-                    message.warning(tag.position(), "doclet.UnknownTag", tag.name());
+                    message.warning(ch.getDocTreePath(tag), "doclet.UnknownTag", ch.getTagName(tag));
                     continue;
                 }
             }
-            //Check if this tag is being used in the wrong location.
-            if ((taglet = customTags.get(name)) != null) {
-                if (areInlineTags && ! taglet.isInlineTag()) {
-                    printTagMisuseWarn(taglet, tag, "inline");
+            final Taglet taglet = customTags.get(name);
+            // Check and verify tag usage
+            if (taglet != null) {
+                if (areInlineTags && !taglet.isInlineTag()) {
+                    printTagMisuseWarn(ch, taglet, tag, "inline");
                 }
-                if ((doc instanceof RootDoc) && ! taglet.inOverview()) {
-                    printTagMisuseWarn(taglet, tag, "overview");
-                } else if ((doc instanceof PackageDoc) && ! taglet.inPackage()) {
-                    printTagMisuseWarn(taglet, tag, "package");
-                } else if ((doc instanceof ClassDoc) && ! taglet.inType()) {
-                    printTagMisuseWarn(taglet, tag, "class");
-                } else if ((doc instanceof ConstructorDoc) && ! taglet.inConstructor()) {
-                    printTagMisuseWarn(taglet, tag, "constructor");
-                } else if ((doc instanceof FieldDoc) && ! taglet.inField()) {
-                    printTagMisuseWarn(taglet, tag, "field");
-                } else if ((doc instanceof MethodDoc) && ! taglet.inMethod()) {
-                    printTagMisuseWarn(taglet, tag, "method");
+                // nothing more to do
+                if (element == null) {
+                    return;
                 }
+                new SimpleElementVisitor9<Void, Void>() {
+                    @Override @DefinedBy(Api.LANGUAGE_MODEL)
+                    public Void visitPackage(PackageElement e, Void p) {
+                        if (!taglet.inPackage()) {
+                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "package");
             }
+                        return null;
         }
+
+                    @Override @DefinedBy(Api.LANGUAGE_MODEL)
+                    public Void visitType(TypeElement e, Void p) {
+                        if (!taglet.inType()) {
+                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "class");
     }
+                        return null;
+                    }
 
+                    @Override @DefinedBy(Api.LANGUAGE_MODEL)
+                    public Void visitExecutable(ExecutableElement e, Void p) {
+                        if (utils.isConstructor(e) && !taglet.inConstructor()) {
+                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "constructor");
+                        } else if (!taglet.inMethod()) {
+                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "method");
+                        }
+                        return null;
+                    }
+
+                    @Override @DefinedBy(Api.LANGUAGE_MODEL)
+                    public Void visitVariable(VariableElement e, Void p) {
+                        if (utils.isField(e) && !taglet.inField()) {
+                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "field");
+                        }
+                        return null;
+                    }
+
+                    @Override @DefinedBy(Api.LANGUAGE_MODEL)
+                    public Void visitUnknown(Element e, Void p) {
+                        if (utils.isOverviewElement(e) && !taglet.inOverview()) {
+                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "overview");
+                        }
+                        return null;
+                    }
+
+                    @Override @DefinedBy(Api.LANGUAGE_MODEL)
+                    protected Void defaultAction(Element e, Void p) {
+                        return null;
+                    }
+                }.visit(element);
+            }
+        }
+    }
+
     /**
      * Given the taglet, the tag and the type of documentation that the tag
      * was found in, print a tag misuse warning.
      * @param taglet the taglet representing the misused tag.
      * @param tag the misused tag.
      * @param holderType the type of documentation that the misused tag was found in.
      */
-    private void printTagMisuseWarn(Taglet taglet, Tag tag, String holderType) {
+    private void printTagMisuseWarn(CommentHelper ch, Taglet taglet, DocTree tag, String holderType) {
         Set<String> locationsSet = new LinkedHashSet<>();
         if (taglet.inOverview()) {
             locationsSet.add("overview");
         }
         if (taglet.inPackage()) {

@@ -446,23 +460,23 @@
             if (i > 0) {
                 combined_locations.append(", ");
             }
             combined_locations.append(locations[i]);
         }
-        message.warning(tag.position(), "doclet.tag_misuse",
+        message.warning(ch.getDocTreePath(tag), "doclet.tag_misuse",
             "@" + taglet.getName(), holderType, combined_locations.toString());
     }
 
     /**
      * Return the array of <code>Taglet</code>s that can
      * appear in packages.
      * @return the array of <code>Taglet</code>s that can
      * appear in packages.
      */
-    public Taglet[] getPackageCustomTaglets() {
+    public List<Taglet> getPackageCustomTaglets() {
         if (packageTags == null) {
-            initCustomTagletArrays();
+            initCustomTaglets();
         }
         return packageTags;
     }
 
     /**

@@ -469,13 +483,13 @@
      * Return the array of <code>Taglet</code>s that can
      * appear in classes or interfaces.
      * @return the array of <code>Taglet</code>s that can
      * appear in classes or interfaces.
      */
-    public Taglet[] getTypeCustomTaglets() {
+    public List<Taglet> getTypeCustomTaglets() {
         if (typeTags == null) {
-            initCustomTagletArrays();
+            initCustomTaglets();
         }
         return typeTags;
     }
 
     /**

@@ -482,13 +496,13 @@
      * Return the array of inline <code>Taglet</code>s that can
      * appear in comments.
      * @return the array of <code>Taglet</code>s that can
      * appear in comments.
      */
-    public Taglet[] getInlineCustomTaglets() {
+    public List<Taglet> getInlineCustomTaglets() {
         if (inlineTags == null) {
-            initCustomTagletArrays();
+            initCustomTaglets();
         }
         return inlineTags;
     }
 
     /**

@@ -495,13 +509,13 @@
      * Return the array of <code>Taglet</code>s that can
      * appear in fields.
      * @return the array of <code>Taglet</code>s that can
      * appear in field.
      */
-    public Taglet[] getFieldCustomTaglets() {
+    public List<Taglet> getFieldCustomTaglets() {
         if (fieldTags == null) {
-            initCustomTagletArrays();
+            initCustomTaglets();
         }
         return fieldTags;
     }
 
     /**

@@ -508,130 +522,130 @@
      * Return the array of <code>Taglet</code>s that can
      * appear in the serialized form.
      * @return the array of <code>Taglet</code>s that can
      * appear in the serialized form.
      */
-    public Taglet[] getSerializedFormTaglets() {
+    public List<Taglet> getSerializedFormTaglets() {
         if (serializedFormTags == null) {
-            initCustomTagletArrays();
+            initCustomTaglets();
         }
         return serializedFormTags;
     }
 
     /**
+     * Returns the custom tags for a given element.
+     *
+     * @param e the element to get custom tags for
      * @return the array of <code>Taglet</code>s that can
-     * appear in the given Doc.
+     * appear in the given element.
      */
-    public Taglet[] getCustomTaglets(Doc doc) {
-        if (doc instanceof ConstructorDoc) {
+    public List<Taglet> getCustomTaglets(Element e) {
+        switch (e.getKind()) {
+            case CONSTRUCTOR:
             return getConstructorCustomTaglets();
-        } else if (doc instanceof MethodDoc) {
+            case METHOD:
             return getMethodCustomTaglets();
-        } else if (doc instanceof FieldDoc) {
+            case ENUM_CONSTANT:
+            case FIELD:
             return getFieldCustomTaglets();
-        } else if (doc instanceof ClassDoc) {
+            case ANNOTATION_TYPE:
+            case INTERFACE:
+            case CLASS:
+            case ENUM:
             return getTypeCustomTaglets();
-        } else if (doc instanceof PackageDoc) {
+            case PACKAGE:
             return getPackageCustomTaglets();
-        } else if (doc instanceof RootDoc) {
+            case OTHER:
             return getOverviewCustomTaglets();
+            default:
+                throw new AssertionError("unknown element: " + e + " ,kind: " + e.getKind());
         }
-        return null;
     }
 
     /**
-     * Return the array of <code>Taglet</code>s that can
+     * Return a List of <code>Taglet</code>s that can
      * appear in constructors.
      * @return the array of <code>Taglet</code>s that can
      * appear in constructors.
      */
-    public Taglet[] getConstructorCustomTaglets() {
+    public List<Taglet> getConstructorCustomTaglets() {
         if (constructorTags == null) {
-            initCustomTagletArrays();
+            initCustomTaglets();
         }
         return constructorTags;
     }
 
     /**
-     * Return the array of <code>Taglet</code>s that can
+     * Return a List of <code>Taglet</code>s that can
      * appear in methods.
      * @return the array of <code>Taglet</code>s that can
      * appear in methods.
      */
-    public Taglet[] getMethodCustomTaglets() {
+    public List<Taglet> getMethodCustomTaglets() {
         if (methodTags == null) {
-            initCustomTagletArrays();
+            initCustomTaglets();
         }
         return methodTags;
     }
 
     /**
-     * Return the array of <code>Taglet</code>s that can
+     * Return a List of <code>Taglet</code>s that can
      * appear in an overview.
      * @return the array of <code>Taglet</code>s that can
      * appear in overview.
      */
-    public Taglet[] getOverviewCustomTaglets() {
+    public List<Taglet> getOverviewCustomTaglets() {
         if (overviewTags == null) {
-            initCustomTagletArrays();
+            initCustomTaglets();
         }
         return overviewTags;
     }
 
     /**
-     * Initialize the custom tag arrays.
+     * Initialize the custom tag Lists.
      */
-    private void initCustomTagletArrays() {
-        Iterator<Taglet> it = customTags.values().iterator();
-        ArrayList<Taglet> pTags = new ArrayList<>(customTags.size());
-        ArrayList<Taglet> tTags = new ArrayList<>(customTags.size());
-        ArrayList<Taglet> fTags = new ArrayList<>(customTags.size());
-        ArrayList<Taglet> cTags = new ArrayList<>(customTags.size());
-        ArrayList<Taglet> mTags = new ArrayList<>(customTags.size());
-        ArrayList<Taglet> iTags = new ArrayList<>(customTags.size());
-        ArrayList<Taglet> oTags = new ArrayList<>(customTags.size());
-        ArrayList<Taglet> sTags = new ArrayList<>();
-        Taglet current;
-        while (it.hasNext()) {
-            current = it.next();
+    private void initCustomTaglets() {
+
+        packageTags = new ArrayList<>();
+        typeTags = new ArrayList<>();
+        fieldTags = new ArrayList<>();
+        constructorTags = new ArrayList<>();
+        methodTags = new ArrayList<>();
+        inlineTags = new ArrayList<>();
+        overviewTags = new ArrayList<>();
+
+        for (Taglet current : customTags.values()) {
             if (current.inPackage() && !current.isInlineTag()) {
-                pTags.add(current);
+                packageTags.add(current);
             }
             if (current.inType() && !current.isInlineTag()) {
-                tTags.add(current);
+                typeTags.add(current);
             }
             if (current.inField() && !current.isInlineTag()) {
-                fTags.add(current);
+                fieldTags.add(current);
             }
             if (current.inConstructor() && !current.isInlineTag()) {
-                cTags.add(current);
+                constructorTags.add(current);
             }
             if (current.inMethod() && !current.isInlineTag()) {
-                mTags.add(current);
+                methodTags.add(current);
             }
             if (current.isInlineTag()) {
-                iTags.add(current);
+                inlineTags.add(current);
             }
             if (current.inOverview() && !current.isInlineTag()) {
-                oTags.add(current);
+                overviewTags.add(current);
             }
         }
-        packageTags = pTags.toArray(new Taglet[] {});
-        typeTags = tTags.toArray(new Taglet[] {});
-        fieldTags = fTags.toArray(new Taglet[] {});
-        constructorTags = cTags.toArray(new Taglet[] {});
-        methodTags = mTags.toArray(new Taglet[] {});
-        overviewTags = oTags.toArray(new Taglet[] {});
-        inlineTags = iTags.toArray(new Taglet[] {});
 
         //Init the serialized form tags
-        sTags.add(customTags.get("serialData"));
-        sTags.add(customTags.get("throws"));
+        serializedFormTags = new ArrayList<>();
+        serializedFormTags.add(customTags.get(SERIAL_DATA.tagName));
+        serializedFormTags.add(customTags.get(THROWS.tagName));
         if (!nosince)
-            sTags.add(customTags.get("since"));
-        sTags.add(customTags.get("see"));
-        serializedFormTags = sTags.toArray(new Taglet[] {});
+            serializedFormTags.add(customTags.get(SINCE.tagName));
+        serializedFormTags.add(customTags.get(SEE.tagName));
     }
 
     /**
      * Initialize standard Javadoc tags for ordering purposes.
      */

@@ -642,19 +656,19 @@
 
         Taglet temp;
         addStandardTaglet(new ParamTaglet());
         addStandardTaglet(new ReturnTaglet());
         addStandardTaglet(new ThrowsTaglet());
-        addStandardTaglet(new SimpleTaglet("exception", null,
+        addStandardTaglet(new SimpleTaglet(EXCEPTION.tagName, null,
                 SimpleTaglet.METHOD + SimpleTaglet.CONSTRUCTOR));
-        addStandardTaglet(!nosince, new SimpleTaglet("since", message.getText("doclet.Since"),
+        addStandardTaglet(!nosince, new SimpleTaglet(SINCE.tagName, message.getText("doclet.Since"),
                SimpleTaglet.ALL));
-        addStandardTaglet(showversion, new SimpleTaglet("version", message.getText("doclet.Version"),
+        addStandardTaglet(showversion, new SimpleTaglet(VERSION.tagName, message.getText("doclet.Version"),
                 SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
-        addStandardTaglet(showauthor, new SimpleTaglet("author", message.getText("doclet.Author"),
+        addStandardTaglet(showauthor, new SimpleTaglet(AUTHOR.tagName, message.getText("doclet.Author"),
                 SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
-        addStandardTaglet(new SimpleTaglet("serialData", message.getText("doclet.SerialData"),
+        addStandardTaglet(new SimpleTaglet(SERIAL_DATA.tagName, message.getText("doclet.SerialData"),
             SimpleTaglet.EXCLUDED));
         customTags.put((temp = new SimpleTaglet("factory", message.getText("doclet.Factory"),
             SimpleTaglet.METHOD)).getName(), temp);
         addStandardTaglet(new SeeTaglet());
         //Standard inline tags

@@ -665,17 +679,15 @@
         addStandardTaglet(new CodeTaglet());
         addStandardTaglet(new IndexTaglet());
 
         // Keep track of the names of standard tags for error
         // checking purposes. The following are not handled above.
-        // See, for example, com.sun.tools.javadoc.Comment
-        standardTags.add("deprecated");
-        standardTags.add("link");
-        standardTags.add("linkplain");
-        standardTags.add("serial");
-        standardTags.add("serialField");
-        standardTags.add("Text");
+        standardTags.add(DEPRECATED.tagName);
+        standardTags.add(LINK.tagName);
+        standardTags.add(LINK_PLAIN.tagName);
+        standardTags.add(SERIAL.tagName);
+        standardTags.add(SERIAL_FIELD.tagName);
     }
 
     /**
      * Initialize JavaFX-related tags.
      */

@@ -707,11 +719,11 @@
     /**
      * Initialize lowercase version of standard Javadoc tags.
      */
     private void initStandardTagsLowercase() {
         for (String standardTag : standardTags) {
-            standardTagsLowercase.add(StringUtils.toLowerCase(standardTag));
+            standardTagsLowercase.add(Utils.toLowerCase(standardTag));
         }
     }
 
     public boolean isKnownCustomTag(String tagName) {
         return customTags.containsKey(tagName);