Merge
authorlana
Fri, 17 May 2013 10:13:34 -0700
changeset 17587 a5e4cac27b50
parent 17543 482fdbf61490 (current diff)
parent 17586 6db178e18835 (diff)
child 17588 48e3c0f361f2
Merge
langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletOutputImpl.java
langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ExpertTaglet.java
langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletOutput.java
langtools/src/share/classes/javax/tools/annotation/GenerateNativeHeader.java
langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass2.java
langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass3.java
--- a/langtools/make/tools/genstubs/GenStubs.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/make/tools/genstubs/GenStubs.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, 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
@@ -37,6 +37,7 @@
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.TypeTag;
 import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
 import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
 import com.sun.tools.javac.tree.JCTree.JCIdent;
@@ -208,6 +209,21 @@
          * methods: remove method bodies, make methods native
          */
         @Override
+        public void visitClassDef(JCClassDecl tree) {
+            long prevClassMods = currClassMods;
+            currClassMods = tree.mods.flags;
+            try {
+                super.visitClassDef(tree);;
+            } finally {
+                currClassMods = prevClassMods;
+            }
+        }
+        private long currClassMods = 0;
+
+        /**
+         * methods: remove method bodies, make methods native
+         */
+        @Override
         public void visitMethodDef(JCMethodDecl tree) {
             tree.mods = translate(tree.mods);
             tree.restype = translate(tree.restype);
@@ -215,7 +231,11 @@
             tree.params = translateVarDefs(tree.params);
             tree.thrown = translate(tree.thrown);
             if (tree.restype != null && tree.body != null) {
-                tree.mods.flags |= Flags.NATIVE;
+                if ((currClassMods & Flags.INTERFACE) != 0) {
+                    tree.mods.flags &= ~Flags.DEFAULT;
+                } else {
+                    tree.mods.flags |= Flags.NATIVE;
+                }
                 tree.body = null;
             }
             result = tree;
--- a/langtools/makefiles/BuildLangtools.gmk	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/makefiles/BuildLangtools.gmk	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2013, 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
@@ -123,10 +123,10 @@
              genstubs.GenStubs
         # We fetch source from the JDK...
         JDKS=$(JDK_TOPDIR)/src/share/classes
-        # Build the list of classes to generate stubs from. java/util/Objects.java isn't
+        # Build the list of classes to generate stubs from. java/util/function/Predicate.java isn't
         # currently needed, but is used as a demo for now.
 	 STUBSOURCES:=$(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \
-		    -e "$(JDKS)/java/util/Objects.java")
+		    -e "$(JDKS)/java/util/function/Predicate.java")
         # Rewrite the file names into class names because the GenStubs tool require this.
         STUBCLASSES:=$(subst /,.,$(patsubst $(JDKS)/%.java,%,$(STUBSOURCES)))
 
--- a/langtools/src/share/classes/com/sun/source/tree/VariableTree.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/source/tree/VariableTree.java	Fri May 17 10:13:34 2013 -0700
@@ -33,6 +33,7 @@
  * For example:
  * <pre>
  *   <em>modifiers</em> <em>type</em> <em>name</em> <em>initializer</em> ;
+ *   <em>modifiers</em> <em>type</em> <em>qualified-name</em>.this
  * </pre>
  *
  * @jls sections 8.3 and 14.4
@@ -45,6 +46,7 @@
 public interface VariableTree extends StatementTree {
     ModifiersTree getModifiers();
     Name getName();
+    ExpressionTree getNameExpression();
     Tree getType();
     ExpressionTree getInitializer();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/util/DocTreePath.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.util;
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import java.util.Iterator;
+
+/**
+ * A path of tree nodes, typically used to represent the sequence of ancestor
+ * nodes of a tree node up to the top level DocCommentTree node.
+ *
+ * @since 1.8
+ */
+@jdk.Supported
+public class DocTreePath implements Iterable<DocTree> {
+    /**
+     * Gets a documentation tree path for a tree node within a compilation unit.
+     * @return null if the node is not found
+     */
+    public static DocTreePath getPath(TreePath treePath, DocCommentTree doc, DocTree target) {
+        return getPath(new DocTreePath(treePath, doc), target);
+    }
+
+    /**
+     * Gets a documentation tree path for a tree node within a subtree identified by a DocTreePath object.
+     * @return null if the node is not found
+     */
+    public static DocTreePath getPath(DocTreePath path, DocTree target) {
+        path.getClass();
+        target.getClass();
+
+        class Result extends Error {
+            static final long serialVersionUID = -5942088234594905625L;
+            DocTreePath path;
+            Result(DocTreePath path) {
+                this.path = path;
+            }
+        }
+
+        class PathFinder extends DocTreePathScanner<DocTreePath,DocTree> {
+            public DocTreePath scan(DocTree tree, DocTree target) {
+                if (tree == target) {
+                    throw new Result(new DocTreePath(getCurrentPath(), target));
+                }
+                return super.scan(tree, target);
+            }
+        }
+
+        if (path.getLeaf() == target) {
+            return path;
+        }
+
+        try {
+            new PathFinder().scan(path, target);
+        } catch (Result result) {
+            return result.path;
+        }
+        return null;
+    }
+
+    /**
+     * Creates a DocTreePath for a root node.
+     *
+     * @param treePath the TreePath from which the root node was created.
+     * @param t the DocCommentTree to create the path for.
+     */
+    public DocTreePath(TreePath treePath, DocCommentTree t) {
+        treePath.getClass();
+        t.getClass();
+
+        this.treePath = treePath;
+        this.docComment = t;
+        this.parent = null;
+        this.leaf = t;
+    }
+
+    /**
+     * Creates a DocTreePath for a child node.
+     */
+    public DocTreePath(DocTreePath p, DocTree t) {
+        if (t.getKind() == DocTree.Kind.DOC_COMMENT) {
+            throw new IllegalArgumentException("Use DocTreePath(TreePath, DocCommentTree) to construct DocTreePath for a DocCommentTree.");
+        } else {
+            treePath = p.treePath;
+            docComment = p.docComment;
+            parent = p;
+        }
+        leaf = t;
+    }
+
+    /**
+     * Get the TreePath associated with this path.
+     * @return TreePath for this DocTreePath
+     */
+    public TreePath getTreePath() {
+        return treePath;
+    }
+
+    /**
+     * Get the DocCommentTree associated with this path.
+     * @return DocCommentTree for this DocTreePath
+     */
+    public DocCommentTree getDocComment() {
+        return docComment;
+    }
+
+    /**
+     * Get the leaf node for this path.
+     * @return DocTree for this DocTreePath
+     */
+    public DocTree getLeaf() {
+        return leaf;
+    }
+
+    /**
+     * Get the path for the enclosing node, or null if there is no enclosing node.
+     * @return DocTreePath of parent
+     */
+    public DocTreePath getParentPath() {
+        return parent;
+    }
+
+    public Iterator<DocTree> iterator() {
+        return new Iterator<DocTree>() {
+            public boolean hasNext() {
+                return next != null;
+            }
+
+            public DocTree next() {
+                DocTree t = next.leaf;
+                next = next.parent;
+                return t;
+            }
+
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+
+            private DocTreePath next = DocTreePath.this;
+        };
+    }
+
+    private final TreePath treePath;
+    private final DocCommentTree docComment;
+    private final DocTree leaf;
+    private final DocTreePath parent;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/util/DocTreePathScanner.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.source.util;
+
+import com.sun.source.doctree.DocTree;
+
+/**
+ * A DocTreeVisitor that visits all the child tree nodes, and provides
+ * support for maintaining a path for the parent nodes.
+ * To visit nodes of a particular type, just override the
+ * corresponding visitorXYZ method.
+ * Inside your method, call super.visitXYZ to visit descendant
+ * nodes.
+ *
+ * @since 1.8
+ */
+@jdk.Supported
+public class DocTreePathScanner<R, P> extends DocTreeScanner<R, P> {
+    /**
+     * Scan a tree from a position identified by a TreePath.
+     */
+    public R scan(DocTreePath path, P p) {
+        this.path = path;
+        try {
+            return path.getLeaf().accept(this, p);
+        } finally {
+            this.path = null;
+        }
+    }
+
+    /**
+     * Scan a single node.
+     * The current path is updated for the duration of the scan.
+     */
+    @Override
+    public R scan(DocTree tree, P p) {
+        if (tree == null)
+            return null;
+
+        DocTreePath prev = path;
+        path = new DocTreePath(path, tree);
+        try {
+            return tree.accept(this, p);
+        } finally {
+            path = prev;
+        }
+    }
+
+    /**
+     * Get the current path for the node, as built up by the currently
+     * active set of scan calls.
+     */
+    public DocTreePath getCurrentPath() {
+        return path;
+    }
+
+    private DocTreePath path;
+}
--- a/langtools/src/share/classes/com/sun/source/util/DocTrees.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/source/util/DocTrees.java	Fri May 17 10:13:34 2013 -0700
@@ -67,10 +67,10 @@
     public abstract DocCommentTree getDocCommentTree(TreePath path);
 
     /**
-     * Gets the language model element referred to by a ReferenceTree that
-     * appears on the declaration identified by the given path.
+     * Gets the language model element referred to by the leaf node of the given
+     * {@link DocTreePath}, or null if unknown.
      */
-    public abstract Element getElement(TreePath path, ReferenceTree reference);
+    public abstract Element getElement(DocTreePath path);
 
     public abstract DocSourcePositions getSourcePositions();
 
--- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java	Fri May 17 10:13:34 2013 -0700
@@ -149,6 +149,7 @@
     public R visitVariable(VariableTree node, P p) {
         R r = scan(node.getModifiers(), p);
         r = scanAndReduce(node.getType(), p, r);
+        r = scanAndReduce(node.getNameExpression(), p, r);
         r = scanAndReduce(node.getInitializer(), p, r);
         return r;
     }
--- a/langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -751,7 +751,7 @@
                 break;
             // exception parameter
             case EXCEPTION_PARAMETER:
-                out.writeByte(p.exception_index);
+                out.writeShort(p.exception_index);
                 break;
             // method receiver
             case METHOD_RECEIVER:
@@ -770,11 +770,11 @@
                 break;
             // class extends or implements clause
             case CLASS_EXTENDS:
-                out.writeByte(p.type_index);
+                out.writeShort(p.type_index);
                 break;
             // throws
             case THROWS:
-                out.writeByte(p.type_index);
+                out.writeShort(p.type_index);
                 break;
             // method parameter
             case METHOD_FORMAL_PARAMETER:
--- a/langtools/src/share/classes/com/sun/tools/classfile/TypeAnnotation.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/classfile/TypeAnnotation.java	Fri May 17 10:13:34 2013 -0700
@@ -111,7 +111,7 @@
             break;
         // exception parameter
         case EXCEPTION_PARAMETER:
-            position.exception_index = cr.readUnsignedByte();
+            position.exception_index = cr.readUnsignedShort();
             break;
         // method receiver
         case METHOD_RECEIVER:
@@ -198,7 +198,7 @@
             break;
         // exception parameter
         case EXCEPTION_PARAMETER:
-            n += 1; // exception_index
+            n += 2; // exception_index
             break;
         // method receiver
         case METHOD_RECEIVER:
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -60,17 +60,24 @@
      * @param htmltree the content tree to which the parameters will be added.
      * @return the display length required to write this information.
      */
-    protected int addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
+    protected void addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
+        Content typeParameters = getTypeParameters(member);
+        if (!typeParameters.isEmpty()) {
+            htmltree.addContent(typeParameters);
+            htmltree.addContent(writer.getSpace());
+        }
+    }
+
+    /**
+     * Get the type parameters for the executable member.
+     *
+     * @param member the member for which to get the type parameters.
+     * @return the type parameters.
+     */
+    protected Content getTypeParameters(ExecutableMemberDoc member) {
         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
-            LinkInfoImpl.CONTEXT_MEMBER_TYPE_PARAMS, member, false);
-        String typeParameters = writer.getTypeParameterLinks(linkInfo);
-        if (linkInfo.displayLength > 0) {
-            Content linkContent = new RawHtml(typeParameters);
-            htmltree.addContent(linkContent);
-            htmltree.addContent(writer.getSpace());
-            writer.displayLength += linkInfo.displayLength + 1;
-        }
-        return linkInfo.displayLength;
+            LinkInfoImpl.Kind.MEMBER_TYPE_PARAMS, member);
+        return writer.getTypeParameterLinks(linkInfo);
     }
 
     /**
@@ -78,7 +85,7 @@
      */
     protected Content getDeprecatedLink(ProgramElementDoc member) {
         ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
-        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc) emd,
+        return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, (MemberDoc) emd,
                 emd.qualifiedName() + emd.flatSignature());
     }
 
@@ -90,16 +97,15 @@
      * @param member the member being linked to
      * @param tdSummary the content tree to which the link will be added
      */
-    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
+    protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
             Content tdSummary) {
         ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
         String name = emd.name();
-        Content strong = HtmlTree.STRONG(new RawHtml(
+        Content strong = HtmlTree.STRONG(
                 writer.getDocLink(context, cd, (MemberDoc) emd,
-                name, false)));
+                name, false));
         Content code = HtmlTree.CODE(strong);
-        writer.displayLength = name.length();
-        addParameters(emd, false, code);
+        addParameters(emd, false, code, name.length() - 1);
         tdSummary.addContent(code);
     }
 
@@ -112,9 +118,9 @@
      */
     protected void addInheritedSummaryLink(ClassDoc cd,
             ProgramElementDoc member, Content linksTree) {
-        linksTree.addContent(new RawHtml(
-                writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc) member,
-                member.name(), false)));
+        linksTree.addContent(
+                writer.getDocLink(LinkInfoImpl.Kind.MEMBER, cd, (MemberDoc) member,
+                member.name(), false));
     }
 
     /**
@@ -126,11 +132,11 @@
      * @param tree the content tree to which the parameter information will be added.
      */
     protected void addParam(ExecutableMemberDoc member, Parameter param,
-        boolean isVarArg, Content tree) {
+            boolean isVarArg, Content tree) {
         if (param.type() != null) {
-            Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
-                    configuration, LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM,
-                    param.type(), isVarArg)));
+            Content link = writer.getLink(new LinkInfoImpl(
+                    configuration, LinkInfoImpl.Kind.EXECUTABLE_MEMBER_PARAM,
+                    param.type()).varargs(isVarArg));
             tree.addContent(link);
         }
         if(param.name().length() > 0) {
@@ -153,8 +159,8 @@
         tree.addContent(writer.getSpace());
         tree.addContent(rcvrType.typeName());
         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
-                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, rcvrType);
-        tree.addContent(new RawHtml(writer.getTypeParameterLinks(linkInfo)));
+                LinkInfoImpl.Kind.CLASS_SIGNATURE, rcvrType);
+        tree.addContent(writer.getTypeParameterLinks(linkInfo));
         tree.addContent(writer.getSpace());
         tree.addContent("this");
     }
@@ -166,8 +172,8 @@
      * @param member the member to write parameters for.
      * @param htmltree the content tree to which the parameters information will be added.
      */
-    protected void addParameters(ExecutableMemberDoc member, Content htmltree) {
-        addParameters(member, true, htmltree);
+    protected void addParameters(ExecutableMemberDoc member, Content htmltree, int indentSize) {
+        addParameters(member, true, htmltree, indentSize);
     }
 
     /**
@@ -178,15 +184,11 @@
      * @param htmltree the content tree to which the parameters information will be added.
      */
     protected void addParameters(ExecutableMemberDoc member,
-            boolean includeAnnotations, Content htmltree) {
+            boolean includeAnnotations, Content htmltree, int indentSize) {
         htmltree.addContent("(");
         String sep = "";
         Parameter[] params = member.parameters();
-        String indent = makeSpace(writer.displayLength);
-        if (configuration.linksource) {
-            //add spaces to offset indentation changes caused by link.
-            indent+= makeSpace(member.name().length());
-        }
+        String indent = makeSpace(indentSize + 1);
         Type rcvrType = member.receiverType();
         if (includeAnnotations && rcvrType instanceof AnnotatedType) {
             AnnotationDesc[] descList = rcvrType.asAnnotatedType().annotations();
@@ -240,53 +242,30 @@
      * @param member the member to write exceptions for.
      * @param htmltree the content tree to which the exceptions information will be added.
      */
-    protected void addExceptions(ExecutableMemberDoc member, Content htmltree) {
+    protected void addExceptions(ExecutableMemberDoc member, Content htmltree, int indentSize) {
         Type[] exceptions = member.thrownExceptionTypes();
-        if(exceptions.length > 0) {
+        if (exceptions.length > 0) {
             LinkInfoImpl memberTypeParam = new LinkInfoImpl(configuration,
-                    LinkInfoImpl.CONTEXT_MEMBER, member, false);
-            int retlen = getReturnTypeLength(member);
-            writer.getTypeParameterLinks(memberTypeParam);
-            retlen += memberTypeParam.displayLength == 0 ?
-                0 : memberTypeParam.displayLength + 1;
-            String indent = makeSpace(modifierString(member).length() +
-                    member.name().length() + retlen - 4);
+                    LinkInfoImpl.Kind.MEMBER, member);
+            String indent = makeSpace(indentSize + 1 - 7);
             htmltree.addContent(DocletConstants.NL);
             htmltree.addContent(indent);
             htmltree.addContent("throws ");
-            indent += "       ";
-            Content link = new RawHtml(writer.getLink(new LinkInfoImpl(configuration,
-                    LinkInfoImpl.CONTEXT_MEMBER, exceptions[0])));
+            indent = makeSpace(indentSize + 1);
+            Content link = writer.getLink(new LinkInfoImpl(configuration,
+                    LinkInfoImpl.Kind.MEMBER, exceptions[0]));
             htmltree.addContent(link);
             for(int i = 1; i < exceptions.length; i++) {
                 htmltree.addContent(",");
                 htmltree.addContent(DocletConstants.NL);
                 htmltree.addContent(indent);
-                Content exceptionLink = new RawHtml(writer.getLink(new LinkInfoImpl(
-                        configuration, LinkInfoImpl.CONTEXT_MEMBER, exceptions[i])));
+                Content exceptionLink = writer.getLink(new LinkInfoImpl(
+                        configuration, LinkInfoImpl.Kind.MEMBER, exceptions[i]));
                 htmltree.addContent(exceptionLink);
             }
         }
     }
 
-    protected int getReturnTypeLength(ExecutableMemberDoc member) {
-        if (member instanceof MethodDoc) {
-            MethodDoc method = (MethodDoc)member;
-            Type rettype = method.returnType();
-            if (rettype.isPrimitive()) {
-                return rettype.typeName().length() +
-                       rettype.dimension().length();
-            } else {
-                LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
-                    LinkInfoImpl.CONTEXT_MEMBER, rettype);
-                writer.getLink(linkInfo);
-                return linkInfo.displayLength;
-            }
-        } else {   // it's a constructordoc
-            return -1;
-        }
-    }
-
     protected ClassDoc implementsMethodInIntfac(MethodDoc method,
                                                 ClassDoc[] intfacs) {
         for (int i = 0; i < intfacs.length; i++) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
@@ -139,9 +139,8 @@
      * @param dlTree the content tree to which the description will be added
      */
     protected void addDescription(ClassDoc cd, Content dlTree) {
-        Content link = new RawHtml(
-                getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.CONTEXT_INDEX, cd, true)));
+        Content link = getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.Kind.INDEX, cd).strong(true));
         Content dt = HtmlTree.DT(link);
         dt.addContent(" - ");
         addClassInfo(cd, dt);
@@ -152,7 +151,7 @@
     }
 
     /**
-     * Add the classkind(class, interface, exception, error of the class
+     * Add the classkind (class, interface, exception), error of the class
      * passed.
      *
      * @param cd the class being documented
@@ -161,8 +160,9 @@
     protected void addClassInfo(ClassDoc cd, Content contentTree) {
         contentTree.addContent(getResource("doclet.in",
                 Util.getTypeName(configuration, cd, false),
-                getPackageLinkString(cd.containingPackage(),
-                Util.getPackageName(cd.containingPackage()), false)));
+                getPackageLink(cd.containingPackage(),
+                    Util.getPackageName(cd.containingPackage()))
+                ));
     }
 
     /**
@@ -175,11 +175,8 @@
         String name = (member instanceof ExecutableMemberDoc)?
             member.name() + ((ExecutableMemberDoc)member).flatSignature() :
             member.name();
-        if (name.indexOf("<") != -1 || name.indexOf(">") != -1) {
-                name = Util.escapeHtmlChars(name);
-        }
         Content span = HtmlTree.SPAN(HtmlStyle.strong,
-                getDocLink(LinkInfoImpl.CONTEXT_INDEX, member, name));
+                getDocLink(LinkInfoImpl.Kind.INDEX, member, name));
         Content dt = HtmlTree.DT(span);
         dt.addContent(" - ");
         addMemberDesc(member, dt);
@@ -253,7 +250,7 @@
                         getResource("doclet.Method_in", classdesc));
             }
         }
-        addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing,
+        addPreQualifiedClassLink(LinkInfoImpl.Kind.INDEX, containing,
                 false, contentTree);
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, 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
@@ -91,7 +91,7 @@
      *
      * @return a string for the table caption
      */
-    public abstract String getCaption();
+    public abstract Content getCaption();
 
     /**
      * Get the summary table header for the member.
@@ -143,7 +143,7 @@
      */
     protected void addSummaryLink(ClassDoc cd, ProgramElementDoc member,
             Content tdSummary) {
-        addSummaryLink(LinkInfoImpl.CONTEXT_MEMBER, cd, member, tdSummary);
+        addSummaryLink(LinkInfoImpl.Kind.MEMBER, cd, member, tdSummary);
     }
 
     /**
@@ -154,7 +154,7 @@
      * @param member the member to be documented
      * @param tdSummary the content tree to which the summary link will be added
      */
-    protected abstract void addSummaryLink(int context,
+    protected abstract void addSummaryLink(LinkInfoImpl.Kind context,
             ClassDoc cd, ProgramElementDoc member, Content tdSummary);
 
     /**
@@ -193,14 +193,13 @@
     protected abstract void addNavDetailLink(boolean link, Content liNav);
 
     /**
-     * Add the member name to the content tree and modifies the display length.
+     * Add the member name to the content tree.
      *
      * @param name the member name to be added to the content tree.
      * @param htmltree the content tree to which the name will be added.
      */
     protected void addName(String name, Content htmltree) {
         htmltree.addContent(name);
-        writer.displayLength += name.length();
     }
 
     /**
@@ -259,7 +258,7 @@
             return "";
         }
         StringBuilder sb = new StringBuilder(len);
-        for(int i = 0; i < len; i++) {
+        for (int i = 0; i < len; i++) {
             sb.append(' ');
     }
         return sb.toString();
@@ -286,19 +285,22 @@
         } else {
             if (member instanceof ExecutableMemberDoc &&
                     ((ExecutableMemberDoc) member).typeParameters().length > 0) {
+                Content typeParameters = ((AbstractExecutableMemberWriter) this).getTypeParameters(
+                        (ExecutableMemberDoc) member);
+                    code.addContent(typeParameters);
                 //Code to avoid ugly wrapping in member summary table.
-                int displayLength = ((AbstractExecutableMemberWriter) this).addTypeParameters(
-                        (ExecutableMemberDoc) member, code);
-                if (displayLength > 10) {
+                if (typeParameters.charCount() > 10) {
                     code.addContent(new HtmlTree(HtmlTag.BR));
+                } else {
+                    code.addContent(writer.getSpace());
                 }
-                code.addContent(new RawHtml(
+                code.addContent(
                         writer.getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
+                        LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
             } else {
-                code.addContent(new RawHtml(
+                code.addContent(
                         writer.getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
+                        LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
             }
 
         }
@@ -346,10 +348,10 @@
      * @param contentTree the content tree to which the deprecated information will be added.
      */
     protected void addDeprecatedInfo(ProgramElementDoc member, Content contentTree) {
-        String output = (new DeprecatedTaglet()).getTagletOutput(member,
-            writer.getTagletWriterInstance(false)).toString().trim();
+        Content output = (new DeprecatedTaglet()).getTagletOutput(member,
+            writer.getTagletWriterInstance(false));
         if (!output.isEmpty()) {
-            Content deprecatedContent = new RawHtml(output);
+            Content deprecatedContent = output;
             Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent);
             contentTree.addContent(div);
         }
@@ -378,7 +380,7 @@
      * @return a header content for the section.
      */
     protected Content getHead(MemberDoc member) {
-        Content memberContent = new RawHtml(member.name());
+        Content memberContent = new StringContent(member.name());
         Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent);
         return heading;
     }
@@ -412,7 +414,7 @@
             String tableSummary, String[] tableHeader, Content contentTree) {
         if (deprmembers.size() > 0) {
             Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
-                writer.getTableCaption(configuration.getText(headingKey)));
+                writer.getTableCaption(configuration.getResource(headingKey)));
             table.addContent(writer.getSummaryTableHeader(tableHeader, "col"));
             Content tbody = new HtmlTree(HtmlTag.TBODY);
             for (int i = 0; i < deprmembers.size(); i++) {
@@ -444,7 +446,7 @@
      * @param contentTree the content tree to which the use information will be added
      */
     protected void addUseInfo(List<? extends ProgramElementDoc> mems,
-            String heading, String tableSummary, Content contentTree) {
+            Content heading, String tableSummary, Content contentTree) {
         if (mems == null) {
             return;
         }
@@ -483,7 +485,7 @@
                     tdLast.addContent(name);
                 }
                 addSummaryLink(pgmdoc instanceof ClassDoc ?
-                    LinkInfoImpl.CONTEXT_CLASS_USE : LinkInfoImpl.CONTEXT_MEMBER,
+                    LinkInfoImpl.Kind.CLASS_USE : LinkInfoImpl.Kind.MEMBER,
                     cd, pgmdoc, tdLast);
                 writer.addSummaryLinkComment(this, pgmdoc, tdLast);
                 tr.addContent(tdLast);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -158,10 +158,10 @@
             }
             body.addContent(div);
             if (configuration.showProfiles) {
-                String profileSummary = configuration.getText("doclet.Profiles");
-                String profilesTableSummary = configuration.getText("doclet.Member_Table_Summary",
-                configuration.getText("doclet.Profile_Summary"),
-                configuration.getText("doclet.profiles"));
+                Content profileSummary = configuration.getResource("doclet.Profiles");
+                Content profilesTableSummary = configuration.getResource("doclet.Member_Table_Summary",
+                        configuration.getResource("doclet.Profile_Summary"),
+                        configuration.getResource("doclet.profiles"));
                 addProfilesList(profileSummary, profilesTableSummary, body);
             }
             addPackagesList(packages, text, tableSummary, body);
@@ -217,7 +217,7 @@
      * @param profilesTableSummary the profiles table summary information
      * @param body the content tree to which the profiles list will be added
      */
-    protected void addProfilesList(String profileSummary, String profilesTableSummary,
+    protected void addProfilesList(Content profileSummary, Content profilesTableSummary,
             Content body) {
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
@@ -152,7 +152,7 @@
                     } else {
                         contentTree.addContent(", ");
                     }
-                    addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE,
+                    addPreQualifiedClassLink(LinkInfoImpl.Kind.TREE,
                             interfaces[i], contentTree);
                     counter++;
                 }
@@ -170,7 +170,7 @@
      * @param contentTree the content tree to which the information will be added
      */
     protected void addPartialInfo(ClassDoc cd, Content contentTree) {
-        addPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd, contentTree);
+        addPreQualifiedStrongClassLink(LinkInfoImpl.Kind.TREE, cd, contentTree);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
@@ -156,14 +156,13 @@
             if (!Util.isCoreClass(cd)) {
                 continue;
             }
-            String label = italicsClassName(cd, false);
+            Content label = italicsClassName(cd, false);
             Content linkContent;
-            if(wantFrames){
-                linkContent = new RawHtml(getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.ALL_CLASSES_FRAME, cd, label, "classFrame")));
+            if (wantFrames) {
+                linkContent = getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.Kind.ALL_CLASSES_FRAME, cd).label(label).target("classFrame"));
             } else {
-                linkContent = new RawHtml(getLink(new LinkInfoImpl(
-                        configuration, cd, label)));
+                linkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, cd).label(label));
             }
             Content li = HtmlTree.LI(linkContent);
             content.addContent(li);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -111,8 +111,8 @@
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration.getText("doclet.Annotation_Type_Optional_Members");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Annotation_Type_Optional_Members");
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -105,9 +105,9 @@
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(member, pre);
         addModifiers(member, pre);
-        Content link = new RawHtml(
+        Content link =
                 writer.getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.CONTEXT_MEMBER, getType(member))));
+                        LinkInfoImpl.Kind.MEMBER, getType(member)));
         pre.addContent(link);
         pre.addContent(writer.getSpace());
         if (configuration.linksource) {
@@ -183,8 +183,8 @@
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration.getText("doclet.Annotation_Type_Required_Members");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Annotation_Type_Required_Members");
     }
 
     /**
@@ -223,10 +223,10 @@
     /**
      * {@inheritDoc}
      */
-    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
+    protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
             Content tdSummary) {
-        Content strong = HtmlTree.STRONG(new RawHtml(
-                writer.getDocLink(context, (MemberDoc) member, member.name(), false)));
+        Content strong = HtmlTree.STRONG(
+                writer.getDocLink(context, (MemberDoc) member, member.name(), false));
         Content code = HtmlTree.CODE(strong);
         tdSummary.addContent(code);
     }
@@ -251,7 +251,7 @@
      * {@inheritDoc}
      */
     protected Content getDeprecatedLink(ProgramElementDoc member) {
-        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+        return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
                 (MemberDoc) member, ((MemberDoc)member).qualifiedName());
     }
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -116,9 +116,9 @@
     public Content getNavLinkPrevious() {
         Content li;
         if (prev != null) {
-            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
-                    LinkInfoImpl.CONTEXT_CLASS, prev.asClassDoc(), "",
-                    configuration.getText("doclet.Prev_Class"), true)));
+            Content prevLink = getLink(new LinkInfoImpl(configuration,
+                    LinkInfoImpl.Kind.CLASS, prev.asClassDoc())
+                    .label(configuration.getText("doclet.Prev_Class")).strong(true));
             li = HtmlTree.LI(prevLink);
         }
         else
@@ -134,9 +134,9 @@
     public Content getNavLinkNext() {
         Content li;
         if (next != null) {
-            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
-                    LinkInfoImpl.CONTEXT_CLASS, next.asClassDoc(), "",
-                    configuration.getText("doclet.Next_Class"), true)));
+            Content nextLink = getLink(new LinkInfoImpl(configuration,
+                    LinkInfoImpl.Kind.CLASS, next.asClassDoc())
+                    .label(configuration.getText("doclet.Next_Class")).strong(true));
             li = HtmlTree.LI(nextLink);
         }
         else
@@ -163,11 +163,11 @@
             div.addContent(pkgNameDiv);
         }
         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
-                LinkInfoImpl.CONTEXT_CLASS_HEADER, annotationType, false);
+                LinkInfoImpl.Kind.CLASS_HEADER, annotationType);
         Content headerContent = new StringContent(header);
         Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
                 HtmlStyle.title, headerContent);
-        heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo)));
+        heading.addContent(getTypeParameterLinks(linkInfo));
         div.addContent(heading);
         bodyTree.addContent(div);
         return bodyTree;
@@ -220,9 +220,9 @@
         addAnnotationInfo(annotationType, pre);
         pre.addContent(modifiers);
         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
-                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false);
+                LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType);
         Content annotationName = new StringContent(annotationType.name());
-        Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo));
+        Content parameterLinks = getTypeParameterLinks(linkInfo);
         if (configuration.linksource) {
             addSrcLink(annotationType, annotationName, pre);
             pre.addContent(parameterLinks);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
@@ -256,10 +256,10 @@
      */
     protected void addPackageList(Content contentTree) throws IOException {
         Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
-                getTableCaption(configuration.getText(
+                getTableCaption(configuration.getResource(
                 "doclet.ClassUse_Packages.that.use.0",
-                getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
-                false)))));
+                getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc
+                )))));
         table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
         Content tbody = new HtmlTree(HtmlTag.TBODY);
         Iterator<PackageDoc> it = pkgSet.iterator();
@@ -291,10 +291,10 @@
             return;
         }
         Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
-                getTableCaption(configuration.getText(
+                getTableCaption(configuration.getResource(
                 "doclet.ClassUse_PackageAnnotation",
                 getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false)))));
+                        LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)))));
         table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
         Content tbody = new HtmlTree(HtmlTag.TBODY);
         Iterator<PackageDoc> it = pkgToPackageAnnotations.iterator();
@@ -331,11 +331,10 @@
         for (Iterator<PackageDoc> it = pkgSet.iterator(); it.hasNext();) {
             PackageDoc pkg = it.next();
             Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(pkg.name()));
-            Content link = new RawHtml(
-                    configuration.getText("doclet.ClassUse_Uses.of.0.in.1",
-                    getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER,
-                    classdoc, false)),
-                    getPackageLinkString(pkg, Util.getPackageName(pkg), false)));
+            Content link = getResource("doclet.ClassUse_Uses.of.0.in.1",
+                    getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER,
+                    classdoc)),
+                    getPackageLink(pkg, Util.getPackageName(pkg)));
             Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
             li.addContent(heading);
             addClassUse(pkg, li);
@@ -368,71 +367,71 @@
      * @param contentTree the content tree to which the class use information will be added
      */
     protected void addClassUse(PackageDoc pkg, Content contentTree) throws IOException {
-        String classLink = getLink(new LinkInfoImpl(configuration,
-            LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false));
-        String pkgLink = getPackageLinkString(pkg, Util.getPackageName(pkg), false);
+        Content classLink = getLink(new LinkInfoImpl(configuration,
+            LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc));
+        Content pkgLink = getPackageLink(pkg, Util.getPackageName(pkg));
         classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_Annotation", classLink,
+                configuration.getResource("doclet.ClassUse_Annotation", classLink,
                 pkgLink), classUseTableSummary, contentTree);
         classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_TypeParameter", classLink,
+                configuration.getResource("doclet.ClassUse_TypeParameter", classLink,
                 pkgLink), classUseTableSummary, contentTree);
         classSubWriter.addUseInfo(pkgToSubclass.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_Subclass", classLink,
+                configuration.getResource("doclet.ClassUse_Subclass", classLink,
                 pkgLink), subclassUseTableSummary, contentTree);
         classSubWriter.addUseInfo(pkgToSubinterface.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_Subinterface", classLink,
+                configuration.getResource("doclet.ClassUse_Subinterface", classLink,
                 pkgLink), subinterfaceUseTableSummary, contentTree);
         classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ImplementingClass", classLink,
+                configuration.getResource("doclet.ClassUse_ImplementingClass", classLink,
                 pkgLink), classUseTableSummary, contentTree);
         fieldSubWriter.addUseInfo(pkgToField.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_Field", classLink,
+                configuration.getResource("doclet.ClassUse_Field", classLink,
                 pkgLink), fieldUseTableSummary, contentTree);
         fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_FieldAnnotations", classLink,
+                configuration.getResource("doclet.ClassUse_FieldAnnotations", classLink,
                 pkgLink), fieldUseTableSummary, contentTree);
         fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_FieldTypeParameter", classLink,
+                configuration.getResource("doclet.ClassUse_FieldTypeParameter", classLink,
                 pkgLink), fieldUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodAnnotations", classLink,
+                configuration.getResource("doclet.ClassUse_MethodAnnotations", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodParameterAnnotations", classLink,
+                configuration.getResource("doclet.ClassUse_MethodParameterAnnotations", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodTypeParameter", classLink,
+                configuration.getResource("doclet.ClassUse_MethodTypeParameter", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodReturn", classLink,
+                configuration.getResource("doclet.ClassUse_MethodReturn", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodReturnTypeParameter", classLink,
+                configuration.getResource("doclet.ClassUse_MethodReturnTypeParameter", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodArgs", classLink,
+                configuration.getResource("doclet.ClassUse_MethodArgs", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodArgsTypeParameters", classLink,
+                configuration.getResource("doclet.ClassUse_MethodArgsTypeParameters", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_MethodThrows", classLink,
+                configuration.getResource("doclet.ClassUse_MethodThrows", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ConstructorAnnotations", classLink,
+                configuration.getResource("doclet.ClassUse_ConstructorAnnotations", classLink,
                 pkgLink), constructorUseTableSummary, contentTree);
         constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
+                configuration.getResource("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
                 pkgLink), constructorUseTableSummary, contentTree);
         constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ConstructorArgs", classLink,
+                configuration.getResource("doclet.ClassUse_ConstructorArgs", classLink,
                 pkgLink), constructorUseTableSummary, contentTree);
         constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
+                configuration.getResource("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
                 pkgLink), constructorUseTableSummary, contentTree);
         constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg.name()),
-                configuration.getText("doclet.ClassUse_ConstructorThrows", classLink,
+                configuration.getResource("doclet.ClassUse_ConstructorThrows", classLink,
                 pkgLink), constructorUseTableSummary, contentTree);
     }
 
@@ -450,7 +449,10 @@
         Content bodyTree = getBody(true, getWindowTitle(title));
         addTop(bodyTree);
         addNavLinks(true, bodyTree);
-        Content headContent = getResource("doclet.ClassUse_Title", cltype, clname);
+        ContentBuilder headContent = new ContentBuilder();
+        headContent.addContent(getResource("doclet.ClassUse_Title", cltype));
+        headContent.addContent(new HtmlTree(HtmlTag.BR));
+        headContent.addContent(clname);
         Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING,
                 true, HtmlStyle.title, headContent);
         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
@@ -476,9 +478,9 @@
      * @return a content tree for the class page link
      */
     protected Content getNavLinkClass() {
-        Content linkContent = new RawHtml(getLink(new LinkInfoImpl(
-                configuration, LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
-                "", configuration.getText("doclet.Class"), false)));
+        Content linkContent = getLink(new LinkInfoImpl(
+                configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)
+                .label(configuration.getText("doclet.Class")));
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -124,9 +124,9 @@
     public Content getNavLinkPrevious() {
         Content li;
         if (prev != null) {
-            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
-                    LinkInfoImpl.CONTEXT_CLASS, prev, "",
-                    configuration.getText("doclet.Prev_Class"), true)));
+            Content prevLink = getLink(new LinkInfoImpl(configuration,
+                    LinkInfoImpl.Kind.CLASS, prev)
+                    .label(configuration.getText("doclet.Prev_Class")).strong(true));
             li = HtmlTree.LI(prevLink);
         }
         else
@@ -142,9 +142,9 @@
     public Content getNavLinkNext() {
         Content li;
         if (next != null) {
-            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
-                    LinkInfoImpl.CONTEXT_CLASS, next, "",
-                    configuration.getText("doclet.Next_Class"), true)));
+            Content nextLink = getLink(new LinkInfoImpl(configuration,
+                    LinkInfoImpl.Kind.CLASS, next)
+                    .label(configuration.getText("doclet.Next_Class")).strong(true));
             li = HtmlTree.LI(nextLink);
         }
         else
@@ -185,13 +185,13 @@
             div.addContent(pkgNameDiv);
         }
         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
-                LinkInfoImpl.CONTEXT_CLASS_HEADER, classDoc, false);
+                LinkInfoImpl.Kind.CLASS_HEADER, classDoc);
         //Let's not link to ourselves in the header.
         linkInfo.linkToSelf = false;
         Content headerContent = new StringContent(header);
         Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
                 HtmlStyle.title, headerContent);
-        heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo)));
+        heading.addContent(getTypeParameterLinks(linkInfo));
         div.addContent(heading);
         bodyTree.addContent(div);
         return bodyTree;
@@ -245,11 +245,11 @@
         addAnnotationInfo(classDoc, pre);
         pre.addContent(modifiers);
         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
-                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false);
+                LinkInfoImpl.Kind.CLASS_SIGNATURE, classDoc);
         //Let's not link to ourselves in the signature.
         linkInfo.linkToSelf = false;
         Content className = new StringContent(classDoc.name());
-        Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo));
+        Content parameterLinks = getTypeParameterLinks(linkInfo);
         if (configuration.linksource) {
             addSrcLink(classDoc, className, pre);
             pre.addContent(parameterLinks);
@@ -264,9 +264,9 @@
             if (superclass != null) {
                 pre.addContent(DocletConstants.NL);
                 pre.addContent("extends ");
-                Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
-                        superclass)));
+                Content link = getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
+                        superclass));
                 pre.addContent(link);
             }
         }
@@ -285,9 +285,9 @@
                 } else {
                     pre.addContent(", ");
                 }
-                Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
-                        implIntfacs[i])));
+                Content link = getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
+                        implIntfacs[i]));
                 pre.addContent(link);
                 counter++;
             }
@@ -360,22 +360,21 @@
     private Content getTreeForClassHelper(Type type) {
         Content li = new HtmlTree(HtmlTag.LI);
         if (type.equals(classDoc)) {
-            String typeParameters = getTypeParameterLinks(
-                    new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_TREE,
-                    classDoc, false));
+            Content typeParameters = getTypeParameterLinks(
+                    new LinkInfoImpl(configuration, LinkInfoImpl.Kind.TREE,
+                    classDoc));
             if (configuration.shouldExcludeQualifier(
                     classDoc.containingPackage().name())) {
                 li.addContent(type.asClassDoc().name());
-                li.addContent(new RawHtml(typeParameters));
+                li.addContent(typeParameters);
             } else {
                 li.addContent(type.asClassDoc().qualifiedName());
-                li.addContent(new RawHtml(typeParameters));
+                li.addContent(typeParameters);
             }
         } else {
-            Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
-                    LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT,
-                    type instanceof ClassDoc ? (ClassDoc) type : type,
-                    configuration.getClassName(type.asClassDoc()), false)));
+            Content link = getLink(new LinkInfoImpl(configuration,
+                    LinkInfoImpl.Kind.CLASS_TREE_PARENT, type)
+                    .label(configuration.getClassName(type.asClassDoc())));
             li.addContent(link);
         }
         return li;
@@ -396,9 +395,8 @@
      */
     public void addTypeParamInfo(Content classInfoTree) {
         if (classDoc.typeParamTags().length > 0) {
-            TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc,
+            Content typeParam = (new ParamTaglet()).getTagletOutput(classDoc,
                     getTagletWriterInstance(false));
-            Content typeParam = new RawHtml(output.toString());
             Content dl = HtmlTree.DL(typeParam);
             classInfoTree.addContent(dl);
         }
@@ -419,7 +417,7 @@
                         "doclet.Subclasses");
                 Content dt = HtmlTree.DT(label);
                 Content dl = HtmlTree.DL(dt);
-                dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES,
+                dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES,
                         subclasses));
                 classInfoTree.addContent(dl);
             }
@@ -437,7 +435,7 @@
                         "doclet.Subinterfaces");
                 Content dt = HtmlTree.DT(label);
                 Content dl = HtmlTree.DL(dt);
-                dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES,
+                dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES,
                         subInterfaces));
                 classInfoTree.addContent(dl);
             }
@@ -461,7 +459,7 @@
                     "doclet.Implementing_Classes");
             Content dt = HtmlTree.DT(label);
             Content dl = HtmlTree.DL(dt);
-            dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES,
+            dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES,
                     implcl));
             classInfoTree.addContent(dl);
         }
@@ -479,7 +477,7 @@
                     "doclet.All_Implemented_Interfaces");
             Content dt = HtmlTree.DT(label);
             Content dl = HtmlTree.DL(dt);
-            dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES,
+            dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES,
                     interfaceArray));
             classInfoTree.addContent(dl);
         }
@@ -497,7 +495,7 @@
                     "doclet.All_Superinterfaces");
             Content dt = HtmlTree.DT(label);
             Content dl = HtmlTree.DL(dt);
-            dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES,
+            dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES,
                     interfaceArray));
             classInfoTree.addContent(dl);
         }
@@ -520,8 +518,8 @@
             Content dt = HtmlTree.DT(label);
             Content dl = HtmlTree.DL(dt);
             Content dd = new HtmlTree(HtmlTag.DD);
-            dd.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration,
-                    LinkInfoImpl.CONTEXT_CLASS, outerClass, false))));
+            dd.addContent(getLink(new LinkInfoImpl(configuration,
+                    LinkInfoImpl.Kind.CLASS, outerClass)));
             dl.addContent(dd);
             classInfoTree.addContent(dl);
         }
@@ -569,7 +567,7 @@
      * @param list the list of classes
      * @return a content tree for the class list
      */
-    private Content getClassLinks(int context, List<?> list) {
+    private Content getClassLinks(LinkInfoImpl.Kind context, List<?> list) {
         Object[] typeList = list.toArray();
         Content dd = new HtmlTree(HtmlTag.DD);
         for (int i = 0; i < list.size(); i++) {
@@ -578,12 +576,12 @@
                 dd.addContent(separator);
             }
             if (typeList[i] instanceof ClassDoc) {
-                Content link = new RawHtml(getLink(
-                        new LinkInfoImpl(configuration, context, (ClassDoc)(typeList[i]))));
+                Content link = getLink(
+                        new LinkInfoImpl(configuration, context, (ClassDoc)(typeList[i])));
                 dd.addContent(link);
             } else {
-                Content link = new RawHtml(getLink(
-                        new LinkInfoImpl(configuration, context, (Type)(typeList[i]))));
+                Content link = getLink(
+                        new LinkInfoImpl(configuration, context, (Type)(typeList[i])));
                 dd.addContent(link);
             }
         }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -31,6 +31,7 @@
 import javax.tools.JavaFileManager;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.ContentBuilder;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclint.DocLint;
@@ -562,4 +563,9 @@
         }
         return true;
     }
+
+    @Override
+    public Content newContent() {
+        return new ContentBuilder();
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, 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
@@ -184,13 +184,17 @@
      */
     public Content getConstantMembersHeader(ClassDoc cd) {
         //generate links backward only to public classes.
-        String classlink = (cd.isPublic() || cd.isProtected()) ?
+        Content classlink = (cd.isPublic() || cd.isProtected()) ?
             getLink(new LinkInfoImpl(configuration,
-                    LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd, false)) :
-            cd.qualifiedName();
+                    LinkInfoImpl.Kind.CONSTANT_SUMMARY, cd)) :
+            new StringContent(cd.qualifiedName());
         String name = cd.containingPackage().name();
         if (name.length() > 0) {
-            return getClassName(name + "." + classlink);
+            Content cb = new ContentBuilder();
+            cb.addContent(name);
+            cb.addContent(".");
+            cb.addContent(classlink);
+            return getClassName(cb);
         } else {
             return getClassName(classlink);
         }
@@ -202,7 +206,7 @@
      * @param classStr the class name to print.
      * @return the table caption and header
      */
-    protected Content getClassName(String classStr) {
+    protected Content getClassName(Content classStr) {
         Content table = HtmlTree.TABLE(0, 3, 0, constantsTableSummary,
                 getTableCaption(classStr));
         table.addContent(getSummaryTableHeader(constantsTableHeader, "col"));
@@ -260,8 +264,8 @@
             code.addContent(modifier);
             code.addContent(getSpace());
         }
-        Content type = new RawHtml(getLink(new LinkInfoImpl(configuration,
-                LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member.type())));
+        Content type = getLink(new LinkInfoImpl(configuration,
+                LinkInfoImpl.Kind.CONSTANT_SUMMARY, member.type()));
         code.addContent(type);
         tdType.addContent(code);
         return tdType;
@@ -274,8 +278,8 @@
      * @return the name column of the constant table row
      */
     private Content getNameColumn(FieldDoc member) {
-        Content nameContent = new RawHtml(getDocLink(
-                LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member, member.name(), false));
+        Content nameContent = getDocLink(
+                LinkInfoImpl.Kind.CONSTANT_SUMMARY, member, member.name(), false);
         Content code = HtmlTree.CODE(nameContent);
         return HtmlTree.TD(code);
     }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -126,7 +126,6 @@
      * {@inheritDoc}
      */
     public Content getSignature(ConstructorDoc constructor) {
-        writer.displayLength = 0;
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(constructor, pre);
         addModifiers(constructor, pre);
@@ -136,8 +135,9 @@
         } else {
             addName(constructor.name(), pre);
         }
-        addParameters(constructor, pre);
-        addExceptions(constructor, pre);
+        int indent = pre.charCount();
+        addParameters(constructor, pre, indent);
+        addExceptions(constructor, pre, indent);
         return pre;
     }
 
@@ -225,8 +225,8 @@
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration.getText("doclet.Constructors");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Constructors");
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -101,8 +101,8 @@
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(enumConstant, pre);
         addModifiers(enumConstant, pre);
-        Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(
-                configuration, LinkInfoImpl.CONTEXT_MEMBER, enumConstant.type())));
+        Content enumConstantLink = writer.getLink(new LinkInfoImpl(
+                configuration, LinkInfoImpl.Kind.MEMBER, enumConstant.type()));
         pre.addContent(enumConstantLink);
         pre.addContent(" ");
         if (configuration.linksource) {
@@ -182,8 +182,8 @@
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration.getText("doclet.Enum_Constants");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Enum_Constants");
     }
 
     /**
@@ -220,10 +220,10 @@
     /**
      * {@inheritDoc}
      */
-    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
+    protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
             Content tdSummary) {
-        Content strong = HtmlTree.STRONG(new RawHtml(
-                writer.getDocLink(context, (MemberDoc) member, member.name(), false)));
+        Content strong = HtmlTree.STRONG(
+                writer.getDocLink(context, (MemberDoc) member, member.name(), false));
         Content code = HtmlTree.CODE(strong);
         tdSummary.addContent(code);
     }
@@ -254,7 +254,7 @@
      * {@inheritDoc}
      */
     protected Content getDeprecatedLink(ProgramElementDoc member) {
-        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+        return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
                 (MemberDoc) member, ((FieldDoc)member).qualifiedName());
     }
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, 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
@@ -102,8 +102,8 @@
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(field, pre);
         addModifiers(field, pre);
-        Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(
-                configuration, LinkInfoImpl.CONTEXT_MEMBER, field.type())));
+        Content fieldlink = writer.getLink(new LinkInfoImpl(
+                configuration, LinkInfoImpl.Kind.MEMBER, field.type()));
         pre.addContent(fieldlink);
         pre.addContent(" ");
         if (configuration.linksource) {
@@ -132,12 +132,12 @@
                     (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
                 writer.addInlineComment(field, fieldDocTree);
             } else {
-                Content link = new RawHtml(
-                        writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
+                Content link =
+                        writer.getDocLink(LinkInfoImpl.Kind.FIELD_DOC_COPY,
                         holder, field,
                         holder.isIncluded() ?
                             holder.typeName() : holder.qualifiedTypeName(),
-                            false));
+                            false);
                 Content codeLink = HtmlTree.CODE(link);
                 Content strong = HtmlTree.STRONG(holder.isClass()?
                    writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
@@ -203,8 +203,8 @@
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration.getText("doclet.Fields");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Fields");
     }
 
     /**
@@ -239,8 +239,8 @@
      * {@inheritDoc}
      */
     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
-        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
-                LinkInfoImpl.CONTEXT_MEMBER, cd, false));
+        Content classLink = writer.getPreQualifiedClassLink(
+                LinkInfoImpl.Kind.MEMBER, cd, false);
         Content label = new StringContent(cd.isClass() ?
             configuration.getText("doclet.Fields_Inherited_From_Class") :
             configuration.getText("doclet.Fields_Inherited_From_Interface"));
@@ -254,10 +254,10 @@
     /**
      * {@inheritDoc}
      */
-    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
+    protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
             Content tdSummary) {
-        Content strong = HtmlTree.STRONG(new RawHtml(
-                writer.getDocLink(context, cd , (MemberDoc) member, member.name(), false)));
+        Content strong = HtmlTree.STRONG(
+                writer.getDocLink(context, cd , (MemberDoc) member, member.name(), false));
         Content code = HtmlTree.CODE(strong);
         tdSummary.addContent(code);
     }
@@ -267,9 +267,9 @@
      */
     protected void addInheritedSummaryLink(ClassDoc cd,
             ProgramElementDoc member, Content linksTree) {
-        linksTree.addContent(new RawHtml(
-                writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
-                member.name(), false)));
+        linksTree.addContent(
+                writer.getDocLink(LinkInfoImpl.Kind.MEMBER, cd, (MemberDoc)member,
+                member.name(), false));
     }
 
     /**
@@ -284,7 +284,7 @@
      * {@inheritDoc}
      */
     protected Content getDeprecatedLink(ProgramElementDoc member) {
-        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+        return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
                 (MemberDoc) member, ((FieldDoc)member).qualifiedName());
     }
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -121,7 +121,7 @@
                 getResource("doclet.Frame_Alert"));
         noframes.addContent(noframesHead);
         Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message",
-                getHyperLinkString(configuration.topFile,
+                getHyperLink(configuration.topFile,
                 configuration.getText("doclet.Non_Frame_Version"))));
         noframes.addContent(p);
         contentTree.addContent(noframes);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
@@ -113,7 +113,7 @@
                 getResource("doclet.Overview"));
             Content liOverview = HtmlTree.LI(HtmlStyle.blockList, overviewHeading);
             Content line3 = getResource("doclet.Help_line_3",
-                    getHyperLinkString(DocPaths.OVERVIEW_SUMMARY,
+                    getHyperLink(DocPaths.OVERVIEW_SUMMARY,
                     configuration.getText("doclet.Overview")));
             Content overviewPara = HtmlTree.P(line3);
             liOverview.addContent(overviewPara);
@@ -234,8 +234,9 @@
                     getResource("doclet.Help_line_16"));
             Content liTree = HtmlTree.LI(HtmlStyle.blockList, treeHead);
             Content line17 = getResource("doclet.Help_line_17_with_tree_link",
-                    getHyperLinkString(DocPaths.OVERVIEW_TREE,
-                    configuration.getText("doclet.Class_Hierarchy")));
+                    getHyperLink(DocPaths.OVERVIEW_TREE,
+                    configuration.getText("doclet.Class_Hierarchy")),
+                    HtmlTree.CODE(new StringContent("java.lang.Object")));
             Content treePara = HtmlTree.P(line17);
             liTree.addContent(treePara);
             HtmlTree tul = new HtmlTree(HtmlTag.UL);
@@ -252,19 +253,19 @@
                     getResource("doclet.Deprecated_API"));
             Content liDeprecated = HtmlTree.LI(HtmlStyle.blockList, dHead);
             Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link",
-                    getHyperLinkString(DocPaths.DEPRECATED_LIST,
+                    getHyperLink(DocPaths.DEPRECATED_LIST,
                     configuration.getText("doclet.Deprecated_API")));
             Content dPara = HtmlTree.P(line20);
             liDeprecated.addContent(dPara);
             ul.addContent(liDeprecated);
         }
         if (configuration.createindex) {
-            String indexlink;
+            Content indexlink;
             if (configuration.splitindex) {
-                indexlink = getHyperLinkString(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)),
+                indexlink = getHyperLink(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)),
                         configuration.getText("doclet.Index"));
             } else {
-                indexlink = getHyperLinkString(DocPaths.INDEX_ALL,
+                indexlink = getHyperLink(DocPaths.INDEX_ALL,
                         configuration.getText("doclet.Index"));
             }
             Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
@@ -293,7 +294,7 @@
                 getResource("doclet.All_Classes"));
         Content liAllClasses = HtmlTree.LI(HtmlStyle.blockList, allclassesHead);
         Content line27 = getResource("doclet.Help_line_27",
-                getHyperLinkString(DocPaths.ALLCLASSES_NOFRAME,
+                getHyperLink(DocPaths.ALLCLASSES_NOFRAME,
                 configuration.getText("doclet.All_Classes")));
         Content allclassesPara = HtmlTree.P(line27);
         liAllClasses.addContent(allclassesPara);
@@ -309,7 +310,7 @@
                 getResource("doclet.Constants_Summary"));
         Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead);
         Content line29 = getResource("doclet.Help_line_29",
-                getHyperLinkString(DocPaths.CONSTANT_VALUES,
+                getHyperLink(DocPaths.CONSTANT_VALUES,
                 configuration.getText("doclet.Constants_Summary")));
         Content constPara = HtmlTree.P(line29);
         liConst.addContent(constPara);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -75,11 +75,6 @@
     public final DocPath filename;
 
     /**
-     * The display length used for indentation while generating the class page.
-     */
-    public int displayLength = 0;
-
-    /**
      * The global configuration information for this run.
      */
     public final ConfigurationImpl configuration;
@@ -251,15 +246,11 @@
         if (doc instanceof MethodDoc) {
             addMethodInfo((MethodDoc) doc, dl);
         }
-        TagletOutputImpl output = new TagletOutputImpl("");
+        Content output = new ContentBuilder();
         TagletWriter.genTagOuput(configuration.tagletManager, doc,
-            configuration.tagletManager.getCustomTags(doc),
+            configuration.tagletManager.getCustomTaglets(doc),
                 getTagletWriterInstance(false), output);
-        String outputString = output.toString().trim();
-        if (!outputString.isEmpty()) {
-            Content resultString = new RawHtml(outputString);
-            dl.addContent(resultString);
-        }
+        dl.addContent(output);
         htmltree.addContent(dl);
     }
 
@@ -271,11 +262,11 @@
      * @return true if there are tags to be printed else return false.
      */
     protected boolean hasSerializationOverviewTags(FieldDoc field) {
-        TagletOutputImpl output = new TagletOutputImpl("");
+        Content output = new ContentBuilder();
         TagletWriter.genTagOuput(configuration.tagletManager, field,
-            configuration.tagletManager.getCustomTags(field),
+            configuration.tagletManager.getCustomTaglets(field),
                 getTagletWriterInstance(false), output);
-        return (!output.toString().trim().isEmpty());
+        return !output.isEmpty();
     }
 
     /**
@@ -359,7 +350,7 @@
             int profileValue) {
         if(classes.length > 0) {
             Arrays.sort(classes);
-            Content caption = getTableCaption(label);
+            Content caption = getTableCaption(new RawHtml(label));
             Content table = HtmlTree.TABLE(HtmlStyle.packageSummary, 0, 3, 0,
                     tableSummary, caption);
             table.addContent(getSummaryTableHeader(tableHeader, "col"));
@@ -372,9 +363,8 @@
                     !configuration.isGeneratedDoc(classes[i])) {
                     continue;
                 }
-                Content classContent = new RawHtml(getLink(new LinkInfoImpl(
-                        configuration, LinkInfoImpl.CONTEXT_PACKAGE, classes[i],
-                        false)));
+                Content classContent = getLink(new LinkInfoImpl(
+                        configuration, LinkInfoImpl.Kind.PACKAGE, classes[i]));
                 Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
                 HtmlTree tr = HtmlTree.TR(tdClass);
                 if (i%2 == 0)
@@ -879,8 +869,7 @@
      * @param rawText the caption for the table which could be raw Html
      * @return a content tree for the caption
      */
-    public Content getTableCaption(String rawText) {
-        Content title = new RawHtml(rawText);
+    public Content getTableCaption(Content title) {
         Content captionSpan = HtmlTree.SPAN(title);
         Content space = getSpace();
         Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
@@ -948,7 +937,7 @@
             String tableSummary, String[] tableHeader, Content contentTree) {
         if (deprPkgs.size() > 0) {
             Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
-                    getTableCaption(configuration.getText(headingKey)));
+                    getTableCaption(configuration.getResource(headingKey)));
             table.addContent(getSummaryTableHeader(tableHeader, "col"));
             Content tbody = new HtmlTree(HtmlTag.TBODY);
             for (int i = 0; i < deprPkgs.size(); i++) {
@@ -1001,46 +990,10 @@
      *
      * @param pkg the package to link to.
      * @param label the label for the link.
-     * @param isStrong true if the label should be strong.
-     * @return the link to the given package.
-     */
-    public String getPackageLinkString(PackageDoc pkg, String label,
-                                 boolean isStrong) {
-        return getPackageLinkString(pkg, label, isStrong, "");
-    }
-
-    /**
-     * Return the link to the given package.
-     *
-     * @param pkg the package to link to.
-     * @param label the label for the link.
-     * @param isStrong true if the label should be strong.
-     * @param style  the font of the package link label.
-     * @return the link to the given package.
+     * @return a content tree for the package link.
      */
-    public String getPackageLinkString(PackageDoc pkg, String label, boolean isStrong,
-            String style) {
-        boolean included = pkg != null && pkg.isIncluded();
-        if (! included) {
-            PackageDoc[] packages = configuration.packages;
-            for (int i = 0; i < packages.length; i++) {
-                if (packages[i].equals(pkg)) {
-                    included = true;
-                    break;
-                }
-            }
-        }
-        if (included || pkg == null) {
-            return getHyperLinkString(pathString(pkg, DocPaths.PACKAGE_SUMMARY),
-                                label, isStrong, style);
-        } else {
-            DocLink crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
-            if (crossPkgLink != null) {
-                return getHyperLinkString(crossPkgLink, label, isStrong, style);
-            } else {
-                return label;
-            }
-        }
+    public Content getPackageLink(PackageDoc pkg, String label) {
+        return getPackageLink(pkg, new StringContent(label));
     }
 
     /**
@@ -1074,9 +1027,9 @@
         }
     }
 
-    public String italicsClassName(ClassDoc cd, boolean qual) {
-        String name = (qual)? cd.qualifiedName(): cd.name();
-        return (cd.isInterface())?  italicsText(name): name;
+    public Content italicsClassName(ClassDoc cd, boolean qual) {
+        Content name = new StringContent((qual)? cd.qualifiedName(): cd.name());
+        return (cd.isInterface())?  HtmlTree.I(name): name;
     }
 
     /**
@@ -1109,11 +1062,9 @@
      *
      * @return the link for the given class.
      */
-    public String getLink(LinkInfoImpl linkInfo) {
+    public Content getLink(LinkInfoImpl linkInfo) {
         LinkFactoryImpl factory = new LinkFactoryImpl(this);
-        String link = factory.getLinkOutput(linkInfo).toString();
-        displayLength += linkInfo.displayLength;
-        return link;
+        return factory.getLink(linkInfo);
     }
 
     /**
@@ -1122,9 +1073,9 @@
      * @param linkInfo the information about the link.
      * @return the type for the given class.
      */
-    public String getTypeParameterLinks(LinkInfoImpl linkInfo) {
+    public Content getTypeParameterLinks(LinkInfoImpl linkInfo) {
         LinkFactoryImpl factory = new LinkFactoryImpl(this);
-        return factory.getTypeParameterLinks(linkInfo, false).toString();
+        return factory.getTypeParameterLinks(linkInfo, false);
     }
 
     /*************************************************************
@@ -1141,8 +1092,8 @@
      * @param style the style of the link.
      * @param code true if the label should be code font.
      */
-    public String getCrossClassLink(String qualifiedClassName, String refMemName,
-                                    String label, boolean strong, String style,
+    public Content getCrossClassLink(String qualifiedClassName, String refMemName,
+                                    Content label, boolean strong, String style,
                                     boolean code) {
         String className = "";
         String packageName = qualifiedClassName == null ? "" : qualifiedClassName;
@@ -1150,7 +1101,9 @@
         while ((periodIndex = packageName.lastIndexOf('.')) != -1) {
             className = packageName.substring(periodIndex + 1, packageName.length()) +
                 (className.length() > 0 ? "." + className : "");
-            String defaultLabel = code ? codeText(className) : className;
+            Content defaultLabel = new StringContent(className);
+            if (code)
+                defaultLabel = HtmlTree.CODE(defaultLabel);
             packageName = packageName.substring(0, periodIndex);
             if (getCrossPackageLink(packageName) != null) {
                 //The package exists in external documentation, so link to the external
@@ -1160,10 +1113,8 @@
                 //have to assume that it does.
                 DocLink link = configuration.extern.getExternalLink(packageName, pathToRoot,
                                 className + ".html", refMemName);
-                return getHyperLinkString(link,
-                    (label == null) || label.length() == 0 ? defaultLabel : label,
-
-
+                return getHyperLink(link,
+                    (label == null) || label.isEmpty() ? defaultLabel : label,
                     strong, style,
                     configuration.getText("doclet.Href_Class_Or_Interface_Title", packageName),
                     "");
@@ -1191,9 +1142,9 @@
      * @param cd the class doc to link to
      * @return a content tree for the link
      */
-    public Content getQualifiedClassLink(int context, ClassDoc cd) {
-        return new RawHtml(getLink(new LinkInfoImpl(configuration, context, cd,
-                configuration.getClassName(cd), "")));
+    public Content getQualifiedClassLink(LinkInfoImpl.Kind context, ClassDoc cd) {
+        return getLink(new LinkInfoImpl(configuration, context, cd)
+                .label(configuration.getClassName(cd)));
     }
 
     /**
@@ -1203,7 +1154,7 @@
      * @param cd the class doc to link to
      * @param contentTree the content tree to which the link will be added
      */
-    public void addPreQualifiedClassLink(int context, ClassDoc cd, Content contentTree) {
+    public void addPreQualifiedClassLink(LinkInfoImpl.Kind context, ClassDoc cd, Content contentTree) {
         addPreQualifiedClassLink(context, cd, false, contentTree);
     }
 
@@ -1216,15 +1167,15 @@
      * @param isStrong true if the link should be strong.
      * @return the link with the package portion of the label in plain text.
      */
-    public String getPreQualifiedClassLink(int context,
+    public Content getPreQualifiedClassLink(LinkInfoImpl.Kind context,
             ClassDoc cd, boolean isStrong) {
-        String classlink = "";
+        ContentBuilder classlink = new ContentBuilder();
         PackageDoc pd = cd.containingPackage();
-        if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
-            classlink = getPkgName(cd);
+        if (pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
+            classlink.addContent(getPkgName(cd));
         }
-        classlink += getLink(new LinkInfoImpl(configuration,
-                context, cd, cd.name(), isStrong));
+        classlink.addContent(getLink(new LinkInfoImpl(configuration,
+                context, cd).label(cd.name()).strong(isStrong)));
         return classlink;
     }
 
@@ -1238,14 +1189,14 @@
      * @param isStrong true if the link should be strong
      * @param contentTree the content tree to which the link with be added
      */
-    public void addPreQualifiedClassLink(int context,
+    public void addPreQualifiedClassLink(LinkInfoImpl.Kind context,
             ClassDoc cd, boolean isStrong, Content contentTree) {
         PackageDoc pd = cd.containingPackage();
         if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
             contentTree.addContent(getPkgName(cd));
         }
-        contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration,
-                context, cd, cd.name(), isStrong))));
+        contentTree.addContent(getLink(new LinkInfoImpl(configuration,
+                context, cd).label(cd.name()).strong(isStrong)));
     }
 
     /**
@@ -1256,7 +1207,7 @@
      * @param cd the class to link to
      * @param contentTree the content tree to which the link with be added
      */
-    public void addPreQualifiedStrongClassLink(int context, ClassDoc cd, Content contentTree) {
+    public void addPreQualifiedStrongClassLink(LinkInfoImpl.Kind context, ClassDoc cd, Content contentTree) {
         addPreQualifiedClassLink(context, cd, true, contentTree);
     }
 
@@ -1268,8 +1219,9 @@
      * @param label the label for the link
      * @return a content tree for the doc link
      */
-    public Content getDocLink(int context, MemberDoc doc, String label) {
-        return getDocLink(context, doc.containingClass(), doc, label);
+    public Content getDocLink(LinkInfoImpl.Kind context, MemberDoc doc, String label) {
+        return getDocLink(context, doc.containingClass(), doc,
+                new StringContent(label));
     }
 
     /**
@@ -1281,8 +1233,8 @@
      * @param strong true if the link should be strong.
      * @return the link for the given member.
      */
-    public String getDocLink(int context, MemberDoc doc, String label,
-                boolean strong) {
+    public Content getDocLink(LinkInfoImpl.Kind context, MemberDoc doc, String label,
+            boolean strong) {
         return getDocLink(context, doc.containingClass(), doc, label, strong);
     }
 
@@ -1298,8 +1250,12 @@
      * @param strong true if the link should be strong.
      * @return the link for the given member.
      */
-    public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
-        String label, boolean strong) {
+    public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
+            String label, boolean strong) {
+        return getDocLink(context, classDoc, doc, label, strong, false);
+    }
+    public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
+            Content label, boolean strong) {
         return getDocLink(context, classDoc, doc, label, strong, false);
     }
 
@@ -1316,18 +1272,28 @@
      * @param isProperty true if the doc parameter is a JavaFX property.
      * @return the link for the given member.
      */
-    public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
-        String label, boolean strong, boolean isProperty) {
+    public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
+            String label, boolean strong, boolean isProperty) {
+        return getDocLink(context, classDoc, doc, new StringContent(check(label)), strong, isProperty);
+    }
+
+    String check(String s) {
+        if (s.matches(".*[&<>].*"))throw new IllegalArgumentException(s);
+        return s;
+    }
+
+    public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
+            Content label, boolean strong, boolean isProperty) {
         if (! (doc.isIncluded() ||
             Util.isLinkable(classDoc, configuration))) {
             return label;
         } else if (doc instanceof ExecutableMemberDoc) {
             ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
-            return getLink(new LinkInfoImpl(configuration, context, classDoc,
-                getAnchor(emd, isProperty), label, strong));
+            return getLink(new LinkInfoImpl(configuration, context, classDoc)
+                .label(label).where(getAnchor(emd, isProperty)).strong(strong));
         } else if (doc instanceof MemberDoc) {
-            return getLink(new LinkInfoImpl(configuration, context, classDoc,
-                doc.name(), label, strong));
+            return getLink(new LinkInfoImpl(configuration, context, classDoc)
+                .label(label).where(doc.name()).strong(strong));
         } else {
             return label;
         }
@@ -1344,20 +1310,20 @@
      * @param label the label for the link
      * @return the link for the given member
      */
-    public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
-        String label) {
+    public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
+            Content label) {
         if (! (doc.isIncluded() ||
             Util.isLinkable(classDoc, configuration))) {
-            return new StringContent(label);
+            return label;
         } else if (doc instanceof ExecutableMemberDoc) {
-            ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
-            return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc,
-                getAnchor(emd), label, false)));
+            ExecutableMemberDoc emd = (ExecutableMemberDoc) doc;
+            return getLink(new LinkInfoImpl(configuration, context, classDoc)
+                .label(label).where(getAnchor(emd)));
         } else if (doc instanceof MemberDoc) {
-            return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc,
-                doc.name(), label, false)));
+            return getLink(new LinkInfoImpl(configuration, context, classDoc)
+                .label(label).where(doc.name()));
         } else {
-            return new StringContent(label);
+            return label;
         }
     }
 
@@ -1385,24 +1351,24 @@
         return emd.name() + signatureParsed.toString();
     }
 
-    public String seeTagToString(SeeTag see) {
+    public Content seeTagToContent(SeeTag see) {
         String tagName = see.name();
         if (! (tagName.startsWith("@link") || tagName.equals("@see"))) {
-            return "";
+            return new ContentBuilder();
         }
 
         String seetext = replaceDocRootDir(see.text());
 
         //Check if @see is an href or "string"
         if (seetext.startsWith("<") || seetext.startsWith("\"")) {
-            return seetext;
+            return new RawHtml(seetext);
         }
 
         boolean plain = tagName.equalsIgnoreCase("@linkplain");
-        String label = plainOrCodeText(plain, see.label());
+        Content label = plainOrCode(plain, new RawHtml(see.label()));
 
         //The text from the @see tag.  We will output this text when a label is not specified.
-        String text = plainOrCodeText(plain, seetext);
+        Content text = plainOrCode(plain, new RawHtml(seetext));
 
         ClassDoc refClass = see.referencedClass();
         String refClassName = see.referencedClassName();
@@ -1415,16 +1381,16 @@
             if (refPackage != null && refPackage.isIncluded()) {
                 //@see is referencing an included package
                 if (label.isEmpty())
-                    label = plainOrCodeText(plain, refPackage.name());
-                return getPackageLinkString(refPackage, label, false);
+                    label = plainOrCode(plain, new StringContent(refPackage.name()));
+                return getPackageLink(refPackage, label);
             } else {
                 //@see is not referencing an included class or package.  Check for cross links.
-                String classCrossLink;
+                Content classCrossLink;
                 DocLink packageCrossLink = getCrossPackageLink(refClassName);
                 if (packageCrossLink != null) {
                     //Package cross link found
-                    return getHyperLinkString(packageCrossLink,
-                        (label.isEmpty() ? text : label), false);
+                    return getHyperLink(packageCrossLink,
+                        (label.isEmpty() ? text : label));
                 } else if ((classCrossLink = getCrossClassLink(refClassName,
                         refMemName, label, false, "", !plain)) != null) {
                     //Class cross link found (possibly to a member in the class)
@@ -1439,9 +1405,10 @@
         } else if (refMemName == null) {
             // Must be a class reference since refClass is not null and refMemName is null.
             if (label.isEmpty()) {
-                label = plainOrCodeText(plain, refClass.name());
+                label = plainOrCode(plain, new StringContent(refClass.name()));
             }
-            return getLink(new LinkInfoImpl(configuration, refClass, label));
+            return getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, refClass)
+                    .label(label));
         } else if (refMem == null) {
             // Must be a member reference since refClass is not null and refMemName is not null.
             // However, refMem is null, so this referenced member does not exist.
@@ -1478,15 +1445,15 @@
                 }
             }
 
-            text = plainOrCodeText(plain, Util.escapeHtmlChars(refMemName));
+            text = plainOrCode(plain, new StringContent(refMemName));
 
-            return getDocLink(LinkInfoImpl.CONTEXT_SEE_TAG, containing,
+            return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing,
                 refMem, (label.isEmpty() ? text: label), false);
         }
     }
 
-    private String plainOrCodeText(boolean plain, String text) {
-        return (plain || text.isEmpty()) ? text : codeText(text);
+    private Content plainOrCode(boolean plain, Content body) {
+        return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body);
     }
 
     /**
@@ -1497,7 +1464,7 @@
      * @param htmltree the content tree to which the comment will be added
      */
     public void addInlineComment(Doc doc, Tag tag, Content htmltree) {
-        addCommentTags(doc, tag.inlineTags(), false, false, htmltree);
+        addCommentTags(doc, tag, tag.inlineTags(), false, false, htmltree);
     }
 
     /**
@@ -1557,11 +1524,26 @@
      */
     private void addCommentTags(Doc doc, Tag[] tags, boolean depr,
             boolean first, Content htmltree) {
+        addCommentTags(doc, null, tags, depr, first, htmltree);
+    }
+
+    /**
+     * Adds the comment tags.
+     *
+     * @param doc the doc for which the comment tags will be generated
+     * @param holderTag the block tag context for the inline tags
+     * @param tags the first sentence tags for the doc
+     * @param depr true if it is deprecated
+     * @param first true if the first sentence tags should be added
+     * @param htmltree the documentation tree to which the comment tags will be added
+     */
+    private void addCommentTags(Doc doc, Tag holderTag, Tag[] tags, boolean depr,
+            boolean first, Content htmltree) {
         if(configuration.nocomment){
             return;
         }
         Content div;
-        Content result = new RawHtml(commentTagsToString(null, doc, tags, first));
+        Content result = commentTagsToContent(null, doc, tags, first);
         if (depr) {
             Content italic = HtmlTree.I(result);
             div = HtmlTree.DIV(HtmlStyle.block, italic);
@@ -1588,9 +1570,9 @@
      *               present in the text of interest for this doc
      * @param isFirstSentence  true if text is first sentence
      */
-    public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags,
+    public Content commentTagsToContent(Tag holderTag, Doc doc, Tag[] tags,
             boolean isFirstSentence) {
-        StringBuilder result = new StringBuilder();
+        Content result = new ContentBuilder();
         boolean textTagChange = false;
         // Array of all possible inline tags for this javadoc run
         configuration.tagletManager.checkTags(doc, tags, true);
@@ -1598,14 +1580,15 @@
             Tag tagelem = tags[i];
             String tagName = tagelem.name();
             if (tagelem instanceof SeeTag) {
-                result.append(seeTagToString((SeeTag)tagelem));
+                result.addContent(seeTagToContent((SeeTag) tagelem));
             } else if (! tagName.equals("Text")) {
-                int originalLength = result.length();
-                TagletOutput output = TagletWriter.getInlineTagOuput(
+                boolean wasEmpty = result.isEmpty();
+                Content output = TagletWriter.getInlineTagOuput(
                     configuration.tagletManager, holderTag,
                     tagelem, getTagletWriterInstance(isFirstSentence));
-                result.append(output == null ? "" : output.toString());
-                if (originalLength == 0 && isFirstSentence && tagelem.name().equals("@inheritDoc") && result.length() > 0) {
+                if (output != null)
+                    result.addContent(output);
+                if (wasEmpty && isFirstSentence && tagelem.name().equals("@inheritDoc") && !result.isEmpty()) {
                     break;
                 } else if (configuration.docrootparent.length() > 0 &&
                         tagelem.name().equals("@docRoot") &&
@@ -1637,17 +1620,11 @@
                 if (isFirstSentence) {
                     text = removeNonInlineHtmlTags(text);
                 }
-                StringTokenizer lines = new StringTokenizer(text, "\r\n", true);
-                StringBuilder textBuff = new StringBuilder();
-                while (lines.hasMoreTokens()) {
-                    StringBuilder line = new StringBuilder(lines.nextToken());
-                    Util.replaceTabs(configuration, line);
-                    textBuff.append(line.toString());
-                }
-                result.append(textBuff);
+                text = Util.replaceTabs(configuration, text);
+                result.addContent(new RawHtml(text));
             }
         }
-        return result.toString();
+        return result;
     }
 
     /**
@@ -1749,60 +1726,55 @@
         return text;
     }
 
-    public String removeNonInlineHtmlTags(String text) {
-        if (text.indexOf('<') < 0) {
+    static final Set<String> blockTags = new HashSet<String>();
+    static {
+        for (HtmlTag t: HtmlTag.values()) {
+            if (t.blockType == HtmlTag.BlockType.BLOCK)
+                blockTags.add(t.value);
+        }
+    }
+
+    public static String removeNonInlineHtmlTags(String text) {
+        final int len = text.length();
+
+        int startPos = 0;                     // start of text to copy
+        int lessThanPos = text.indexOf('<');  // position of latest '<'
+        if (lessThanPos < 0) {
             return text;
         }
-        String noninlinetags[] = { "<ul>", "</ul>", "<ol>", "</ol>",
-                "<dl>", "</dl>", "<table>", "</table>",
-                "<tr>", "</tr>", "<td>", "</td>",
-                "<th>", "</th>", "<p>", "</p>",
-                "<li>", "</li>", "<dd>", "</dd>",
-                "<dir>", "</dir>", "<dt>", "</dt>",
-                "<h1>", "</h1>", "<h2>", "</h2>",
-                "<h3>", "</h3>", "<h4>", "</h4>",
-                "<h5>", "</h5>", "<h6>", "</h6>",
-                "<pre>", "</pre>", "<menu>", "</menu>",
-                "<listing>", "</listing>", "<hr>",
-                "<blockquote>", "</blockquote>",
-                "<center>", "</center>",
-                "<UL>", "</UL>", "<OL>", "</OL>",
-                "<DL>", "</DL>", "<TABLE>", "</TABLE>",
-                "<TR>", "</TR>", "<TD>", "</TD>",
-                "<TH>", "</TH>", "<P>", "</P>",
-                "<LI>", "</LI>", "<DD>", "</DD>",
-                "<DIR>", "</DIR>", "<DT>", "</DT>",
-                "<H1>", "</H1>", "<H2>", "</H2>",
-                "<H3>", "</H3>", "<H4>", "</H4>",
-                "<H5>", "</H5>", "<H6>", "</H6>",
-                "<PRE>", "</PRE>", "<MENU>", "</MENU>",
-                "<LISTING>", "</LISTING>", "<HR>",
-                "<BLOCKQUOTE>", "</BLOCKQUOTE>",
-                "<CENTER>", "</CENTER>"
-        };
-        for (int i = 0; i < noninlinetags.length; i++) {
-            text = replace(text, noninlinetags[i], "");
+
+        StringBuilder result = new StringBuilder();
+    main: while (lessThanPos != -1) {
+            int currPos = lessThanPos + 1;
+            if (currPos == len)
+                break;
+            char ch = text.charAt(currPos);
+            if (ch == '/') {
+                if (++currPos == len)
+                    break;
+                ch = text.charAt(currPos);
+            }
+            int tagPos = currPos;
+            while (isHtmlTagLetterOrDigit(ch)) {
+                if (++currPos == len)
+                    break main;
+                ch = text.charAt(currPos);
+            }
+            if (ch == '>' && blockTags.contains(text.substring(tagPos, currPos).toLowerCase())) {
+                result.append(text, startPos, lessThanPos);
+                startPos = currPos + 1;
+            }
+            lessThanPos = text.indexOf('<', currPos);
         }
-        return text;
+        result.append(text.substring(startPos));
+
+        return result.toString();
     }
 
-    public String replace(String text, String tobe, String by) {
-        while (true) {
-            int startindex = text.indexOf(tobe);
-            if (startindex < 0) {
-                return text;
-            }
-            int endindex = startindex + tobe.length();
-            StringBuilder replaced = new StringBuilder();
-            if (startindex > 0) {
-                replaced.append(text.substring(0, startindex));
-            }
-            replaced.append(by);
-            if (text.length() > endindex) {
-                replaced.append(text.substring(endindex));
-            }
-            text = replaced.toString();
-        }
+    private static boolean isHtmlTagLetterOrDigit(char ch) {
+        return ('a' <= ch && ch <= 'z') ||
+                ('A' <= ch && ch <= 'Z') ||
+                ('1' <= ch && ch <= '6');
     }
 
     /**
@@ -1906,7 +1878,7 @@
     }
 
     /**
-     * Adds the annotatation types for the given doc.
+     * Adds the annotation types for the given doc.
      *
      * @param indent the number of extra spaces to indent the annotations.
      * @param doc the doc to write annotations for.
@@ -1916,16 +1888,14 @@
      */
     private boolean addAnnotationInfo(int indent, Doc doc,
             AnnotationDesc[] descList, boolean lineBreak, Content htmltree) {
-        List<String> annotations = getAnnotations(indent, descList, lineBreak);
+        List<Content> annotations = getAnnotations(indent, descList, lineBreak);
         String sep ="";
-        if (annotations.size() == 0) {
+        if (annotations.isEmpty()) {
             return false;
         }
-        Content annotationContent;
-        for (Iterator<String> iter = annotations.iterator(); iter.hasNext();) {
+        for (Content annotation: annotations) {
             htmltree.addContent(sep);
-            annotationContent = new RawHtml(iter.next());
-            htmltree.addContent(annotationContent);
+            htmltree.addContent(annotation);
             sep = " ";
         }
         return true;
@@ -1941,7 +1911,7 @@
      * @return an array of strings representing the annotations being
      *         documented.
      */
-    private List<String> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) {
+    private List<Content> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) {
         return getAnnotations(indent, descList, linkBreak, true);
     }
 
@@ -1960,10 +1930,10 @@
      * @return an array of strings representing the annotations being
      *         documented.
      */
-    public List<String> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak,
+    public List<Content> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak,
             boolean isJava5DeclarationLocation) {
-        List<String> results = new ArrayList<String>();
-        StringBuilder annotation;
+        List<Content> results = new ArrayList<Content>();
+        ContentBuilder annotation;
         for (int i = 0; i < descList.length; i++) {
             AnnotationTypeDoc annotationDoc = descList[i].annotationType();
             // If an annotation is not documented, do not add it to the list. If
@@ -1980,10 +1950,10 @@
             if  (Util.isDeclarationAnnotation(annotationDoc, isJava5DeclarationLocation)) {
                 continue;
             }*/
-            annotation = new StringBuilder();
+            annotation = new ContentBuilder();
             isAnnotationDocumented = false;
             LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
-                LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc);
+                LinkInfoImpl.Kind.ANNOTATION, annotationDoc);
             AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues();
             // If the annotation is synthesized, do not print the container.
             if (descList[i].isSynthesized()) {
@@ -1999,8 +1969,8 @@
                     }
                     String sep = "";
                     for (AnnotationValue av : annotationTypeValues) {
-                        annotation.append(sep);
-                        annotation.append(annotationValueToString(av));
+                        annotation.addContent(sep);
+                        annotation.addContent(annotationValueToContent(av));
                         sep = " ";
                     }
                 }
@@ -2016,8 +1986,8 @@
                     annotationTypeValues.addAll(Arrays.asList(annotationArray));
                     String sep = "";
                     for (AnnotationValue av : annotationTypeValues) {
-                        annotation.append(sep);
-                        annotation.append(annotationValueToString(av));
+                        annotation.addContent(sep);
+                        annotation.addContent(annotationValueToContent(av));
                         sep = " ";
                     }
                 }
@@ -2032,8 +2002,8 @@
                 addAnnotations(annotationDoc, linkInfo, annotation, pairs,
                         indent, linkBreak);
             }
-            annotation.append(linkBreak ? DocletConstants.NL : "");
-            results.add(annotation.toString());
+            annotation.addContent(linkBreak ? DocletConstants.NL : "");
+            results.add(annotation);
         }
         return results;
     }
@@ -2049,26 +2019,26 @@
      * @param linkBreak if true, add new line between each member value
      */
     private void addAnnotations(AnnotationTypeDoc annotationDoc, LinkInfoImpl linkInfo,
-            StringBuilder annotation, AnnotationDesc.ElementValuePair[] pairs,
+            ContentBuilder annotation, AnnotationDesc.ElementValuePair[] pairs,
             int indent, boolean linkBreak) {
-        linkInfo.label = "@" + annotationDoc.name();
-        annotation.append(getLink(linkInfo));
+        linkInfo.label = new StringContent("@" + annotationDoc.name());
+        annotation.addContent(getLink(linkInfo));
         if (pairs.length > 0) {
-            annotation.append('(');
+            annotation.addContent("(");
             for (int j = 0; j < pairs.length; j++) {
                 if (j > 0) {
-                    annotation.append(",");
+                    annotation.addContent(",");
                     if (linkBreak) {
-                        annotation.append(DocletConstants.NL);
+                        annotation.addContent(DocletConstants.NL);
                         int spaces = annotationDoc.name().length() + 2;
                         for (int k = 0; k < (spaces + indent); k++) {
-                            annotation.append(' ');
+                            annotation.addContent(" ");
                         }
                     }
                 }
-                annotation.append(getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION,
+                annotation.addContent(getDocLink(LinkInfoImpl.Kind.ANNOTATION,
                         pairs[j].element(), pairs[j].element().name(), false));
-                annotation.append('=');
+                annotation.addContent("=");
                 AnnotationValue annotationValue = pairs[j].value();
                 List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
                 if (annotationValue.value() instanceof AnnotationValue[]) {
@@ -2078,17 +2048,17 @@
                 } else {
                     annotationTypeValues.add(annotationValue);
                 }
-                annotation.append(annotationTypeValues.size() == 1 ? "" : "{");
+                annotation.addContent(annotationTypeValues.size() == 1 ? "" : "{");
                 String sep = "";
                 for (AnnotationValue av : annotationTypeValues) {
-                    annotation.append(sep);
-                    annotation.append(annotationValueToString(av));
+                    annotation.addContent(sep);
+                    annotation.addContent(annotationValueToContent(av));
                     sep = ",";
                 }
-                annotation.append(annotationTypeValues.size() == 1 ? "" : "}");
+                annotation.addContent(annotationTypeValues.size() == 1 ? "" : "}");
                 isContainerDocumented = false;
             }
-            annotation.append(")");
+            annotation.addContent(")");
         }
     }
 
@@ -2123,34 +2093,34 @@
         return false;
     }
 
-    private String annotationValueToString(AnnotationValue annotationValue) {
+    private Content annotationValueToContent(AnnotationValue annotationValue) {
         if (annotationValue.value() instanceof Type) {
             Type type = (Type) annotationValue.value();
             if (type.asClassDoc() != null) {
                 LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
-                    LinkInfoImpl.CONTEXT_ANNOTATION, type);
-                    linkInfo.label = (type.asClassDoc().isIncluded() ?
-                        type.typeName() :
-                        type.qualifiedTypeName()) + type.dimension() + ".class";
+                    LinkInfoImpl.Kind.ANNOTATION, type);
+                linkInfo.label = new StringContent((type.asClassDoc().isIncluded() ?
+                    type.typeName() :
+                    type.qualifiedTypeName()) + type.dimension() + ".class");
                 return getLink(linkInfo);
             } else {
-                return type.typeName() + type.dimension() + ".class";
+                return new StringContent(type.typeName() + type.dimension() + ".class");
             }
         } else if (annotationValue.value() instanceof AnnotationDesc) {
-            List<String> list = getAnnotations(0,
+            List<Content> list = getAnnotations(0,
                 new AnnotationDesc[]{(AnnotationDesc) annotationValue.value()},
                     false);
-            StringBuilder buf = new StringBuilder();
-            for (String s: list) {
-                buf.append(s);
+            ContentBuilder buf = new ContentBuilder();
+            for (Content c: list) {
+                buf.addContent(c);
             }
-            return buf.toString();
+            return buf;
         } else if (annotationValue.value() instanceof MemberDoc) {
-            return getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION,
+            return getDocLink(LinkInfoImpl.Kind.ANNOTATION,
                 (MemberDoc) annotationValue.value(),
                 ((MemberDoc) annotationValue.value()).name(), false);
          } else {
-            return annotationValue.toString();
+            return new StringContent(annotationValue.toString());
          }
     }
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
@@ -46,7 +46,7 @@
  * @author Bhavesh Patel (Modified)
  */
 public class HtmlSerialFieldWriter extends FieldWriterImpl
-    implements SerializedFormWriter.SerialFieldWriter {
+        implements SerializedFormWriter.SerialFieldWriter {
     ProgramElementDoc[] members = null;
 
     private boolean printedOverallAnchor = false;
@@ -129,8 +129,8 @@
         if (fieldType == null) {
             pre.addContent(fieldTypeStr);
         } else {
-            Content fieldContent = new RawHtml(writer.getLink(new LinkInfoImpl(
-                    configuration, LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType)));
+            Content fieldContent = writer.getLink(new LinkInfoImpl(
+                    configuration, LinkInfoImpl.Kind.SERIAL_MEMBER, fieldType));
             pre.addContent(fieldContent);
         }
         pre.addContent(fieldDimensions + " ");
@@ -186,17 +186,13 @@
      * @param contentTree the tree to which the member tags info will be added
      */
     public void addMemberTags(FieldDoc field, Content contentTree) {
-        TagletOutputImpl output = new TagletOutputImpl("");
+        Content tagContent = new ContentBuilder();
         TagletWriter.genTagOuput(configuration.tagletManager, field,
-                configuration.tagletManager.getCustomTags(field),
-                writer.getTagletWriterInstance(false), output);
-        String outputString = output.toString().trim();
+                configuration.tagletManager.getCustomTaglets(field),
+                writer.getTagletWriterInstance(false), tagContent);
         Content dlTags = new HtmlTree(HtmlTag.DL);
-        if (!outputString.isEmpty()) {
-            Content tagContent = new RawHtml(outputString);
-            dlTags.addContent(tagContent);
-        }
-        contentTree.addContent(dlTags);
+        dlTags.addContent(tagContent);
+        contentTree.addContent(dlTags);  // TODO: what if empty?
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
@@ -146,19 +146,15 @@
      * @param methodsContentTree the tree to which the member tags info will be added
      */
     public void addMemberTags(MethodDoc member, Content methodsContentTree) {
-        TagletOutputImpl output = new TagletOutputImpl("");
+        Content tagContent = new ContentBuilder();
         TagletManager tagletManager =
             configuration.tagletManager;
         TagletWriter.genTagOuput(tagletManager, member,
-            tagletManager.getSerializedFormTags(),
-            writer.getTagletWriterInstance(false), output);
-        String outputString = output.toString().trim();
+            tagletManager.getSerializedFormTaglets(),
+            writer.getTagletWriterInstance(false), tagContent);
         Content dlTags = new HtmlTree(HtmlTag.DL);
-        if (!outputString.isEmpty()) {
-            Content tagContent = new RawHtml(outputString);
-            dlTags.addContent(tagContent);
-        }
-        methodsContentTree.addContent(dlTags);
+        dlTags.addContent(tagContent);
+        methodsContentTree.addContent(dlTags);  // TODO: what if empty?
         MethodDoc method = member;
         if (method.name().compareTo("writeExternal") == 0
                 && method.tags("serialData").length == 0) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -28,6 +28,9 @@
 import java.util.List;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.ContentBuilder;
+import com.sun.tools.doclets.formats.html.markup.RawHtml;
+import com.sun.tools.doclets.formats.html.markup.StringContent;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.util.links.*;
@@ -54,16 +57,16 @@
     /**
      * {@inheritDoc}
      */
-    protected LinkOutput getOutputInstance() {
-        return new LinkOutputImpl();
+    protected Content newContent() {
+        return new ContentBuilder();
     }
 
     /**
      * {@inheritDoc}
      */
-    protected LinkOutput getClassLink(LinkInfo linkInfo) {
+    protected Content getClassLink(LinkInfo linkInfo) {
         LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
-        boolean noLabel = linkInfo.label == null || linkInfo.label.length() == 0;
+        boolean noLabel = linkInfo.label == null || linkInfo.label.isEmpty();
         ClassDoc classDoc = classLinkInfo.classDoc;
         //Create a tool tip if we are linking to a class or interface.  Don't
         //create one if we are linking to a member.
@@ -73,100 +76,94 @@
                     classLinkInfo.type != null &&
                     !classDoc.qualifiedTypeName().equals(classLinkInfo.type.qualifiedTypeName())) :
             "";
-        StringBuilder label = new StringBuilder(
-            classLinkInfo.getClassLinkLabel(m_writer.configuration));
-        classLinkInfo.displayLength += label.length();
+        Content label = classLinkInfo.getClassLinkLabel(m_writer.configuration);
         Configuration configuration = m_writer.configuration;
-        LinkOutputImpl linkOutput = new LinkOutputImpl();
+        Content link = new ContentBuilder();
         if (classDoc.isIncluded()) {
             if (configuration.isGeneratedDoc(classDoc)) {
                 DocPath filename = getPath(classLinkInfo);
                 if (linkInfo.linkToSelf ||
                                 !(DocPath.forName(classDoc)).equals(m_writer.filename)) {
-                        linkOutput.append(m_writer.getHyperLinkString(
+                        link.addContent(m_writer.getHyperLink(
                                 filename.fragment(classLinkInfo.where),
-                            label.toString(),
+                            label,
                             classLinkInfo.isStrong, classLinkInfo.styleName,
                             title, classLinkInfo.target));
                         if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
-                            linkOutput.append(getTypeParameterLinks(linkInfo).toString());
+                            link.addContent(getTypeParameterLinks(linkInfo));
                         }
-                        return linkOutput;
+                        return link;
                 }
             }
         } else {
-            String crossLink = m_writer.getCrossClassLink(
+            Content crossLink = m_writer.getCrossClassLink(
                 classDoc.qualifiedName(), classLinkInfo.where,
-                label.toString(), classLinkInfo.isStrong, classLinkInfo.styleName,
+                label, classLinkInfo.isStrong, classLinkInfo.styleName,
                 true);
             if (crossLink != null) {
-                linkOutput.append(crossLink);
+                link.addContent(crossLink);
                 if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
-                    linkOutput.append(getTypeParameterLinks(linkInfo).toString());
+                    link.addContent(getTypeParameterLinks(linkInfo));
                 }
-                return linkOutput;
+                return link;
             }
         }
         // Can't link so just write label.
-        linkOutput.append(label.toString());
+        link.addContent(label.toString());
         if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
-            linkOutput.append(getTypeParameterLinks(linkInfo).toString());
+            link.addContent(getTypeParameterLinks(linkInfo));
         }
-        return linkOutput;
+        return link;
     }
 
     /**
      * {@inheritDoc}
      */
-    protected LinkOutput getTypeParameterLink(LinkInfo linkInfo,
+    protected Content getTypeParameterLink(LinkInfo linkInfo,
         Type typeParam) {
         LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration,
-                linkInfo.getContext(), typeParam);
+                ((LinkInfoImpl) linkInfo).getContext(), typeParam);
         typeLinkInfo.excludeTypeBounds = linkInfo.excludeTypeBounds;
         typeLinkInfo.excludeTypeParameterLinks = linkInfo.excludeTypeParameterLinks;
         typeLinkInfo.linkToSelf = linkInfo.linkToSelf;
         typeLinkInfo.isJava5DeclarationLocation = false;
-        LinkOutput output = getLinkOutput(typeLinkInfo);
-        ((LinkInfoImpl) linkInfo).displayLength += typeLinkInfo.displayLength;
-        return output;
+        return getLink(typeLinkInfo);
     }
 
-    protected LinkOutput getTypeAnnotationLink(LinkInfo linkInfo,
+    protected Content getTypeAnnotationLink(LinkInfo linkInfo,
             AnnotationDesc annotation) {
         throw new RuntimeException("Not implemented yet!");
     }
 
-    public LinkOutput getTypeAnnotationLinks(LinkInfo linkInfo) {
-        LinkOutput output = getOutputInstance();
+    public Content getTypeAnnotationLinks(LinkInfo linkInfo) {
+        ContentBuilder links = new ContentBuilder();
         AnnotationDesc[] annotations;
         if (linkInfo.type instanceof AnnotatedType) {
             annotations = linkInfo.type.asAnnotatedType().annotations();
         } else if (linkInfo.type instanceof TypeVariable) {
             annotations = linkInfo.type.asTypeVariable().annotations();
         } else {
-            return output;
+            return links;
         }
 
         if (annotations.length == 0)
-            return output;
+            return links;
 
-        List<String> annos = m_writer.getAnnotations(0, annotations, false, linkInfo.isJava5DeclarationLocation);
+        List<Content> annos = m_writer.getAnnotations(0, annotations, false, linkInfo.isJava5DeclarationLocation);
 
         boolean isFirst = true;
-        for (String anno : annos) {
+        for (Content anno : annos) {
             if (!isFirst) {
-                linkInfo.displayLength += 1;
-                output.append(" ");
+                links.addContent(" ");
             }
-            output.append(anno);
+            links.addContent(anno);
             isFirst = false;
         }
         if (!annos.isEmpty()) {
-            linkInfo.displayLength += 1;
-            output.append(" ");
+            links.addContent(" ");
         }
 
-        return output;
+        return links;
     }
 
     /**
@@ -204,7 +201,7 @@
      * @param linkInfo the information about the link.
      */
     private DocPath getPath(LinkInfoImpl linkInfo) {
-        if (linkInfo.context == LinkInfoImpl.PACKAGE_FRAME) {
+        if (linkInfo.context == LinkInfoImpl.Kind.PACKAGE_FRAME) {
             //Not really necessary to do this but we want to be consistent
             //with 1.4.2 output.
             return DocPath.forName(linkInfo.classDoc);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -27,6 +27,9 @@
 package com.sun.tools.doclets.formats.html;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.ContentBuilder;
+import com.sun.tools.doclets.formats.html.markup.StringContent;
+import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.util.links.*;
 
@@ -38,177 +41,181 @@
  */
 public class LinkInfoImpl extends LinkInfo {
 
-    /**
-     * Indicate that the link appears in a class list.
-     */
-    public static final int ALL_CLASSES_FRAME = 1;
+    public enum Kind {
+        DEFAULT,
 
-    /**
-     * Indicate that the link appears in a class documentation.
-     */
-    public static final int CONTEXT_CLASS = 2;
+        /**
+         * Indicate that the link appears in a class list.
+         */
+        ALL_CLASSES_FRAME,
 
-    /**
-     * Indicate that the link appears in member documentation.
-     */
-    public static final int CONTEXT_MEMBER = 3;
+        /**
+         * Indicate that the link appears in a class documentation.
+         */
+        CLASS,
 
-    /**
-     * Indicate that the link appears in class use documentation.
-     */
-    public static final int CONTEXT_CLASS_USE = 4;
+        /**
+         * Indicate that the link appears in member documentation.
+         */
+        MEMBER,
 
-    /**
-     * Indicate that the link appears in index documentation.
-     */
-    public static final int CONTEXT_INDEX = 5;
+        /**
+         * Indicate that the link appears in class use documentation.
+         */
+        CLASS_USE,
 
-    /**
-     * Indicate that the link appears in constant value summary.
-     */
-    public static final int CONTEXT_CONSTANT_SUMMARY = 6;
+        /**
+         * Indicate that the link appears in index documentation.
+         */
+        INDEX,
 
-    /**
-     * Indicate that the link appears in serialized form documentation.
-     */
-    public static final int CONTEXT_SERIALIZED_FORM = 7;
+        /**
+         * Indicate that the link appears in constant value summary.
+         */
+        CONSTANT_SUMMARY,
 
-    /**
-     * Indicate that the link appears in serial member documentation.
-     */
-    public static final int CONTEXT_SERIAL_MEMBER = 8;
+        /**
+         * Indicate that the link appears in serialized form documentation.
+         */
+        SERIALIZED_FORM,
 
-    /**
-     * Indicate that the link appears in package documentation.
-     */
-    public static final int CONTEXT_PACKAGE = 9;
+        /**
+         * Indicate that the link appears in serial member documentation.
+         */
+        SERIAL_MEMBER,
 
-    /**
-     * Indicate that the link appears in see tag documentation.
-     */
-    public static final int CONTEXT_SEE_TAG = 10;
+        /**
+         * Indicate that the link appears in package documentation.
+         */
+        PACKAGE,
 
-    /**
-     * Indicate that the link appears in value tag documentation.
-     */
-    public static final int CONTEXT_VALUE_TAG = 11;
+        /**
+         * Indicate that the link appears in see tag documentation.
+         */
+        SEE_TAG,
 
-    /**
-     * Indicate that the link appears in tree documentation.
-     */
-    public static final int CONTEXT_TREE = 12;
+        /**
+         * Indicate that the link appears in value tag documentation.
+         */
+        VALUE_TAG,
 
-    /**
-     * Indicate that the link appears in a class list.
-     */
-    public static final int PACKAGE_FRAME = 13;
+        /**
+         * Indicate that the link appears in tree documentation.
+         */
+        TREE,
 
-    /**
-     * The header in the class documentation.
-     */
-    public static final int CONTEXT_CLASS_HEADER = 14;
+        /**
+         * Indicate that the link appears in a class list.
+         */
+        PACKAGE_FRAME,
 
-    /**
-     * The signature in the class documentation.
-     */
-    public static final int CONTEXT_CLASS_SIGNATURE = 15;
+        /**
+         * The header in the class documentation.
+         */
+        CLASS_HEADER,
 
-    /**
-     * The return type of a method.
-     */
-    public static final int CONTEXT_RETURN_TYPE = 16;
+        /**
+         * The signature in the class documentation.
+         */
+        CLASS_SIGNATURE,
+
+        /**
+         * The return type of a method.
+         */
+        RETURN_TYPE,
 
-    /**
-     * The return type of a method in a member summary.
-     */
-    public static final int CONTEXT_SUMMARY_RETURN_TYPE = 17;
+        /**
+         * The return type of a method in a member summary.
+         */
+        SUMMARY_RETURN_TYPE,
 
-    /**
-     * The type of a method/constructor parameter.
-     */
-    public static final int CONTEXT_EXECUTABLE_MEMBER_PARAM = 18;
+        /**
+         * The type of a method/constructor parameter.
+         */
+        EXECUTABLE_MEMBER_PARAM,
 
-    /**
-     * Super interface links.
-     */
-    public static final int CONTEXT_SUPER_INTERFACES = 19;
+        /**
+         * Super interface links.
+         */
+        SUPER_INTERFACES,
 
-    /**
-     * Implemented interface links.
-     */
-    public static final int CONTEXT_IMPLEMENTED_INTERFACES = 20;
+        /**
+         * Implemented interface links.
+         */
+        IMPLEMENTED_INTERFACES,
 
-    /**
-     * Implemented class links.
-     */
-    public static final int CONTEXT_IMPLEMENTED_CLASSES = 21;
+        /**
+         * Implemented class links.
+         */
+        IMPLEMENTED_CLASSES,
 
-    /**
-     * Subinterface links.
-     */
-    public static final int CONTEXT_SUBINTERFACES = 22;
+        /**
+         * Subinterface links.
+         */
+        SUBINTERFACES,
 
-    /**
-     * Subclasses links.
-     */
-    public static final int CONTEXT_SUBCLASSES = 23;
+        /**
+         * Subclasses links.
+         */
+        SUBCLASSES,
 
-    /**
-     * The signature in the class documentation (implements/extends portion).
-     */
-    public static final int CONTEXT_CLASS_SIGNATURE_PARENT_NAME = 24;
+        /**
+         * The signature in the class documentation (implements/extends portion).
+         */
+        CLASS_SIGNATURE_PARENT_NAME,
 
-    /**
-     * The header for method documentation copied from parent.
-     */
-    public static final int CONTEXT_METHOD_DOC_COPY = 26;
+        /**
+         * The header for method documentation copied from parent.
+         */
+        METHOD_DOC_COPY,
 
-    /**
-     * Method "specified by" link.
-     */
-    public static final int CONTEXT_METHOD_SPECIFIED_BY = 27;
+        /**
+         * Method "specified by" link.
+         */
+        METHOD_SPECIFIED_BY,
 
-    /**
-     * Method "overrides" link.
-     */
-    public static final int CONTEXT_METHOD_OVERRIDES = 28;
+        /**
+         * Method "overrides" link.
+         */
+        METHOD_OVERRIDES,
 
-    /**
-     * Annotation link.
-     */
-    public static final int CONTEXT_ANNOTATION = 29;
+        /**
+         * Annotation link.
+         */
+        ANNOTATION,
 
-    /**
-     * The header for field documentation copied from parent.
-     */
-    public static final int CONTEXT_FIELD_DOC_COPY = 30;
+        /**
+         * The header for field documentation copied from parent.
+         */
+        FIELD_DOC_COPY,
 
-    /**
-     * The parent nodes int the class tree.
-     */
-    public static final int CONTEXT_CLASS_TREE_PARENT = 31;
+        /**
+         * The parent nodes in the class tree.
+         */
+        CLASS_TREE_PARENT,
 
-    /**
-     * The type parameters of a method or constructor.
-     */
-    public static final int CONTEXT_MEMBER_TYPE_PARAMS = 32;
+        /**
+         * The type parameters of a method or constructor.
+         */
+        MEMBER_TYPE_PARAMS,
 
-    /**
-     * Indicate that the link appears in class use documentation.
-     */
-    public static final int CONTEXT_CLASS_USE_HEADER = 33;
+        /**
+         * Indicate that the link appears in class use documentation.
+         */
+        CLASS_USE_HEADER,
 
-    /**
-     * The header for property documentation copied from parent.
-     */
-    public static final int CONTEXT_PROPERTY_DOC_COPY = 34;
+        /**
+         * The header for property documentation copied from parent.
+         */
+        PROPERTY_DOC_COPY
+    }
 
     public final ConfigurationImpl configuration;
 
     /**
-     * The integer indicating the location of the link.
+     * The location of the link.
      */
-    public int context;
+    public Kind context = Kind.DEFAULT;
 
     /**
      * The value of the marker #.
@@ -218,7 +225,7 @@
     /**
      * String style of text defined in style sheet.
      */
-    public String styleName ="";
+    public String styleName = "";
 
     /**
      * The value of the target.
@@ -230,40 +237,21 @@
      *
      * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
-     * @param classDoc   the class to link to.
-     * @param label      the label for the link.
-     * @param target     the value of the target attribute.
+     * @param context               the context of the link.
+     * @param executableMemberDoc   the member to link to.
      */
     public LinkInfoImpl(ConfigurationImpl configuration,
-            int context, ClassDoc classDoc, String label, String target) {
+            Kind context, ExecutableMemberDoc executableMemberDoc) {
         this.configuration = configuration;
-        this.classDoc = classDoc;
-        this.label = label;
-        this.target = target;
+        this.executableMemberDoc = executableMemberDoc;
         setContext(context);
     }
 
     /**
-     * Construct a LinkInfo object.
-     *
-     * @param configuration the configuration data for the doclet
-     * @param context    the context of the link.
-     * @param classDoc   the class to link to.
-     * @param where      the value of the marker #.
-     * @param label      the label for the link.
-     * @param isStrong       true if the link should be strong.
-     * @param styleName  String style of text defined in style sheet.
+     * {@inherotDoc}
      */
-    public LinkInfoImpl(ConfigurationImpl configuration,
-            int context, ClassDoc classDoc, String where, String label,
-            boolean isStrong, String styleName) {
-        this.configuration = configuration;
-        this.classDoc = classDoc;
-        this.where = where;
-        this.label = label;
-        this.isStrong = isStrong;
-        this.styleName = styleName;
-        setContext(context);
+    protected Content newContent() {
+        return new ContentBuilder();
     }
 
     /**
@@ -272,66 +260,11 @@
      * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param classDoc   the class to link to.
-     * @param where      the value of the marker #.
-     * @param label      the label for the link.
-     * @param isStrong       true if the link should be strong.
      */
     public LinkInfoImpl(ConfigurationImpl configuration,
-            int context, ClassDoc classDoc, String where, String label,
-            boolean isStrong) {
-        this.configuration = configuration;
-        this.classDoc = classDoc;
-        this.where = where;
-        this.label = label;
-        this.isStrong = isStrong;
-        setContext(context);
-    }
-
-    /**
-     * Construct a LinkInfo object.
-     *
-     * @param configuration the configuration data for the doclet
-     * @param classDoc   the class to link to.
-     * @param label      the label for the link.
-     */
-    public LinkInfoImpl(ConfigurationImpl configuration,
-            ClassDoc classDoc, String label) {
+            Kind context, ClassDoc classDoc) {
         this.configuration = configuration;
         this.classDoc = classDoc;
-        this.label = label;
-        setContext(context);
-    }
-
-    /**
-     * Construct a LinkInfo object.
-     *
-     * @param configuration the configuration data for the doclet
-     * @param context               the context of the link.
-     * @param executableMemberDoc   the member to link to.
-     * @param isStrong                true if the link should be strong.
-     */
-    public LinkInfoImpl(ConfigurationImpl configuration,
-            int context, ExecutableMemberDoc executableMemberDoc,
-            boolean isStrong) {
-        this.configuration = configuration;
-        this.executableMemberDoc = executableMemberDoc;
-        this.isStrong = isStrong;
-        setContext(context);
-    }
-
-    /**
-     * Construct a LinkInfo object.
-     *
-     * @param configuration the configuration data for the doclet
-     * @param context    the context of the link.
-     * @param classDoc   the class to link to.
-     * @param isStrong       true if the link should be strong.
-     */
-    public LinkInfoImpl(ConfigurationImpl configuration,
-            int context, ClassDoc classDoc,  boolean isStrong) {
-        this.configuration = configuration;
-        this.classDoc = classDoc;
-        this.isStrong = isStrong;
         setContext(context);
     }
 
@@ -343,70 +276,76 @@
      * @param type       the class to link to.
      */
     public LinkInfoImpl(ConfigurationImpl configuration,
-            int context, Type type) {
+            Kind context, Type type) {
         this.configuration = configuration;
         this.type = type;
         setContext(context);
     }
 
+
     /**
-     * Construct a LinkInfo object.
-     *
-     * @param configuration the configuration data for the doclet
-     * @param context    the context of the link.
-     * @param type       the class to link to.
-     * @param isVarArg   true if this is a link to a var arg.
+     * Set the label for the link.
+     * @param label plain-text label for the link
+     */
+    public LinkInfoImpl label(String label) {
+        this.label = new StringContent(label);
+        return this;
+    }
+
+    /**
+     * Set the label for the link.
      */
-    public LinkInfoImpl(ConfigurationImpl configuration,
-            int context, Type type, boolean isVarArg) {
-        this.configuration = configuration;
-        this.type = type;
-        this.isVarArg = isVarArg;
-        setContext(context);
+    public LinkInfoImpl label(Content label) {
+        this.label = label;
+        return this;
+    }
+
+    /**
+     * Set whether or not the link should be strong.
+     */
+    public LinkInfoImpl strong(boolean strong) {
+        this.isStrong = strong;
+        return this;
     }
 
     /**
-     * Construct a LinkInfo object.
-     *
-     * @param configuration the configuration data for the doclet
-     * @param context    the context of the link.
-     * @param type       the class to link to.
-     * @param label      the label for the link.
-     * @param isStrong     true if the link should be strong.
+     * Set the style to be used for the link.
+     * @param styleName  String style of text defined in style sheet.
      */
-    public LinkInfoImpl(ConfigurationImpl configuration,
-            int context, Type type, String label,
-            boolean isStrong) {
-        this.configuration = configuration;
-        this.type = type;
-        this.label = label;
-        this.isStrong = isStrong;
-        setContext(context);
+    public LinkInfoImpl styleName(String styleName) {
+        this.styleName = styleName;
+        return this;
     }
 
     /**
-     * Construct a LinkInfo object.
-     *
-     * @param configuration the configuration data for the doclet
-     * @param context    the context of the link.
-     * @param classDoc   the class to link to.
-     * @param label      the label for the link.
-     * @param isStrong       true if the link should be strong.
+     * Set the target to be used for the link.
+     * @param styleName  String style of text defined in style sheet.
+     */
+    public LinkInfoImpl target(String target) {
+        this.target = target;
+        return this;
+    }
+
+    /**
+     * Set whether or not this is a link to a varargs parameter.
      */
-    public LinkInfoImpl(ConfigurationImpl configuration,
-            int context, ClassDoc classDoc, String label,
-            boolean isStrong) {
-        this.configuration = configuration;
-        this.classDoc = classDoc;
-        this.label = label;
-        this.isStrong = isStrong;
-        setContext(context);
+    public LinkInfoImpl varargs(boolean varargs) {
+        this.isVarArg = varargs;
+        return this;
     }
 
     /**
+     * Set the fragment specifier for the link.
+     */
+    public LinkInfoImpl where(String where) {
+        this.where = where;
+        return this;
+     }
+
+    /**
      * {@inheritDoc}
      */
-    public int getContext() {
+    public Kind getContext() {
         return context;
     }
 
@@ -418,63 +357,63 @@
      *
      * @param c the context id to set.
      */
-    public void setContext(int c) {
+    public final void setContext(Kind c) {
         //NOTE:  Put context specific link code here.
         switch (c) {
             case ALL_CLASSES_FRAME:
             case PACKAGE_FRAME:
-            case CONTEXT_IMPLEMENTED_CLASSES:
-            case CONTEXT_SUBCLASSES:
-            case CONTEXT_METHOD_DOC_COPY:
-            case CONTEXT_FIELD_DOC_COPY:
-            case CONTEXT_PROPERTY_DOC_COPY:
-            case CONTEXT_CLASS_USE_HEADER:
+            case IMPLEMENTED_CLASSES:
+            case SUBCLASSES:
+            case METHOD_DOC_COPY:
+            case FIELD_DOC_COPY:
+            case PROPERTY_DOC_COPY:
+            case CLASS_USE_HEADER:
                 includeTypeInClassLinkLabel = false;
                 break;
 
-            case CONTEXT_ANNOTATION:
+            case ANNOTATION:
                 excludeTypeParameterLinks = true;
                 excludeTypeBounds = true;
                 break;
 
-            case CONTEXT_IMPLEMENTED_INTERFACES:
-            case CONTEXT_SUPER_INTERFACES:
-            case CONTEXT_SUBINTERFACES:
-            case CONTEXT_CLASS_TREE_PARENT:
-            case CONTEXT_TREE:
-            case CONTEXT_CLASS_SIGNATURE_PARENT_NAME:
+            case IMPLEMENTED_INTERFACES:
+            case SUPER_INTERFACES:
+            case SUBINTERFACES:
+            case CLASS_TREE_PARENT:
+            case TREE:
+            case CLASS_SIGNATURE_PARENT_NAME:
                 excludeTypeParameterLinks = true;
                 excludeTypeBounds = true;
                 includeTypeInClassLinkLabel = false;
                 includeTypeAsSepLink = true;
                 break;
 
-            case CONTEXT_PACKAGE:
-            case CONTEXT_CLASS_USE:
-            case CONTEXT_CLASS_HEADER:
-            case CONTEXT_CLASS_SIGNATURE:
+            case PACKAGE:
+            case CLASS_USE:
+            case CLASS_HEADER:
+            case CLASS_SIGNATURE:
                 excludeTypeParameterLinks = true;
                 includeTypeAsSepLink = true;
                 includeTypeInClassLinkLabel = false;
                 break;
 
-            case CONTEXT_MEMBER_TYPE_PARAMS:
+            case MEMBER_TYPE_PARAMS:
                 includeTypeAsSepLink = true;
                 includeTypeInClassLinkLabel = false;
                 break;
 
-            case CONTEXT_RETURN_TYPE:
-            case CONTEXT_SUMMARY_RETURN_TYPE:
+            case RETURN_TYPE:
+            case SUMMARY_RETURN_TYPE:
                 excludeTypeBounds = true;
                 break;
-            case CONTEXT_EXECUTABLE_MEMBER_PARAM:
+            case EXECUTABLE_MEMBER_PARAM:
                 excludeTypeBounds = true;
                 break;
         }
         context = c;
         if (type != null &&
             type.asTypeVariable()!= null &&
-            type.asTypeVariable().owner() instanceof ExecutableMemberDoc){
+            type.asTypeVariable().owner() instanceof ExecutableMemberDoc) {
             excludeTypeParameterLinks = true;
         }
     }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -117,7 +117,6 @@
      * @return a content object for the signature
      */
     public Content getSignature(MethodDoc method) {
-        writer.displayLength = 0;
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(method, pre);
         addModifiers(method, pre);
@@ -129,8 +128,9 @@
         } else {
             addName(method.name(), pre);
         }
-        addParameters(method, pre);
-        addExceptions(method, pre);
+        int indent = pre.charCount();
+        addParameters(method, pre, indent);
+        addExceptions(method, pre, indent);
         return pre;
     }
 
@@ -152,12 +152,12 @@
                     Util.isLinkable(holderClassDoc, configuration)))) {
                 writer.addInlineComment(method, methodDocTree);
             } else {
-                Content link = new RawHtml(
-                        writer.getDocLink(LinkInfoImpl.CONTEXT_METHOD_DOC_COPY,
+                Content link =
+                        writer.getDocLink(LinkInfoImpl.Kind.METHOD_DOC_COPY,
                         holder.asClassDoc(), method,
                         holder.asClassDoc().isIncluded() ?
                             holder.typeName() : holder.qualifiedTypeName(),
-                            false));
+                            false);
                 Content codelLink = HtmlTree.CODE(link);
                 Content strong = HtmlTree.STRONG(holder.asClassDoc().isClass()?
                     writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
@@ -223,8 +223,8 @@
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration.getText("doclet.Methods");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Methods");
     }
 
     /**
@@ -260,8 +260,8 @@
      * {@inheritDoc}
      */
     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
-        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
-                LinkInfoImpl.CONTEXT_MEMBER, cd, false));
+        Content classLink = writer.getPreQualifiedClassLink(
+                LinkInfoImpl.Kind.MEMBER, cd, false);
         Content label = new StringContent(cd.isClass() ?
             configuration.getText("doclet.Methods_Inherited_From_Class") :
             configuration.getText("doclet.Methods_Inherited_From_Interface"));
@@ -300,25 +300,25 @@
             return;
         }
         Content label = writer.overridesLabel;
-        int context = LinkInfoImpl.CONTEXT_METHOD_OVERRIDES;
+        LinkInfoImpl.Kind context = LinkInfoImpl.Kind.METHOD_OVERRIDES;
 
         if (method != null) {
             if (overriddenType.asClassDoc().isAbstract() && method.isAbstract()){
                 //Abstract method is implemented from abstract class,
                 //not overridden
                 label = writer.specifiedByLabel;
-                context = LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY;
+                context = LinkInfoImpl.Kind.METHOD_SPECIFIED_BY;
             }
             Content dt = HtmlTree.DT(HtmlTree.STRONG(label));
             dl.addContent(dt);
-            Content overriddenTypeLink = new RawHtml(
-                    writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType)));
+            Content overriddenTypeLink =
+                    writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType));
             Content codeOverridenTypeLink = HtmlTree.CODE(overriddenTypeLink);
             String name = method.name();
-            Content methlink = new RawHtml(writer.getLink(
-                    new LinkInfoImpl(writer.configuration, LinkInfoImpl.CONTEXT_MEMBER,
-                    overriddenType.asClassDoc(),
-                    writer.getAnchor(method), name, false)));
+            Content methlink = writer.getLink(
+                    new LinkInfoImpl(writer.configuration, LinkInfoImpl.Kind.MEMBER,
+                    overriddenType.asClassDoc())
+                    .where(writer.getAnchor(method)).label(name));
             Content codeMethLink = HtmlTree.CODE(methlink);
             Content dd = HtmlTree.DD(codeMethLink);
             dd.addContent(writer.getSpace());
@@ -361,14 +361,14 @@
         for (int i = 0; i < implementedMethods.length; i++) {
             MethodDoc implementedMeth = implementedMethods[i];
             Type intfac = implementedMethodsFinder.getMethodHolder(implementedMeth);
-            Content intfaclink = new RawHtml(writer.getLink(new LinkInfoImpl(
-                    writer.configuration, LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac)));
+            Content intfaclink = writer.getLink(new LinkInfoImpl(
+                    writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac));
             Content codeIntfacLink = HtmlTree.CODE(intfaclink);
             Content dt = HtmlTree.DT(HtmlTree.STRONG(writer.specifiedByLabel));
             dl.addContent(dt);
-            Content methlink = new RawHtml(writer.getDocLink(
-                    LinkInfoImpl.CONTEXT_MEMBER, implementedMeth,
-                    implementedMeth.name(), false));
+            Content methlink = writer.getDocLink(
+                    LinkInfoImpl.Kind.MEMBER, implementedMeth,
+                    implementedMeth.name(), false);
             Content codeMethLink = HtmlTree.CODE(methlink);
             Content dd = HtmlTree.DD(codeMethLink);
             dd.addContent(writer.getSpace());
@@ -388,8 +388,8 @@
     protected void addReturnType(MethodDoc method, Content htmltree) {
         Type type = method.returnType();
         if (type != null) {
-            Content linkContent = new RawHtml(writer.getLink(
-                    new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_RETURN_TYPE, type)));
+            Content linkContent = writer.getLink(
+                    new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type));
             htmltree.addContent(linkContent);
             htmltree.addContent(writer.getSpace());
         }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
-import java.util.*;
 
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.formats.html.markup.*;
@@ -101,8 +100,8 @@
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration.getText("doclet.Nested_Classes");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Nested_Classes");
     }
 
     /**
@@ -148,8 +147,8 @@
      * {@inheritDoc}
      */
     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
-        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
-                LinkInfoImpl.CONTEXT_MEMBER, cd, false));
+        Content classLink = writer.getPreQualifiedClassLink(
+                LinkInfoImpl.Kind.MEMBER, cd, false);
         Content label = new StringContent(cd.isInterface() ?
             configuration.getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") :
             configuration.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
@@ -163,10 +162,10 @@
     /**
      * {@inheritDoc}
      */
-    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
+    protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
             Content tdSummary) {
-        Content strong = HtmlTree.STRONG(new RawHtml(
-                writer.getLink(new LinkInfoImpl(configuration, context, (ClassDoc)member, false))));
+        Content strong = HtmlTree.STRONG(
+                writer.getLink(new LinkInfoImpl(configuration, context, (ClassDoc)member)));
         Content code = HtmlTree.CODE(strong);
         tdSummary.addContent(code);
     }
@@ -176,9 +175,9 @@
      */
     protected void addInheritedSummaryLink(ClassDoc cd,
             ProgramElementDoc member, Content linksTree) {
-        linksTree.addContent(new RawHtml(
-                writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER,
-                (ClassDoc)member, false))));
+        linksTree.addContent(
+                writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER,
+                (ClassDoc)member)));
     }
 
     /**
@@ -194,7 +193,7 @@
      * {@inheritDoc}
      */
     protected Content getDeprecatedLink(ProgramElementDoc member) {
-        return writer.getQualifiedClassLink(LinkInfoImpl.CONTEXT_MEMBER,
+        return writer.getQualifiedClassLink(LinkInfoImpl.Kind.MEMBER,
                 (ClassDoc)member);
     }
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -94,7 +94,7 @@
             packgen = new PackageFrameWriter(configuration, packageDoc);
             String pkgName = Util.getPackageName(packageDoc);
             Content body = packgen.getBody(false, packgen.getWindowTitle(pkgName));
-            Content pkgNameContent = new RawHtml(pkgName);
+            Content pkgNameContent = new StringContent(pkgName);
             Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
                     packgen.getTargetPackageLink(packageDoc, "classFrame", pkgNameContent));
             body.addContent(heading);
@@ -166,7 +166,7 @@
             Arrays.sort(arr);
             boolean printedHeader = false;
             HtmlTree ul = new HtmlTree(HtmlTag.UL);
-            ul.addAttr(HtmlAttr.TITLE, labelContent.toString());
+            ul.setTitle(labelContent);
             for (int i = 0; i < arr.length; i++) {
                 if (documentedClasses != null &&
                         !documentedClasses.contains(arr[i])) {
@@ -182,10 +182,10 @@
                     contentTree.addContent(heading);
                     printedHeader = true;
                 }
-                Content link = new RawHtml (getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.PACKAGE_FRAME, arr[i],
-                        (arr[i].isInterface() ? italicsText(arr[i].name()) :
-                            arr[i].name()),"classFrame")));
+                Content arr_i_name = new StringContent(arr[i].name());
+                if (arr[i].isInterface()) arr_i_name = HtmlTree.I(arr_i_name);
+                Content link = getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.Kind.PACKAGE_FRAME, arr[i]).label(arr_i_name).target("classFrame"));
                 Content li = HtmlTree.LI(link);
                 ul.addContent(li);
             }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -84,7 +84,7 @@
                 packagesLabel);
         Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
         HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
+        ul.setTitle(packagesLabel);
         for(int i = 0; i < packages.length; i++) {
             // Do not list the package if -nodeprecated option is set and the
             // package is marked as deprecated.
@@ -112,7 +112,7 @@
                      DocPaths.PACKAGE_FRAME), packageLabel, "",
                     "packageFrame");
         } else {
-            packageLabel = new RawHtml("&lt;unnamed package&gt;");
+            packageLabel = new StringContent("<unnamed package>");
             packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
                     packageLabel, "", "packageFrame");
         }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -123,7 +123,7 @@
     /**
      * {@inheritDoc}
      */
-    protected void addProfilesList(String profileSummary, String profilesTableSummary,
+    protected void addProfilesList(Content profileSummary, String profilesTableSummary,
             Content body) {
         Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, profilesTableSummary,
                 getTableCaption(profileSummary));
@@ -141,7 +141,7 @@
     protected void addPackagesList(PackageDoc[] packages, String text,
             String tableSummary, Content body) {
         Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, tableSummary,
-                getTableCaption(text));
+                getTableCaption(new RawHtml(text)));
         table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
         Content tbody = new HtmlTree(HtmlTag.TBODY);
         addPackagesList(packages, tbody);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
@@ -152,9 +152,9 @@
      */
     protected void addPackageList(Content contentTree) throws IOException {
         Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
-                getTableCaption(configuration.getText(
+                getTableCaption(configuration.getResource(
                 "doclet.ClassUse_Packages.that.use.0",
-                getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false))));
+                getPackageLink(pkgdoc, Util.getPackageName(pkgdoc)))));
         table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
         Content tbody = new HtmlTree(HtmlTag.TBODY);
         Iterator<String> it = usingPackageToUsedClasses.keySet().iterator();
@@ -197,10 +197,10 @@
             String tableSummary = configuration.getText("doclet.Use_Table_Summary",
                     configuration.getText("doclet.classes"));
             Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
-                    getTableCaption(configuration.getText(
+                    getTableCaption(configuration.getResource(
                     "doclet.ClassUse_Classes.in.0.used.by.1",
-                    getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false),
-                    getPackageLinkString(usingPackage,Util.getPackageName(usingPackage), false))));
+                    getPackageLink(pkgdoc, Util.getPackageName(pkgdoc)),
+                    getPackageLink(usingPackage, Util.getPackageName(usingPackage)))));
             table.addContent(getSummaryTableHeader(classTableHeader, "col"));
             Content tbody = new HtmlTree(HtmlTag.TBODY);
             Iterator<ClassDoc> itc =
@@ -247,7 +247,7 @@
     protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
         Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
                 getHyperLink(Util.getPackageName(pkg),
-                new RawHtml(Util.getPackageName(pkg))));
+                new StringContent(Util.getPackageName(pkg))));
         contentTree.addContent(tdFirst);
         HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
         tdLast.addStyle(HtmlStyle.colLast);
@@ -272,7 +272,10 @@
         Content bodyTree = getBody(true, getWindowTitle(title));
         addTop(bodyTree);
         addNavLinks(true, bodyTree);
-        Content headContent = getResource("doclet.ClassUse_Title", packageText, name);
+        ContentBuilder headContent = new ContentBuilder();
+        headContent.addContent(getResource("doclet.ClassUse_Title", packageText));
+        headContent.addContent(new HtmlTree(HtmlTag.BR));
+        headContent.addContent(name);
         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
                 HtmlStyle.title, headContent);
         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, 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
@@ -102,7 +102,7 @@
         Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
                 HtmlStyle.title, packageLabel);
         tHeading.addContent(getSpace());
-        Content packageHead = new RawHtml(heading);
+        Content packageHead = new StringContent(heading);
         tHeading.addContent(packageHead);
         div.addContent(tHeading);
         addDeprecationInfo(div);
@@ -168,7 +168,7 @@
             String tableSummary, String[] tableHeader, Content summaryContentTree) {
         if(classes.length > 0) {
             Arrays.sort(classes);
-            Content caption = getTableCaption(label);
+            Content caption = getTableCaption(new RawHtml(label));
             Content table = HtmlTree.TABLE(HtmlStyle.packageSummary, 0, 3, 0,
                     tableSummary, caption);
             table.addContent(getSummaryTableHeader(tableHeader, "col"));
@@ -178,9 +178,8 @@
                     !configuration.isGeneratedDoc(classes[i])) {
                     continue;
                 }
-                Content classContent = new RawHtml(getLink(new LinkInfoImpl(
-                        configuration, LinkInfoImpl.CONTEXT_PACKAGE, classes[i],
-                        false)));
+                Content classContent = getLink(new LinkInfoImpl(
+                        configuration, LinkInfoImpl.Kind.PACKAGE, classes[i]));
                 Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
                 HtmlTree tr = HtmlTree.TR(tdClass);
                 if (i%2 == 0)
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -87,7 +87,7 @@
                 profilesLabel);
         Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
         HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        ul.addAttr(HtmlAttr.TITLE, profilesLabel.toString());
+        ul.setTitle(profilesLabel);
         for (int i = 1; i < profiles.getProfileCount(); i++) {
             ul.addContent(getProfile(i));
         }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -158,7 +158,7 @@
             Arrays.sort(arr);
             boolean printedHeader = false;
             HtmlTree ul = new HtmlTree(HtmlTag.UL);
-            ul.addAttr(HtmlAttr.TITLE, labelContent.toString());
+            ul.setTitle(labelContent);
             for (int i = 0; i < arr.length; i++) {
                 if (!isTypeInProfile(arr[i], profileValue)) {
                     continue;
@@ -173,10 +173,10 @@
                     contentTree.addContent(heading);
                     printedHeader = true;
                 }
-                Content link = new RawHtml (getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.PACKAGE_FRAME, arr[i],
-                        (arr[i].isInterface() ? italicsText(arr[i].name()) :
-                            arr[i].name()),"classFrame")));
+                Content arr_i_name = new StringContent(arr[i].name());
+                if (arr[i].isInterface()) arr_i_name = HtmlTree.I(arr_i_name);
+                Content link = getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.Kind.PACKAGE_FRAME, arr[i]).label(arr_i_name).target("classFrame"));
                 Content li = HtmlTree.LI(link);
                 ul.addContent(li);
             }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -91,7 +91,7 @@
         heading.addContent(packagesLabel);
         Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
         HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
+        ul.setTitle(packagesLabel);
         PackageDoc[] packages = configuration.profilePackages.get(profileName);
         for (int i = 0; i < packages.length; i++) {
             if ((!(configuration.nodeprecated && Util.isDeprecated(packages[i])))) {
@@ -118,7 +118,7 @@
                      DocPaths.profilePackageFrame(profileName)), pkgLabel, "",
                     "packageFrame");
         } else {
-            pkgLabel = new RawHtml("&lt;unnamed package&gt;");
+            pkgLabel = new StringContent("<unnamed package>");
             packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
                     pkgLabel, "", "packageFrame");
         }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -98,9 +98,9 @@
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(property, pre);
         addModifiers(property, pre);
-        Content propertylink = new RawHtml(writer.getLink(new LinkInfoImpl(
-                configuration, LinkInfoImpl.CONTEXT_MEMBER,
-                property.returnType())));
+        Content propertylink = writer.getLink(new LinkInfoImpl(
+                configuration, LinkInfoImpl.Kind.MEMBER,
+                property.returnType()));
         pre.addContent(propertylink);
         pre.addContent(" ");
         if (configuration.linksource) {
@@ -128,12 +128,12 @@
                     (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
                 writer.addInlineComment(property, propertyDocTree);
             } else {
-                Content link = new RawHtml(
-                        writer.getDocLink(LinkInfoImpl.CONTEXT_PROPERTY_DOC_COPY,
+                Content link =
+                        writer.getDocLink(LinkInfoImpl.Kind.PROPERTY_DOC_COPY,
                         holder, property,
                         holder.isIncluded() ?
                             holder.typeName() : holder.qualifiedTypeName(),
-                            false));
+                            false);
                 Content codeLink = HtmlTree.CODE(link);
                 Content strong = HtmlTree.STRONG(holder.isClass()?
                    writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
@@ -199,8 +199,8 @@
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration.getText("doclet.Properties");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Properties");
     }
 
     /**
@@ -235,8 +235,8 @@
      * {@inheritDoc}
      */
     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
-        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
-                LinkInfoImpl.CONTEXT_MEMBER, cd, false));
+        Content classLink = writer.getPreQualifiedClassLink(
+                LinkInfoImpl.Kind.MEMBER, cd, false);
         Content label = new StringContent(cd.isClass() ?
             configuration.getText("doclet.Properties_Inherited_From_Class") :
             configuration.getText("doclet.Properties_Inherited_From_Interface"));
@@ -250,15 +250,15 @@
     /**
      * {@inheritDoc}
      */
-    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
+    protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
             Content tdSummary) {
-        Content strong = HtmlTree.STRONG(new RawHtml(
+        Content strong = HtmlTree.STRONG(
                 writer.getDocLink(context,
                         cd,
                         (MemberDoc) member,
                         member.name().substring(0, member.name().lastIndexOf("Property")),
                         false,
-                        true)));
+                        true));
 
         Content code = HtmlTree.CODE(strong);
         tdSummary.addContent(code);
@@ -269,12 +269,12 @@
      */
     protected void addInheritedSummaryLink(ClassDoc cd,
             ProgramElementDoc member, Content linksTree) {
-        linksTree.addContent(new RawHtml(
-                writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
+        linksTree.addContent(
+                writer.getDocLink(LinkInfoImpl.Kind.MEMBER, cd, (MemberDoc)member,
                 ((member.name().lastIndexOf("Property") != -1) && configuration.javafx)
                         ? member.name().substring(0, member.name().length() - "Property".length())
                         : member.name(),
-                false, true)));
+                false, true));
     }
 
     /**
@@ -289,7 +289,7 @@
      * {@inheritDoc}
      */
     protected Content getDeprecatedLink(ProgramElementDoc member) {
-        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+        return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
                 (MemberDoc) member, ((MethodDoc)member).qualifiedName());
     }
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
@@ -127,29 +127,28 @@
      * @return a content tree for the class header
      */
     public Content getClassHeader(ClassDoc classDoc) {
-        String classLink = (classDoc.isPublic() || classDoc.isProtected())?
-            getLink(new LinkInfoImpl(configuration, classDoc,
-            configuration.getClassName(classDoc))):
-            classDoc.qualifiedName();
+        Content classLink = (classDoc.isPublic() || classDoc.isProtected()) ?
+            getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, classDoc)
+            .label(configuration.getClassName(classDoc))) :
+            new StringContent(classDoc.qualifiedName());
         Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
                 classDoc.qualifiedName()));
-        String superClassLink =
+        Content superClassLink =
             classDoc.superclassType() != null ?
                 getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.CONTEXT_SERIALIZED_FORM,
+                        LinkInfoImpl.Kind.SERIALIZED_FORM,
                         classDoc.superclassType())) :
                 null;
 
         //Print the heading.
-        String className = superClassLink == null ?
-            configuration.getText(
+        Content className = superClassLink == null ?
+            configuration.getResource(
             "doclet.Class_0_implements_serializable", classLink) :
-            configuration.getText(
+            configuration.getResource(
             "doclet.Class_0_extends_implements_serializable", classLink,
             superClassLink);
-        Content classNameContent = new RawHtml(className);
         li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
-                classNameContent));
+                className));
         return li;
     }
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, 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
@@ -58,7 +58,7 @@
     /**
      * New line to be added to the documentation.
      */
-    private static final Content NEW_LINE = new RawHtml(DocletConstants.NL);
+    private static final String NEW_LINE = DocletConstants.NL;
 
     private final ConfigurationImpl configuration;
 
@@ -269,10 +269,7 @@
      */
     private void addLine(Content pre, String line, int currentLineNo) {
         if (line != null) {
-            StringBuilder lineBuffer = new StringBuilder(line);
-            Util.replaceTabs(configuration, lineBuffer);
-            Util.escapeHtmlChars(lineBuffer);
-            pre.addContent(new RawHtml(lineBuffer.toString()));
+            pre.addContent(Util.replaceTabs(configuration, line));
             Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo));
             pre.addContent(anchor);
             pre.addContent(NEW_LINE);
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, 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
@@ -135,10 +135,8 @@
      * @return the content tree for the method type link
      */
     public Content getMethodTypeLinks(MethodTypes methodType) {
-        StringBuilder jsShow = new StringBuilder("javascript:show(");
-        jsShow.append(methodType.value()).append(");");
-        HtmlTree link = HtmlTree.A(jsShow.toString(),
-                new StringContent(methodType.text()));
+        String jsShow = "javascript:show(" + methodType.value() +");";
+        HtmlTree link = HtmlTree.A(jsShow, new StringContent(methodType.text()));
         return link;
     }
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletOutputImpl.java	Thu May 16 12:16:07 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.doclets.formats.html;
-
-import com.sun.tools.doclets.internal.toolkit.taglets.*;
-
-/**
- * The output for HTML taglets.
- *
- *  <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.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- * @since 1.5
- * @author Jamie Ho
- */
-
-public class TagletOutputImpl implements TagletOutput {
-
-    private StringBuilder output;
-
-    public TagletOutputImpl(String o) {
-        setOutput(o);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setOutput (Object o) {
-        output = new StringBuilder(o == null ? "" : (String) o);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void appendOutput(TagletOutput o) {
-        output.append(o.toString());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean hasInheritDocTag() {
-        return output.indexOf(InheritDocTaglet.INHERIT_DOC_INLINE_TAG) != -1;
-    }
-
-    public String toString() {
-        return output.toString();
-    }
-
-    /**
-     * Check whether the taglet output is empty.
-     */
-    public boolean isEmpty() {
-        return (toString().trim().isEmpty());
-    }
-}
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,11 @@
 package com.sun.tools.doclets.formats.html;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.ContentBuilder;
+import com.sun.tools.doclets.formats.html.markup.HtmlStyle;
+import com.sun.tools.doclets.formats.html.markup.HtmlTree;
+import com.sun.tools.doclets.formats.html.markup.RawHtml;
+import com.sun.tools.doclets.formats.html.markup.StringContent;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
@@ -58,39 +63,48 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getOutputInstance() {
-        return new TagletOutputImpl("");
+    public Content getOutputInstance() {
+        return new ContentBuilder();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected Content codeTagOutput(Tag tag) {
+        Content result = HtmlTree.CODE(new StringContent(tag.text()));
+        return result;
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getDocRootOutput() {
+    public Content getDocRootOutput() {
+        String path;
         if (configuration.docrootparent.length() > 0)
-            return new TagletOutputImpl(configuration.docrootparent);
+            path = configuration.docrootparent;
         else if (htmlWriter.pathToRoot.isEmpty())
-            return new TagletOutputImpl(".");
+            path = ".";
         else
-            return new TagletOutputImpl(htmlWriter.pathToRoot.getPath());
+            path = htmlWriter.pathToRoot.getPath();
+        return new StringContent(path);
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput deprecatedTagOutput(Doc doc) {
-        StringBuilder output = new StringBuilder();
+    public Content deprecatedTagOutput(Doc doc) {
+        ContentBuilder result = new ContentBuilder();
         Tag[] deprs = doc.tags("deprecated");
         if (doc instanceof ClassDoc) {
             if (Util.isDeprecated((ProgramElementDoc) doc)) {
-                output.append("<span class=\"strong\">" +
-                    configuration.
-                        getText("doclet.Deprecated") + "</span>&nbsp;");
+                result.addContent(HtmlTree.SPAN(HtmlStyle.strong,
+                        new StringContent(configuration.getText("doclet.Deprecated"))));
+                result.addContent(RawHtml.nbsp);
                 if (deprs.length > 0) {
                     Tag[] commentTags = deprs[0].inlineTags();
                     if (commentTags.length > 0) {
-
-                        output.append(commentTagsToOutput(null, doc,
-                            deprs[0].inlineTags(), false).toString()
+                        result.addContent(commentTagsToOutput(null, doc,
+                            deprs[0].inlineTags(), false)
                         );
                     }
                 }
@@ -98,24 +112,31 @@
         } else {
             MemberDoc member = (MemberDoc) doc;
             if (Util.isDeprecated((ProgramElementDoc) doc)) {
-                output.append("<span class=\"strong\">" +
-                    configuration.
-                            getText("doclet.Deprecated") + "</span>&nbsp;");
+                result.addContent(HtmlTree.SPAN(HtmlStyle.strong,
+                        new StringContent(configuration.getText("doclet.Deprecated"))));
+                result.addContent(RawHtml.nbsp);
                 if (deprs.length > 0) {
-                    output.append("<i>");
-                    output.append(commentTagsToOutput(null, doc,
-                        deprs[0].inlineTags(), false).toString());
-                    output.append("</i>");
+                    Content body = commentTagsToOutput(null, doc,
+                        deprs[0].inlineTags(), false);
+                    result.addContent(HtmlTree.I(body));
                 }
             } else {
                 if (Util.isDeprecated(member.containingClass())) {
-                    output.append("<span class=\"strong\">" +
-                    configuration.
-                            getText("doclet.Deprecated") + "</span>&nbsp;");
+                    result.addContent(HtmlTree.SPAN(HtmlStyle.strong,
+                            new StringContent(configuration.getText("doclet.Deprecated"))));
+                    result.addContent(RawHtml.nbsp);
                 }
             }
         }
-        return new TagletOutputImpl(output.toString());
+        return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected Content literalTagOutput(Tag tag) {
+        Content result = new StringContent(tag.text());
+        return result;
     }
 
     /**
@@ -128,177 +149,200 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getParamHeader(String header) {
-        StringBuilder result = new StringBuilder();
-        result.append("<dt>");
-        result.append("<span class=\"strong\">").append(header).append("</span></dt>");
-        return new TagletOutputImpl(result.toString());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public TagletOutput paramTagOutput(ParamTag paramTag, String paramName) {
-        TagletOutput result = new TagletOutputImpl("<dd><code>" + paramName + "</code>"
-         + " - " + htmlWriter.commentTagsToString(paramTag, null, paramTag.inlineTags(), false) + "</dd>");
+    public Content getParamHeader(String header) {
+        HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong,
+                new StringContent(header)));
         return result;
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput returnTagOutput(Tag returnTag) {
-        TagletOutput result = new TagletOutputImpl(DocletConstants.NL + "<dt>" +
-            "<span class=\"strong\">" + configuration.getText("doclet.Returns") +
-            "</span>" + "</dt>" + "<dd>" +
-            htmlWriter.commentTagsToString(returnTag, null, returnTag.inlineTags(),
-            false) + "</dd>");
+    public Content paramTagOutput(ParamTag paramTag, String paramName) {
+        ContentBuilder body = new ContentBuilder();
+        body.addContent(HtmlTree.CODE(new RawHtml(paramName)));
+        body.addContent(" - ");
+        body.addContent(htmlWriter.commentTagsToContent(paramTag, null, paramTag.inlineTags(), false));
+        HtmlTree result = HtmlTree.DD(body);
+        return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content propertyTagOutput(Tag tag, String prefix) {
+        Content body = new ContentBuilder();
+        body.addContent(new RawHtml(prefix));
+        body.addContent(" ");
+        body.addContent(HtmlTree.CODE(new RawHtml(tag.text())));
+        body.addContent(".");
+        Content result = HtmlTree.P(body);
+        return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content returnTagOutput(Tag returnTag) {
+        ContentBuilder result = new ContentBuilder();
+        result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong,
+                new StringContent(configuration.getText("doclet.Returns")))));
+        result.addContent(HtmlTree.DD(htmlWriter.commentTagsToContent(
+                returnTag, null, returnTag.inlineTags(), false)));
         return result;
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput seeTagOutput(Doc holder, SeeTag[] seeTags) {
-        String result = "";
+    public Content seeTagOutput(Doc holder, SeeTag[] seeTags) {
+        ContentBuilder body = new ContentBuilder();
         if (seeTags.length > 0) {
-            result = addSeeHeader(result);
             for (int i = 0; i < seeTags.length; ++i) {
-                if (i > 0) {
-                    result += ", " + DocletConstants.NL;
-                }
-                result += htmlWriter.seeTagToString(seeTags[i]);
+                appendSeparatorIfNotEmpty(body);
+                body.addContent(htmlWriter.seeTagToContent(seeTags[i]));
             }
         }
         if (holder.isField() && ((FieldDoc)holder).constantValue() != null &&
                 htmlWriter instanceof ClassWriterImpl) {
             //Automatically add link to constant values page for constant fields.
-            result = addSeeHeader(result);
+            appendSeparatorIfNotEmpty(body);
             DocPath constantsPath =
                     htmlWriter.pathToRoot.resolve(DocPaths.CONSTANT_VALUES);
             String whichConstant =
                     ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName() + "." + ((FieldDoc) holder).name();
             DocLink link = constantsPath.fragment(whichConstant);
-            result += htmlWriter.getHyperLinkString(link,
-                    configuration.getText("doclet.Constants_Summary"),
-                    false);
+            body.addContent(htmlWriter.getHyperLink(link,
+                    new StringContent(configuration.getText("doclet.Constants_Summary"))));
         }
         if (holder.isClass() && ((ClassDoc)holder).isSerializable()) {
             //Automatically add link to serialized form page for serializable classes.
             if ((SerializedFormBuilder.serialInclude(holder) &&
                       SerializedFormBuilder.serialInclude(((ClassDoc)holder).containingPackage()))) {
-                result = addSeeHeader(result);
+                appendSeparatorIfNotEmpty(body);
                 DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM);
                 DocLink link = serialPath.fragment(((ClassDoc)holder).qualifiedName());
-                result += htmlWriter.getHyperLinkString(link,
-                        configuration.getText("doclet.Serialized_Form"), false);
+                body.addContent(htmlWriter.getHyperLink(link,
+                        new StringContent(configuration.getText("doclet.Serialized_Form"))));
             }
         }
-        return result.equals("") ? null : new TagletOutputImpl(result + "</dd>");
+        if (body.isEmpty())
+            return body;
+
+        ContentBuilder result = new ContentBuilder();
+        result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong,
+                new StringContent(configuration.getText("doclet.See_Also")))));
+        result.addContent(HtmlTree.DD(body));
+        return result;
+
     }
 
-    private String addSeeHeader(String result) {
-        if (result != null && result.length() > 0) {
-            return result + ", " + DocletConstants.NL;
-        } else {
-            return "<dt><span class=\"strong\">" +
-                    configuration.getText("doclet.See_Also") + "</span></dt><dd>";
+    private void appendSeparatorIfNotEmpty(ContentBuilder body) {
+        if (!body.isEmpty()) {
+            body.addContent(", ");
+            body.addContent(DocletConstants.NL);
         }
-     }
-
-    /**
-     * {@inheritDoc}
-     */
-    public TagletOutput simpleTagOutput(Tag[] simpleTags, String header) {
-        String result = "<dt><span class=\"strong\">" + header + "</span></dt>" + DocletConstants.NL +
-            "  <dd>";
-        for (int i = 0; i < simpleTags.length; i++) {
-            if (i > 0) {
-                result += ", ";
-            }
-            result += htmlWriter.commentTagsToString(simpleTags[i], null, simpleTags[i].inlineTags(), false);
-        }
-        result += "</dd>" + DocletConstants.NL;
-        return new TagletOutputImpl(result);
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput simpleTagOutput(Tag simpleTag, String header) {
-        return new TagletOutputImpl("<dt><span class=\"strong\">" + header + "</span></dt>" + "  <dd>"
-            + htmlWriter.commentTagsToString(simpleTag, null, simpleTag.inlineTags(), false)
-            + "</dd>" + DocletConstants.NL);
+    public Content simpleTagOutput(Tag[] simpleTags, String header) {
+        ContentBuilder result = new ContentBuilder();
+        result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong, new RawHtml(header))));
+        ContentBuilder body = new ContentBuilder();
+        for (int i = 0; i < simpleTags.length; i++) {
+            if (i > 0) {
+                body.addContent(", ");
+            }
+            body.addContent(htmlWriter.commentTagsToContent(
+                    simpleTags[i], null, simpleTags[i].inlineTags(), false));
+        }
+        result.addContent(HtmlTree.DD(body));
+        return result;
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getThrowsHeader() {
-        return new TagletOutputImpl(DocletConstants.NL + "<dt>" + "<span class=\"strong\">" +
-            configuration.getText("doclet.Throws") + "</span></dt>");
+    public Content simpleTagOutput(Tag simpleTag, String header) {
+        ContentBuilder result = new ContentBuilder();
+        result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong, new RawHtml(header))));
+        Content body = htmlWriter.commentTagsToContent(
+                simpleTag, null, simpleTag.inlineTags(), false);
+        result.addContent(HtmlTree.DD(body));
+        return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getThrowsHeader() {
+        HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong,
+                new StringContent(configuration.getText("doclet.Throws"))));
+        return result;
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput throwsTagOutput(ThrowsTag throwsTag) {
-        String result = DocletConstants.NL + "<dd>";
-        result += throwsTag.exceptionType() == null ?
-            htmlWriter.codeText(throwsTag.exceptionName()) :
-            htmlWriter.codeText(
-                htmlWriter.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER,
-                throwsTag.exceptionType())));
-        TagletOutput text = new TagletOutputImpl(
-            htmlWriter.commentTagsToString(throwsTag, null,
-            throwsTag.inlineTags(), false));
-        if (text != null && text.toString().length() > 0) {
-            result += " - " + text;
+    public Content throwsTagOutput(ThrowsTag throwsTag) {
+        ContentBuilder body = new ContentBuilder();
+        Content excName = (throwsTag.exceptionType() == null) ?
+                new RawHtml(throwsTag.exceptionName()) :
+                htmlWriter.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER,
+                throwsTag.exceptionType()));
+        body.addContent(HtmlTree.CODE(excName));
+        Content desc = htmlWriter.commentTagsToContent(throwsTag, null,
+            throwsTag.inlineTags(), false);
+        if (desc != null && !desc.isEmpty()) {
+            body.addContent(" - ");
+            body.addContent(desc);
         }
-        result += "</dd>";
-        return new TagletOutputImpl(result);
+        HtmlTree result = HtmlTree.DD(body);
+        return result;
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput throwsTagOutput(Type throwsType) {
-        return new TagletOutputImpl(DocletConstants.NL + "<dd>" +
-            htmlWriter.codeText(htmlWriter.getLink(
-                new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + "</dd>");
+    public Content throwsTagOutput(Type throwsType) {
+        HtmlTree result = HtmlTree.DD(HtmlTree.CODE(htmlWriter.getLink(
+                new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, throwsType))));
+        return result;
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput valueTagOutput(FieldDoc field, String constantVal,
+    public Content valueTagOutput(FieldDoc field, String constantVal,
             boolean includeLink) {
-        return new TagletOutputImpl(includeLink ?
-            htmlWriter.getDocLink(LinkInfoImpl.CONTEXT_VALUE_TAG, field,
-                constantVal, false) : constantVal);
+        return includeLink ?
+            htmlWriter.getDocLink(LinkInfoImpl.Kind.VALUE_TAG, field,
+                constantVal, false) : new RawHtml(constantVal);
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput commentTagsToOutput(Tag holderTag, Tag[] tags) {
+    public Content commentTagsToOutput(Tag holderTag, Tag[] tags) {
         return commentTagsToOutput(holderTag, null, tags, false);
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput commentTagsToOutput(Doc holderDoc, Tag[] tags) {
+    public Content commentTagsToOutput(Doc holderDoc, Tag[] tags) {
         return commentTagsToOutput(null, holderDoc, tags, false);
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput commentTagsToOutput(Tag holderTag,
+    public Content commentTagsToOutput(Tag holderTag,
         Doc holderDoc, Tag[] tags, boolean isFirstSentence) {
-        return new TagletOutputImpl(htmlWriter.commentTagsToString(
-            holderTag, holderDoc, tags, isFirstSentence));
+        return htmlWriter.commentTagsToContent(
+            holderTag, holderDoc, tags, isFirstSentence);
     }
 
     /**
@@ -307,13 +351,4 @@
     public Configuration configuration() {
         return configuration;
     }
-
-    /**
-     * Return an instance of a TagletWriter that knows how to write HTML.
-     *
-     * @return an instance of a TagletWriter that knows how to write HTML.
-     */
-    public TagletOutput getTagletOutputInstance() {
-        return new TagletOutputImpl("");
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/ContentBuilder.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.formats.html.markup;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import com.sun.tools.doclets.internal.toolkit.Content;
+
+/**
+ * A sequence of Content nodes.
+ */
+public class ContentBuilder extends Content {
+    protected List<Content> contents = Collections.<Content>emptyList();
+
+    @Override
+    public void addContent(Content content) {
+        nullCheck(content);
+        if ((content instanceof ContentBuilder) && content.isEmpty())
+            return;
+        ensureMutableContents();
+        if (content instanceof ContentBuilder) {
+            contents.addAll(((ContentBuilder) content).contents);
+        } else
+            contents.add(content);
+    }
+
+    @Override
+    public void addContent(String text) {
+        if (text.isEmpty())
+            return;
+        ensureMutableContents();
+        Content c = contents.isEmpty() ? null : contents.get(contents.size() - 1);
+        StringContent sc;
+        if (c != null && c instanceof StringContent) {
+            sc = (StringContent) c;
+        } else {
+            contents.add(sc = new StringContent());
+        }
+        sc.addContent(text);
+    }
+
+    @Override
+    public boolean write(Writer writer, boolean atNewline) throws IOException {
+        for (Content content: contents) {
+            atNewline = content.write(writer, atNewline);
+        }
+        return atNewline;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        for (Content content: contents) {
+            if (!content.isEmpty())
+                return false;
+        }
+        return true;
+    }
+
+    @Override
+    public int charCount() {
+        int n = 0;
+        for (Content c : contents)
+            n += c.charCount();
+        return n;
+    }
+
+    private void ensureMutableContents() {
+        if (contents.isEmpty())
+            contents = new ArrayList<Content>();
+    }
+}
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, 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
@@ -34,7 +34,6 @@
 import com.sun.tools.doclets.internal.toolkit.util.DocFile;
 import com.sun.tools.doclets.internal.toolkit.util.DocLink;
 import com.sun.tools.doclets.internal.toolkit.util.DocPath;
-import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
 
 
 /**
@@ -72,43 +71,8 @@
      */
     public abstract Configuration configuration();
 
-    /**
-     * Return Html Hyper Link string.
-     *
-     * @param link       String name of the file.
-     * @param label      Tag for the link.
-     * @param strong       Boolean that sets label to strong.
-     * @return String    Hyper Link.
-     */
-    public String getHyperLinkString(DocPath link,
-                               String label, boolean strong) {
-        return getHyperLinkString(link, label, strong, "", "", "");
-    }
-
-    public String getHyperLinkString(DocLink link,
-                               String label, boolean strong) {
-        return getHyperLinkString(link, label, strong, "", "", "");
-    }
-
-    /**
-     * Get Html Hyper Link string.
-     *
-     * @param link       String name of the file.
-     * @param label      Tag for the link.
-     * @param strong       Boolean that sets label to strong.
-     * @param stylename  String style of text defined in style sheet.
-     * @return String    Hyper Link.
-     */
-    public String getHyperLinkString(DocPath link,
-                               String label, boolean strong,
-                               String stylename) {
-        return getHyperLinkString(link, label, strong, stylename, "", "");
-    }
-
-    public String getHyperLinkString(DocLink link,
-                               String label, boolean strong,
-                               String stylename) {
-        return getHyperLinkString(link, label, strong, stylename, "", "");
+    public Content getHyperLink(DocPath link, String label) {
+        return getHyperLink(link, new StringContent(label), false, "", "", "");
     }
 
     /**
@@ -125,69 +89,47 @@
     }
 
     /**
-     * Get Html Hyper Link string.
+     * Get Html hyperlink.
      *
-     * @param link       String name of the file.
+     * @param link       path of the file.
      * @param label      Tag for the link.
      * @return a content tree for the hyper link
      */
-    public Content getHyperLink(DocPath link,
-                               Content label) {
+    public Content getHyperLink(DocPath link, Content label) {
         return getHyperLink(link, label, "", "");
     }
 
-    public Content getHyperLink(DocLink link,
-                               Content label) {
+    public Content getHyperLink(DocLink link, Content label) {
         return getHyperLink(link, label, "", "");
     }
 
-    /**
-     * Get Html Hyper Link string.
-     *
-     * @param link       String name of the file.
-     * @param label      Tag for the link.
-     * @param strong       Boolean that sets label to strong.
-     * @param stylename  String style of text defined in style sheet.
-     * @param title      String that describes the links content for accessibility.
-     * @param target     Target frame.
-     * @return String    Hyper Link.
-     */
-    public String getHyperLinkString(DocPath link,
-                               String label, boolean strong,
+    public Content getHyperLink(DocPath link,
+                               Content label, boolean strong,
                                String stylename, String title, String target) {
-        return getHyperLinkString(new DocLink(link), label, strong,
+        return getHyperLink(new DocLink(link), label, strong,
                 stylename, title, target);
     }
 
-    public String getHyperLinkString(DocLink link,
-                               String label, boolean strong,
+    public Content getHyperLink(DocLink link,
+                               Content label, boolean strong,
                                String stylename, String title, String target) {
-        StringBuilder retlink = new StringBuilder();
-        retlink.append("<a href=\"").append(link).append('"');
+        Content body = label;
+        if (strong) {
+            body = HtmlTree.SPAN(HtmlStyle.strong, body);
+        }
+        if (stylename != null && stylename.length() != 0) {
+            HtmlTree t = new HtmlTree(HtmlTag.FONT, body);
+            t.addAttr(HtmlAttr.CLASS, stylename);
+            body = t;
+        }
+        HtmlTree l = HtmlTree.A(link.toString(), body);
         if (title != null && title.length() != 0) {
-            retlink.append(" title=\"").append(title).append('"');
+            l.addAttr(HtmlAttr.TITLE, title);
         }
         if (target != null && target.length() != 0) {
-            retlink.append(" target=\"").append(target).append('"');
-        }
-        retlink.append(">");
-        if (stylename != null && stylename.length() != 0) {
-            retlink.append("<FONT CLASS=\"");
-            retlink.append(stylename);
-            retlink.append("\">");
+            l.addAttr(HtmlAttr.TARGET, target);
         }
-        if (strong) {
-            retlink.append("<span class=\"strong\">");
-        }
-        retlink.append(label);
-        if (strong) {
-            retlink.append("</span>");
-        }
-        if (stylename != null && stylename.length() != 0) {
-            retlink.append("</FONT>");
-        }
-        retlink.append("</a>");
-        return retlink.toString();
+        return l;
     }
 
     /**
@@ -217,17 +159,6 @@
     }
 
     /**
-     * Get link string without positioning in the file.
-     *
-     * @param link       String name of the file.
-     * @param label      Tag for the link.
-     * @return Strign    Hyper link.
-     */
-    public String getHyperLinkString(DocPath link, String label) {
-        return getHyperLinkString(link, label, false);
-    }
-
-    /**
      * Get the name of the package, this class is in.
      *
      * @param cd    ClassDoc.
@@ -277,20 +208,6 @@
         write(htmlDocument);
     }
 
-    /**
-     * Print the appropriate spaces to format the class tree in the class page.
-     *
-     * @param len   Number of spaces.
-     */
-    public String spaces(int len) {
-        String space = "";
-
-        for (int i = 0; i < len; i++) {
-            space += " ";
-        }
-        return space;
-    }
-
     protected String getGeneratedByString() {
         Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
         Date today = calendar.getTime();
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -44,6 +44,7 @@
     CENTER,
     CODE(BlockType.INLINE, EndTag.END),
     DD,
+    DIR,
     DIV,
     DL,
     DT,
@@ -63,6 +64,7 @@
     I(BlockType.INLINE, EndTag.END),
     IMG(BlockType.INLINE, EndTag.NOEND),
     LI,
+    LISTING,
     LINK(BlockType.OTHER, EndTag.NOEND),
     MENU,
     META(BlockType.OTHER, EndTag.NOEND),
@@ -75,6 +77,7 @@
     SMALL(BlockType.INLINE, EndTag.END),
     SPAN(BlockType.INLINE, EndTag.END),
     STRONG(BlockType.INLINE, EndTag.END),
+    SUB(BlockType.INLINE, EndTag.END),
     TABLE,
     TBODY,
     TD,
@@ -84,14 +87,14 @@
     TT(BlockType.INLINE, EndTag.END),
     UL;
 
-    protected final BlockType blockType;
-    protected final EndTag endTag;
-    private final String value;
+    public final BlockType blockType;
+    public final EndTag endTag;
+    public final String value;
 
     /**
      * Enum representing the type of HTML element.
      */
-    protected static enum BlockType {
+    public static enum BlockType {
         BLOCK,
         INLINE,
         OTHER;
@@ -100,7 +103,7 @@
     /**
      * Enum representing HTML end tag requirement.
      */
-    protected static enum EndTag {
+    public static enum EndTag {
         END,
         NOEND;
     }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -78,8 +78,12 @@
      */
     public void addAttr(HtmlAttr attrName, String attrValue) {
         if (attrs.isEmpty())
-            attrs = new LinkedHashMap<HtmlAttr,String>();
-        attrs.put(nullCheck(attrName), nullCheck(attrValue));
+            attrs = new LinkedHashMap<HtmlAttr,String>(3);
+        attrs.put(nullCheck(attrName), escapeHtmlChars(attrValue));
+    }
+
+    public void setTitle(Content body) {
+        addAttr(HtmlAttr.TITLE, stripHtml(body));
     }
 
     /**
@@ -123,6 +127,42 @@
             addContent(new StringContent(stringContent));
     }
 
+    public int charCount() {
+        int n = 0;
+        for (Content c : content)
+            n += c.charCount();
+        return n;
+    }
+
+    /**
+     * Given a string, escape all special html characters and
+     * return the result.
+     *
+     * @param s The string to check.
+     * @return the original string with all of the HTML characters escaped.
+     */
+    private static String escapeHtmlChars(String s) {
+        for (int i = 0; i < s.length(); i++) {
+            char ch = s.charAt(i);
+            switch (ch) {
+                // only start building a new string if we need to
+                case '<': case '>': case '&':
+                    StringBuilder sb = new StringBuilder(s.substring(0, i));
+                    for ( ; i < s.length(); i++) {
+                        ch = s.charAt(i);
+                        switch (ch) {
+                            case '<': sb.append("&lt;");  break;
+                            case '>': sb.append("&gt;");  break;
+                            case '&': sb.append("&amp;"); break;
+                            default:  sb.append(ch);      break;
+                        }
+                    }
+                    return sb.toString();
+            }
+        }
+        return s;
+    }
+
     /**
      * Generates an HTML anchor tag.
      *
@@ -132,7 +172,7 @@
      */
     public static HtmlTree A(String ref, Content body) {
         HtmlTree htmltree = new HtmlTree(HtmlTag.A, nullCheck(body));
-        htmltree.addAttr(HtmlAttr.HREF, nullCheck(ref));
+        htmltree.addAttr(HtmlAttr.HREF, ref);
         return htmltree;
     }
 
@@ -317,7 +357,7 @@
             HtmlStyle styleClass, Content body) {
         HtmlTree htmltree = new HtmlTree(headingTag, nullCheck(body));
         if (printTitle)
-            htmltree.addAttr(HtmlAttr.TITLE, Util.stripHtml(body.toString()));
+            htmltree.setTitle(body);
         if (styleClass != null)
             htmltree.addStyle(styleClass);
         return htmltree;
@@ -802,7 +842,7 @@
         out.write(tagString);
         Iterator<HtmlAttr> iterator = attrs.keySet().iterator();
         HtmlAttr key;
-        String value = "";
+        String value;
         while (iterator.hasNext()) {
             key = iterator.next();
             value = attrs.get(key);
@@ -830,4 +870,22 @@
             return false;
         }
     }
+
+    /**
+     * Given a Content node, strips all html characters and
+     * return the result.
+     *
+     * @param body The content node to check.
+     * @return the plain text from the content node
+     *
+     */
+    private static String stripHtml(Content body) {
+        String rawString = body.toString();
+        // remove HTML tags
+        rawString = rawString.replaceAll("\\<.*?>", " ");
+        // consolidate multiple spaces between a word to a single space
+        rawString = rawString.replaceAll("\\b\\s{2,}\\b", " ");
+        // remove extra whitespaces
+        return rawString.trim();
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -27,6 +27,8 @@
 
 import java.io.*;
 import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
@@ -195,8 +197,7 @@
                 configuration.getText("doclet.Modifier"),
                 configuration.getText("doclet.Type"));
         overviewLabel = getResource("doclet.Overview");
-        defaultPackageLabel = new RawHtml(
-                DocletConstants.DEFAULT_PACKAGE_NAME);
+        defaultPackageLabel = new StringContent(DocletConstants.DEFAULT_PACKAGE_NAME);
         packageLabel = getResource("doclet.Package");
         profileLabel = getResource("doclet.Profile");
         useLabel = getResource("doclet.navClassUse");
@@ -252,30 +253,30 @@
      * @return a content tree for the text
      */
     public Content getResource(String key) {
-        return new StringContent(configuration.getText(key));
+        return configuration.getResource(key);
     }
 
     /**
      * Get the configuration string as a content.
      *
      * @param key the key to look for in the configuration file
-     * @param a1 string argument added to configuration text
+     * @param o   string or content argument added to configuration text
      * @return a content tree for the text
      */
-    public Content getResource(String key, String a1) {
-        return new RawHtml(configuration.getText(key, a1));
+    public Content getResource(String key, Object o) {
+        return configuration.getResource(key, o);
     }
 
     /**
      * Get the configuration string as a content.
      *
      * @param key the key to look for in the configuration file
-     * @param a1 string argument added to configuration text
-     * @param a2 string argument added to configuration text
+     * @param o1  string or content argument added to configuration text
+     * @param o2  string or content argument added to configuration text
      * @return a content tree for the text
      */
-    public Content getResource(String key, String a1, String a2) {
-        return new RawHtml(configuration.getText(key, a1, a2));
+    public Content getResource(String key, Object o0, Object o1) {
+        return configuration.getResource(key, o0, o1);
     }
 
     /**
@@ -303,10 +304,11 @@
      *
      * @return a content for the SCRIPT tag
      */
-    protected Content getFramesetJavaScript(){
+    protected Content getFramesetJavaScript() {
         HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
         script.addAttr(HtmlAttr.TYPE, "text/javascript");
-        String scriptCode = DocletConstants.NL + "    targetPage = \"\" + window.location.search;" + DocletConstants.NL +
+        String scriptCode = DocletConstants.NL +
+                "    targetPage = \"\" + window.location.search;" + DocletConstants.NL +
                 "    if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
                 "        targetPage = targetPage.substring(1);" + DocletConstants.NL +
                 "    if (targetPage.indexOf(\":\") != -1)" + DocletConstants.NL +
@@ -400,16 +402,6 @@
         return title;
     }
 
-    /**
-     * Return, text passed, with Italics &lt;i&gt; and &lt;/i&gt; tags, surrounding it.
-     * So if the text passed is "Hi", then string returned will be "&lt;i&gt;Hi&lt;/i&gt;".
-     *
-     * @param text String to be printed in between &lt;I&gt; and &lt;/I&gt; tags.
-     */
-    public String italicsText(String text) {
-        return "<i>" + text + "</i>";
-    }
-
     public String codeText(String text) {
         return "<code>" + text + "</code>";
     }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -41,7 +41,7 @@
  *
  * @author Bhavesh Patel
  */
-public class RawHtml extends Content{
+public class RawHtml extends Content {
 
     private String rawHtmlContent;
 
@@ -90,10 +90,65 @@
     /**
      * {@inheritDoc}
      */
+    @Override
     public String toString() {
         return rawHtmlContent;
     }
 
+    private enum State { TEXT, ENTITY, TAG, STRING };
+
+    @Override
+    public int charCount() {
+        return charCount(rawHtmlContent);
+    }
+
+    static int charCount(String htmlText) {
+        State state = State.TEXT;
+        int count = 0;
+        for (int i = 0; i < htmlText.length(); i++) {
+            char c = htmlText.charAt(i);
+            switch (state) {
+                case TEXT:
+                    switch (c) {
+                        case '<':
+                            state = State.TAG;
+                            break;
+                        case '&':
+                            state = State.ENTITY;
+                            count++;
+                            break;
+                        default:
+                            count++;
+                    }
+                    break;
+
+                case ENTITY:
+                    if (!Character.isLetterOrDigit(c))
+                        state = State.TEXT;
+                    break;
+
+                case TAG:
+                    switch (c) {
+                        case '"':
+                            state = State.STRING;
+                            break;
+                        case '>':
+                            state = State.TEXT;
+                            break;
+                    }
+                    break;
+
+                case STRING:
+                    switch (c) {
+                        case '"':
+                            state = State.TAG;
+                            break;
+                    }
+            }
+        }
+        return count;
+    }
+
     /**
      * {@inheritDoc}
      */
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -41,7 +41,7 @@
  *
  * @author Bhavesh Patel
  */
-public class StringContent extends Content{
+public class StringContent extends Content {
 
     private StringBuilder stringContent;
 
@@ -58,8 +58,8 @@
      * @param initialContent initial content for the object
      */
     public StringContent(String initialContent) {
-        stringContent = new StringBuilder(
-                Util.escapeHtmlChars(nullCheck(initialContent)));
+        stringContent = new StringBuilder();
+        appendChars(initialContent);
     }
 
     /**
@@ -81,7 +81,7 @@
      * @param strContent string content to be added
      */
     public void addContent(String strContent) {
-        stringContent.append(Util.escapeHtmlChars(nullCheck(strContent)));
+        appendChars(strContent);
     }
 
     /**
@@ -91,6 +91,10 @@
         return (stringContent.length() == 0);
     }
 
+    public int charCount() {
+        return RawHtml.charCount(stringContent.toString());
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -107,4 +111,16 @@
         out.write(s);
         return s.endsWith(DocletConstants.NL);
     }
+
+    private void appendChars(String s) {
+        for (int i = 0; i < s.length(); i++) {
+            char ch = s.charAt(i);
+            switch (ch) {
+                case '<': stringContent.append("&lt;");  break;
+                case '>': stringContent.append("&gt;");  break;
+                case '&': stringContent.append("&amp;"); break;
+                default:  stringContent.append(ch);      break;
+            }
+        }
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Fri May 17 10:13:34 2013 -0700
@@ -132,7 +132,7 @@
 doclet.Help_line_14=Use
 doclet.Help_line_15=Each documented package, class and interface has its own Use page.  This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A.  You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
 doclet.Help_line_16=Tree (Class Hierarchy)
-doclet.Help_line_17_with_tree_link=There is a {0} page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with <code>java.lang.Object</code>. The interfaces do not inherit from <code>java.lang.Object</code>.
+doclet.Help_line_17_with_tree_link=There is a {0} page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with {1}. The interfaces do not inherit from {1}.
 doclet.Help_line_18=When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
 doclet.Help_line_19=When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
 doclet.Help_line_20_with_deprecated_api_link=The {0} page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
@@ -179,7 +179,7 @@
 doclet.ClassUse_ConstructorThrows=Constructors in {1} that throw {0}
 doclet.ClassUse_No.usage.of.0=No usage of {0}
 doclet.Window_ClassUse_Header=Uses of {0} {1}
-doclet.ClassUse_Title=Uses of {0}<br>{1}
+doclet.ClassUse_Title=Uses of {0}
 doclet.navClassUse=Use
 doclet.Error_in_packagelist=Error in using -group option: {0} {1}
 doclet.Groupname_already_used=In -group option, groupname already used: {0}
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Fri May 17 10:13:34 2013 -0700
@@ -27,6 +27,8 @@
 
 import java.io.*;
 import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import com.sun.javadoc.*;
 import com.sun.tools.javac.sym.Profiles;
@@ -825,6 +827,82 @@
         }
     }
 
+    public abstract Content newContent();
+
+    /**
+     * Get the configuration string as a content.
+     *
+     * @param key the key to look for in the configuration file
+     * @return a content tree for the text
+     */
+    public Content getResource(String key) {
+        Content c = newContent();
+        c.addContent(getText(key));
+        return c;
+    }
+
+    /**
+     * Get the configuration string as a content.
+     *
+     * @param key the key to look for in the configuration file
+     * @param o   string or content argument added to configuration text
+     * @return a content tree for the text
+     */
+    public Content getResource(String key, Object o) {
+        return getResource(key, o, null, null);
+    }
+
+    /**
+     * Get the configuration string as a content.
+     *
+     * @param key the key to look for in the configuration file
+     * @param o   string or content argument added to configuration text
+     * @return a content tree for the text
+     */
+    public Content getResource(String key, Object o1, Object o2) {
+        return getResource(key, o1, o2, null);
+    }
+
+    /**
+     * Get the configuration string as a content.
+     *
+     * @param key the key to look for in the configuration file
+     * @param o1  string or content argument added to configuration text
+     * @param o2  string or content argument added to configuration text
+     * @return a content tree for the text
+     */
+    public Content getResource(String key, Object o0, Object o1, Object o2) {
+        Content c = newContent();
+        Pattern p = Pattern.compile("\\{([012])\\}");
+        String text = getText(key);
+        Matcher m = p.matcher(text);
+        int start = 0;
+        while (m.find(start)) {
+            c.addContent(text.substring(start, m.start()));
+
+            Object o = null;
+            switch (m.group(1).charAt(0)) {
+                case '0': o = o0; break;
+                case '1': o = o1; break;
+                case '2': o = o2; break;
+            }
+
+            if (o == null) {
+                c.addContent("{" + m.group(1) + "}");
+            } else if (o instanceof String) {
+                c.addContent((String) o);
+            } else if (o instanceof Content) {
+                c.addContent((Content) o);
+            }
+
+            start = m.end();
+        }
+
+        c.addContent(text.substring(start));
+        return c;
+    }
+
+
     /**
      * Return true if the ClassDoc element is getting documented, depending upon
      * -nodeprecated option and the deprecation information. Return true if
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -97,6 +97,15 @@
     }
 
     /**
+     * Return the number of characters of plain text content in this object
+     * (optional operation.)
+     * @return the number of characters of plain text content in this
+     */
+    public int charCount() {
+        return 0;
+    }
+
+    /**
      * Checks for null values.
      *
      * @param t reference type to check for null values
@@ -106,32 +115,4 @@
         t.getClass();
         return t;
     }
-
-    /**
-     * Returns true if the content ends with a newline character. Empty content
-     * is considered as ending with new line.
-     *
-     * @param contentBuilder content to test for newline character at the end
-     * @return true if the content ends with newline.
-     */
-    protected boolean endsWithNewLine(StringBuilder contentBuilder) {
-        int contentLength = contentBuilder.length();
-        if (contentLength == 0) {
-            return true;
-        }
-        int nlLength = DocletConstants.NL.length();
-        if (contentLength < nlLength) {
-            return false;
-        }
-        int contentIndex = contentLength - 1;
-        int nlIndex = nlLength - 1;
-        while (nlIndex >= 0) {
-            if (contentBuilder.charAt(contentIndex) != DocletConstants.NL.charAt(nlIndex)) {
-                return false;
-            }
-            contentIndex--;
-            nlIndex--;
-        }
-        return true;
-    }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java	Fri May 17 10:13:34 2013 -0700
@@ -120,8 +120,7 @@
      * @param contentTree the content tree to which the documentation will be added
      */
     public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception {
-        contentTree = packageWriter.getPackageHeader(
-                Util.getPackageName(packageDoc));
+        contentTree = packageWriter.getPackageHeader(Util.getPackageName(packageDoc));
         buildChildren(node, contentTree);
         packageWriter.addPackageFooter(contentTree);
         packageWriter.printDocument(contentTree);
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BasePropertyTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BasePropertyTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -26,6 +26,7 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import com.sun.javadoc.Tag;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * An abstract class that implements the {@link Taglet} interface and
@@ -59,15 +60,8 @@
      * @param tagletWriter the taglet writer for output.
      * @return the TagletOutput representation of this <code>Tag</code>.
      */
-    public TagletOutput getTagletOutput(Tag tag, TagletWriter tagletWriter) {
-        TagletOutput tagletOutput = tagletWriter.getOutputInstance();
-        StringBuilder output = new StringBuilder("<P>");
-        output.append(getText(tagletWriter));
-        output.append(" <CODE>");
-        output.append(tag.text());
-        output.append("</CODE>.</P>");
-        tagletOutput.setOutput(output.toString());
-        return tagletOutput;
+    public Content getTagletOutput(Tag tag, TagletWriter tagletWriter) {
+        return tagletWriter.propertyTagOutput(tag, getText(tagletWriter));
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * An abstract class for that implements the {@link Taglet} interface.
@@ -130,7 +131,7 @@
      * {@inheritDoc}
      * @throws IllegalArgumentException thrown when the method is not supported by the taglet.
      */
-    public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
+    public Content getTagletOutput(Tag tag, TagletWriter writer) {
         throw new IllegalArgumentException("Method not supported in taglet " + getName() + ".");
     }
 
@@ -138,7 +139,7 @@
      * {@inheritDoc}
      * @throws IllegalArgumentException thrown when the method is not supported by the taglet.
      */
-    public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
+    public Content getTagletOutput(Doc holder, TagletWriter writer) {
         throw new IllegalArgumentException("Method not supported in taglet " + getName() + ".");
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/CodeTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/CodeTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
 
 import java.util.Map;
 import com.sun.javadoc.Tag;
-import com.sun.tools.doclets.Taglet;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * An inline Taglet used to denote literal code fragments.
@@ -49,23 +49,23 @@
  * @since 1.5
  */
 
-public class CodeTaglet extends LiteralTaglet {
+public class CodeTaglet extends BaseInlineTaglet {
 
-        private static final String NAME = "code";
+    private static final String NAME = "code";
 
-        public static void register(Map<String, Taglet> map) {
-                map.remove(NAME);
-                map.put(NAME, new CodeTaglet());
-        }
+    public static void register(Map<String, Taglet> map) {
+        map.remove(NAME);
+        map.put(NAME, new CodeTaglet());
+    }
 
-        public String getName() {
-                return NAME;
-        }
+    public String getName() {
+        return NAME;
+    }
 
-        /*
-         * Wraps @literal's result in a <code> element.
-         */
-        public String toString(Tag tag) {
-                return "<code>" + super.toString(tag) + "</code>";
-        }
+    /**
+     * {@inheritDoc}
+     */
+    public Content getTagletOutput(Tag tag, TagletWriter writer) {
+        return writer.codeTagOutput(tag);
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DeprecatedTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DeprecatedTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * A taglet that represents the @deprecated tag.
@@ -48,7 +49,7 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
+    public Content getTagletOutput(Doc holder, TagletWriter writer) {
         return writer.deprecatedTagOutput(holder);
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DocRootTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DocRootTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * An inline Taglet representing {&#064;docRoot}.  This taglet is
@@ -60,7 +61,7 @@
      * @param writer a {@link TagletWriter} Taglet writer.
      * @return the string representation of this <code>Tag</code>.
      */
-    public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
+    public Content getTagletOutput(Tag tag, TagletWriter writer) {
         return writer.getDocRootOutput();
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ExpertTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.doclets.internal.toolkit.taglets;
-
-import java.util.Map;
-
-import com.sun.tools.doclets.Taglet;
-import com.sun.javadoc.Tag;
-
-/**
- * An inline Taglet used to denote information for experts.
- *
- *  <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.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- */
-public class ExpertTaglet implements Taglet {
-
-    private static final String NAME = "expert";
-    private static final String START_TAG = "<sub id=\"expert\">";
-    private static final String END_TAG = "</sub>";
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean inField() {
-        return true;
-    }
-
-    public boolean inConstructor() {
-        return true;
-    }
-
-    public boolean inMethod() {
-        return true;
-    }
-
-    public boolean inOverview() {
-        return true;
-    }
-
-    public boolean inPackage() {
-        return true;
-    }
-
-    public boolean inType() {
-        return true;
-    }
-
-    public boolean isInlineTag() {
-        return false;
-    }
-
-    public String getName() {
-        return NAME;
-    }
-
-    public static void register(Map<String, Taglet> map) {
-        map.remove(NAME);
-        map.put(NAME, new ExpertTaglet());
-    }
-
-    public String toString(Tag tag) {
-        return (tag.text() == null || tag.text().length() == 0) ? null :
-            START_TAG + LiteralTaglet.textToString(tag.text()) + END_TAG;
-    }
-
-
-    public String toString(Tag[] tags) {
-        if (tags == null || tags.length == 0) return null;
-
-        StringBuffer sb = new StringBuffer(START_TAG);
-
-        for(Tag t:tags) {
-            sb.append(LiteralTaglet.textToString(t.text()));
-        }
-        sb.append(END_TAG);
-        return sb.toString();
-    }
-
-}
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, 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
@@ -27,6 +27,7 @@
 
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.Configuration;
+import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
@@ -60,8 +61,8 @@
 
     /**
      * Will return false because this inline tag may
-     * only appear in Methods.
-     * @return false since this is not a method.
+     * not appear in Fields.
+     * @return false
      */
     public boolean inField() {
         return false;
@@ -69,8 +70,8 @@
 
     /**
      * Will return false because this inline tag may
-     * only appear in Methods.
-     * @return false since this is not a method.
+     * not appear in Constructors.
+     * @return false
      */
     public boolean inConstructor() {
         return false;
@@ -78,8 +79,8 @@
 
     /**
      * Will return false because this inline tag may
-     * only appear in Methods.
-     * @return false since this is not a method.
+     * not appear in Overview.
+     * @return false
      */
     public boolean inOverview() {
         return false;
@@ -87,20 +88,20 @@
 
     /**
      * Will return false because this inline tag may
-     * only appear in Methods.
-     * @return false since this is not a method.
+     * not appear in Packages.
+     * @return false
      */
     public boolean inPackage() {
         return false;
     }
 
     /**
-     * Will return false because this inline tag may
-     * only appear in Methods.
-     * @return false since this is not a method.
+     * Will return true because this inline tag may
+     * appear in Type (Class).
+     * @return true
      */
     public boolean inType() {
-        return false;
+        return true;
     }
 
     /**
@@ -109,33 +110,44 @@
      * of @inheritDoc with documentation from it's superclass or superinterface.
      *
      * @param writer the writer that is writing the output.
-     * @param md the {@link MethodDoc} that we are documenting.
-     * @param holderTag the tag that holds the inheritDoc tag.
+     * @param ped the {@link ProgramElementDoc} that we are documenting.
+     * @param holderTag the tag that holds the inheritDoc tag or null for type
+     * (class) docs.
      * @param isFirstSentence true if we only want to inherit the first sentence.
      */
-    private TagletOutput retrieveInheritedDocumentation(TagletWriter writer,
-            MethodDoc md, Tag holderTag, boolean isFirstSentence) {
-        TagletOutput replacement = writer.getTagletOutputInstance();
+    private Content retrieveInheritedDocumentation(TagletWriter writer,
+            ProgramElementDoc ped, Tag holderTag, boolean isFirstSentence) {
+        Content replacement = writer.getOutputInstance();
 
         Configuration configuration = writer.configuration();
         Taglet inheritableTaglet = holderTag == null ?
             null : configuration.tagletManager.getTaglet(holderTag.name());
         if (inheritableTaglet != null &&
             !(inheritableTaglet instanceof InheritableTaglet)) {
+                String message = ped.name() +
+                    ((ped instanceof ExecutableMemberDoc)
+                        ? ((ExecutableMemberDoc)ped).flatSignature()
+                        : "");
                 //This tag does not support inheritence.
-                configuration.message.warning(md.position(),
-                "doclet.noInheritedDoc", md.name() + md.flatSignature());
+                configuration.message.warning(ped.position(),
+                "doclet.noInheritedDoc", message);
          }
         DocFinder.Output inheritedDoc =
-            DocFinder.search(new DocFinder.Input(md,
+            DocFinder.search(new DocFinder.Input(ped,
                 (InheritableTaglet) inheritableTaglet, holderTag,
                 isFirstSentence, true));
-        if (inheritedDoc.isValidInheritDocTag == false) {
-            configuration.message.warning(md.position(),
-                "doclet.noInheritedDoc", md.name() + md.flatSignature());
-        } else if (inheritedDoc.inlineTags.length > 0) {
-            replacement = writer.commentTagsToOutput(inheritedDoc.holderTag,
-                inheritedDoc.holder, inheritedDoc.inlineTags, isFirstSentence);
+        if (inheritedDoc.isValidInheritDocTag) {
+            if (inheritedDoc.inlineTags.length > 0) {
+                replacement = writer.commentTagsToOutput(inheritedDoc.holderTag,
+                    inheritedDoc.holder, inheritedDoc.inlineTags, isFirstSentence);
+            }
+        } else {
+            String message = ped.name() +
+                    ((ped instanceof ExecutableMemberDoc)
+                        ? ((ExecutableMemberDoc)ped).flatSignature()
+                        : "");
+            configuration.message.warning(ped.position(),
+                "doclet.noInheritedDoc", message);
         }
         return replacement;
     }
@@ -146,14 +158,14 @@
      * to the generated page.
      * @param tag the <code>Tag</code> representation of this custom tag.
      * @param tagletWriter the taglet writer for output.
-     * @return the TagletOutput representation of this <code>Tag</code>.
+     * @return the Content representation of this <code>Tag</code>.
      */
-    public TagletOutput getTagletOutput(Tag tag, TagletWriter tagletWriter) {
-        if (! (tag.holder() instanceof MethodDoc)) {
+    public Content getTagletOutput(Tag tag, TagletWriter tagletWriter) {
+        if (! (tag.holder() instanceof ProgramElementDoc)) {
             return tagletWriter.getOutputInstance();
         }
         return tag.name().equals("@inheritDoc") ?
-                retrieveInheritedDocumentation(tagletWriter, (MethodDoc) tag.holder(), null, tagletWriter.isFirstSentence) :
-                retrieveInheritedDocumentation(tagletWriter, (MethodDoc) tag.holder(), tag, tagletWriter.isFirstSentence);
+                retrieveInheritedDocumentation(tagletWriter, (ProgramElementDoc) tag.holder(), null, tagletWriter.isFirstSentence) :
+                retrieveInheritedDocumentation(tagletWriter, (ProgramElementDoc) tag.holder(), tag, tagletWriter.isFirstSentence);
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LegacyTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LegacyTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.RawHtml;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * This taglet acts as a wrapper to enable
@@ -115,20 +117,20 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Tag tag, TagletWriter writer)
+    public Content getTagletOutput(Tag tag, TagletWriter writer)
             throws IllegalArgumentException {
-        TagletOutput output = writer.getOutputInstance();
-        output.setOutput(legacyTaglet.toString(tag));
+        Content output = writer.getOutputInstance();
+        output.addContent(new RawHtml(legacyTaglet.toString(tag)));
         return output;
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Doc holder, TagletWriter writer)
+    public Content getTagletOutput(Doc holder, TagletWriter writer)
             throws IllegalArgumentException {
-        TagletOutput output = writer.getOutputInstance();
-        output.setOutput(legacyTaglet.toString(holder.tags(getName())));
+        Content output = writer.getOutputInstance();
+        output.addContent(new RawHtml(legacyTaglet.toString(holder.tags(getName()))));
         return output;
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -25,8 +25,9 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import java.util.Map;
+
 import com.sun.javadoc.Tag;
-import com.sun.tools.doclets.Taglet;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 
 /**
@@ -47,60 +48,23 @@
  * @since 1.5
  */
 
-public class LiteralTaglet implements Taglet {
+public class LiteralTaglet extends BaseInlineTaglet {
 
     private static final String NAME = "literal";
 
-    public static void register(Map<String,Taglet> map) {
-           map.remove(NAME);
-           map.put(NAME, new LiteralTaglet());
+    public static void register(Map<String, Taglet> map) {
+        map.remove(NAME);
+        map.put(NAME, new LiteralTaglet());
     }
 
     public String getName() {
         return NAME;
     }
 
-    public String toString(Tag tag) {
-        return textToString(tag.text());
-    }
-
-    public String toString(Tag[] tags) { return null; }
-
-    public boolean inField() { return false; }
-
-    public boolean inConstructor() { return false; }
-
-    public boolean inMethod() { return false; }
-
-    public boolean inOverview() { return false; }
-
-    public boolean inPackage() { return false; }
-
-    public boolean inType() { return false; }
-
-    public boolean isInlineTag() { return true; }
-
-    /*
-     * Replace occurrences of the following characters:  < > &
+    /**
+     * {@inheritDoc}
      */
-    protected static String textToString(String text) {
-           StringBuilder buf = new StringBuilder();
-           for (int i = 0; i < text.length(); i++) {
-               char c = text.charAt(i);
-               switch (c) {
-                   case '<':
-                          buf.append("&lt;");
-                          break;
-                   case '>':
-                          buf.append("&gt;");
-                          break;
-                   case '&':
-                          buf.append("&amp;");
-                          break;
-                   default:
-                          buf.append(c);
-               }
-           }
-           return buf.toString();
+    public Content getTagletOutput(Tag tag, TagletWriter writer) {
+        return writer.literalTagOutput(tag);
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, 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
@@ -28,6 +28,7 @@
 import java.util.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
@@ -101,14 +102,14 @@
             }
         }
         ParamTag[] tags = input.isTypeVariableParamTag ?
-            input.method.typeParamTags() : input.method.paramTags();
+            ((MethodDoc)input.element).typeParamTags() : ((MethodDoc)input.element).paramTags();
         Map<String, String> rankMap = getRankMap(input.isTypeVariableParamTag ?
-            (Object[]) input.method.typeParameters() :
-            (Object[]) input.method.parameters());
+            (Object[]) ((MethodDoc)input.element).typeParameters() :
+            (Object[]) ((MethodDoc)input.element).parameters());
         for (int i = 0; i < tags.length; i++) {
             if (rankMap.containsKey(tags[i].parameterName()) &&
                     rankMap.get(tags[i].parameterName()).equals((input.tagId))) {
-                output.holder = input.method;
+                output.holder = input.element;
                 output.holderTag = tags[i];
                 output.inlineTags = input.isFirstSentence ?
                     tags[i].firstSentenceTags() : tags[i].inlineTags();
@@ -165,12 +166,12 @@
      * @param writer the TagletWriter that will write this tag.
      * @return the TagletOutput representation of these <code>ParamTag</code>s.
      */
-    public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
+    public Content getTagletOutput(Doc holder, TagletWriter writer) {
         if (holder instanceof ExecutableMemberDoc) {
             ExecutableMemberDoc member = (ExecutableMemberDoc) holder;
-            TagletOutput output = getTagletOutput(false, member, writer,
+            Content output = getTagletOutput(false, member, writer,
                 member.typeParameters(), member.typeParamTags());
-            output.appendOutput(getTagletOutput(true, member, writer,
+            output.addContent(getTagletOutput(true, member, writer,
                 member.parameters(), member.paramTags()));
             return output;
         } else {
@@ -191,12 +192,12 @@
      *
      * @return the TagletOutput representation of these <code>ParamTag</code>s.
      */
-    private TagletOutput getTagletOutput(boolean isNonTypeParams, Doc holder,
+    private Content getTagletOutput(boolean isNonTypeParams, Doc holder,
             TagletWriter writer, Object[] formalParameters, ParamTag[] paramTags) {
-        TagletOutput result = writer.getOutputInstance();
+        Content result = writer.getOutputInstance();
         Set<String> alreadyDocumented = new HashSet<String>();
         if (paramTags.length > 0) {
-            result.appendOutput(
+            result.addContent(
                 processParamTags(isNonTypeParams, paramTags,
                 getRankMap(formalParameters), writer, alreadyDocumented)
             );
@@ -204,7 +205,7 @@
         if (alreadyDocumented.size() != formalParameters.length) {
             //Some parameters are missing corresponding @param tags.
             //Try to inherit them.
-            result.appendOutput(getInheritedTagletOutput (isNonTypeParams, holder,
+            result.addContent(getInheritedTagletOutput (isNonTypeParams, holder,
                 writer, formalParameters, alreadyDocumented));
         }
         return result;
@@ -214,10 +215,10 @@
      * Loop through each indivitual parameter.  It it does not have a
      * corresponding param tag, try to inherit it.
      */
-    private TagletOutput getInheritedTagletOutput(boolean isNonTypeParams, Doc holder,
+    private Content getInheritedTagletOutput(boolean isNonTypeParams, Doc holder,
             TagletWriter writer, Object[] formalParameters,
             Set<String> alreadyDocumented) {
-        TagletOutput result = writer.getOutputInstance();
+        Content result = writer.getOutputInstance();
         if ((! alreadyDocumented.contains(null)) &&
                 holder instanceof MethodDoc) {
             for (int i = 0; i < formalParameters.length; i++) {
@@ -231,7 +232,7 @@
                         String.valueOf(i), ! isNonTypeParams));
                 if (inheritedDoc.inlineTags != null &&
                         inheritedDoc.inlineTags.length > 0) {
-                    result.appendOutput(
+                    result.addContent(
                         processParamTag(isNonTypeParams, writer,
                             (ParamTag) inheritedDoc.holderTag,
                             isNonTypeParams ?
@@ -261,12 +262,12 @@
      *                of a rank of a parameter to its name.  This is
      *                used to ensure that the right name is used
      *                when parameter documentation is inherited.
-     * @return the TagletOutput representation of this <code>Tag</code>.
+     * @return the Content representation of this <code>Tag</code>.
      */
-    private TagletOutput processParamTags(boolean isNonTypeParams,
+    private Content processParamTags(boolean isNonTypeParams,
             ParamTag[] paramTags, Map<String, String> rankMap, TagletWriter writer,
             Set<String> alreadyDocumented) {
-        TagletOutput result = writer.getOutputInstance();
+        Content result = writer.getOutputInstance();
         if (paramTags.length > 0) {
             for (int i = 0; i < paramTags.length; ++i) {
                 ParamTag pt = paramTags[i];
@@ -287,7 +288,7 @@
                            "doclet.Type_Parameters_dup_warn",
                        paramName);
                 }
-                result.appendOutput(processParamTag(isNonTypeParams, writer, pt,
+                result.addContent(processParamTag(isNonTypeParams, writer, pt,
                      pt.parameterName(), alreadyDocumented.size() == 0));
                 alreadyDocumented.add(rank);
             }
@@ -295,7 +296,7 @@
         return result;
     }
     /**
-     * Convert the individual ParamTag into TagletOutput.
+     * Convert the individual ParamTag into Content.
      *
      * @param isNonTypeParams true if this is just a regular param tag.  False
      *                        if this is a type param tag.
@@ -307,16 +308,16 @@
      * @param isFirstParam    true if this is the first param tag being printed.
      *
      */
-    private TagletOutput processParamTag(boolean isNonTypeParams,
+    private Content processParamTag(boolean isNonTypeParams,
             TagletWriter writer, ParamTag paramTag, String name,
             boolean isFirstParam) {
-        TagletOutput result = writer.getOutputInstance();
+        Content result = writer.getOutputInstance();
         String header = writer.configuration().getText(
             isNonTypeParams ? "doclet.Parameters" : "doclet.TypeParameters");
         if (isFirstParam) {
-            result.appendOutput(writer.getParamHeader(header));
+            result.addContent(writer.getParamHeader(header));
         }
-        result.appendOutput(writer.paramTagOutput(paramTag,
+        result.addContent(writer.paramTagOutput(paramTag,
             name));
         return result;
     }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
@@ -50,9 +51,9 @@
      * {@inheritDoc}
      */
     public void inherit(DocFinder.Input input, DocFinder.Output output) {
-       Tag[] tags = input.method.tags("return");
+       Tag[] tags = input.element.tags("return");
         if (tags.length > 0) {
-            output.holder = input.method;
+            output.holder = input.element;
             output.holderTag = tags[0];
             output.inlineTags = input.isFirstSentence ?
                 tags[0].firstSentenceTags() : tags[0].inlineTags();
@@ -73,7 +74,7 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
+    public Content getTagletOutput(Doc holder, TagletWriter writer) {
         Type returnType = ((MethodDoc) holder).returnType();
         Tag[] tags = holder.tags(name);
 
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
@@ -49,9 +50,9 @@
      * {@inheritDoc}
      */
     public void inherit(DocFinder.Input input, DocFinder.Output output) {
-        Tag[] tags = input.method.seeTags();
+        Tag[] tags = input.element.seeTags();
         if (tags.length > 0) {
-            output.holder = input.method;
+            output.holder = input.element;
             output.holderTag = tags[0];
             output.inlineTags = input.isFirstSentence ?
                 tags[0].firstSentenceTags() : tags[0].inlineTags();
@@ -61,7 +62,7 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
+    public Content getTagletOutput(Doc holder, TagletWriter writer) {
         SeeTag[] tags = holder.seeTags();
         if (tags.length == 0 && holder instanceof MethodDoc) {
             DocFinder.Output inheritedDoc =
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
+import com.sun.tools.doclets.internal.toolkit.util.DocFinder;
 
 /**
  * A simple single argument custom tag.
@@ -38,7 +40,7 @@
  * @author Jamie Ho
  */
 
-public class SimpleTaglet extends BaseTaglet {
+public class SimpleTaglet extends BaseTaglet implements InheritableTaglet {
 
     /**
      * The marker in the location string for excluded tags.
@@ -199,17 +201,28 @@
         return false;
     }
 
+    @Override
+    public void inherit(DocFinder.Input input, DocFinder.Output output) {
+        Tag[] tags = input.element.tags(tagName);
+        if (tags.length > 0) {
+            output.holder = input.element;
+            output.holderTag = tags[0];
+            output.inlineTags = input.isFirstSentence
+                    ? tags[0].firstSentenceTags() : tags[0].inlineTags();
+        }
+    }
+
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
+    public Content getTagletOutput(Tag tag, TagletWriter writer) {
         return header == null || tag == null ? null : writer.simpleTagOutput(tag, header);
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
+    public Content getTagletOutput(Doc holder, TagletWriter writer) {
         if (header == null || holder.tags(getName()).length == 0) {
             return null;
         }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/Taglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/Taglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * The interface for a custom tag used by Doclets. A custom
@@ -132,14 +133,14 @@
 
     /**
      * Given the <code>Tag</code> representation of this custom
-     * tag, return its TagletOutput representation, which is output
+     * tag, return its Content representation, which is output
      * to the generated page.
      * @param tag the <code>Tag</code> representation of this custom tag.
      * @param writer a {@link TagletWriter} Taglet writer.
      * @throws IllegalArgumentException thrown when the method is not supported by the taglet.
-     * @return the TagletOutput representation of this <code>Tag</code>.
+     * @return the Content representation of this <code>Tag</code>.
      */
-    public abstract TagletOutput getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException;
+    public abstract Content getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException;
 
     /**
      * Given a <code>Doc</code> object, check if it holds any tags of
@@ -150,6 +151,8 @@
      * @throws IllegalArgumentException thrown when the method is not supported by the taglet.
      * @return the TagletOutput representation of this <code>Tag</code>.
      */
-    public abstract TagletOutput getTagletOutput(Doc holder, TagletWriter writer) throws IllegalArgumentException;
+    public abstract Content getTagletOutput(Doc holder, TagletWriter writer) throws IllegalArgumentException;
 
+    @Override
+    public abstract String toString();
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java	Fri May 17 10:13:34 2013 -0700
@@ -158,8 +158,7 @@
 
     /**
      * True if we want to use JavaFX-related tags (@propertyGetter,
-     * @propertySetter, @propertyDescription, @defaultValue, @treatAsPrivate,
-     * @expert).
+     * @propertySetter, @propertyDescription, @defaultValue, @treatAsPrivate).
      */
     private boolean javafx;
 
@@ -184,7 +183,7 @@
         this.showauthor = showauthor;
         this.javafx = javafx;
         this.message = message;
-        initStandardTags();
+        initStandardTaglets();
         initStandardTagsLowercase();
     }
 
@@ -454,9 +453,9 @@
      * @return the array of <code>Taglet</code>s that can
      * appear in packages.
      */
-    public Taglet[] getPackageCustomTags() {
+    public Taglet[] getPackageCustomTaglets() {
         if (packageTags == null) {
-            initCustomTagArrays();
+            initCustomTagletArrays();
         }
         return packageTags;
     }
@@ -467,9 +466,9 @@
      * @return the array of <code>Taglet</code>s that can
      * appear in classes or interfaces.
      */
-    public Taglet[] getTypeCustomTags() {
+    public Taglet[] getTypeCustomTaglets() {
         if (typeTags == null) {
-            initCustomTagArrays();
+            initCustomTagletArrays();
         }
         return typeTags;
     }
@@ -480,9 +479,9 @@
      * @return the array of <code>Taglet</code>s that can
      * appear in comments.
      */
-    public Taglet[] getInlineCustomTags() {
+    public Taglet[] getInlineCustomTaglets() {
         if (inlineTags == null) {
-            initCustomTagArrays();
+            initCustomTagletArrays();
         }
         return inlineTags;
     }
@@ -493,9 +492,9 @@
      * @return the array of <code>Taglet</code>s that can
      * appear in field.
      */
-    public Taglet[] getFieldCustomTags() {
+    public Taglet[] getFieldCustomTaglets() {
         if (fieldTags == null) {
-            initCustomTagArrays();
+            initCustomTagletArrays();
         }
         return fieldTags;
     }
@@ -506,9 +505,9 @@
      * @return the array of <code>Taglet</code>s that can
      * appear in the serialized form.
      */
-    public Taglet[] getSerializedFormTags() {
+    public Taglet[] getSerializedFormTaglets() {
         if (serializedFormTags == null) {
-            initCustomTagArrays();
+            initCustomTagletArrays();
         }
         return serializedFormTags;
     }
@@ -517,19 +516,19 @@
      * @return the array of <code>Taglet</code>s that can
      * appear in the given Doc.
      */
-    public Taglet[] getCustomTags(Doc doc) {
+    public Taglet[] getCustomTaglets(Doc doc) {
         if (doc instanceof ConstructorDoc) {
-            return getConstructorCustomTags();
+            return getConstructorCustomTaglets();
         } else if (doc instanceof MethodDoc) {
-            return getMethodCustomTags();
+            return getMethodCustomTaglets();
         } else if (doc instanceof FieldDoc) {
-            return getFieldCustomTags();
+            return getFieldCustomTaglets();
         } else if (doc instanceof ClassDoc) {
-            return getTypeCustomTags();
+            return getTypeCustomTaglets();
         } else if (doc instanceof PackageDoc) {
-            return getPackageCustomTags();
+            return getPackageCustomTaglets();
         } else if (doc instanceof RootDoc) {
-            return getOverviewCustomTags();
+            return getOverviewCustomTaglets();
         }
         return null;
     }
@@ -540,9 +539,9 @@
      * @return the array of <code>Taglet</code>s that can
      * appear in constructors.
      */
-    public Taglet[] getConstructorCustomTags() {
+    public Taglet[] getConstructorCustomTaglets() {
         if (constructorTags == null) {
-            initCustomTagArrays();
+            initCustomTagletArrays();
         }
         return constructorTags;
     }
@@ -553,9 +552,9 @@
      * @return the array of <code>Taglet</code>s that can
      * appear in methods.
      */
-    public Taglet[] getMethodCustomTags() {
+    public Taglet[] getMethodCustomTaglets() {
         if (methodTags == null) {
-            initCustomTagArrays();
+            initCustomTagletArrays();
         }
         return methodTags;
     }
@@ -566,9 +565,9 @@
      * @return the array of <code>Taglet</code>s that can
      * appear in overview.
      */
-    public Taglet[] getOverviewCustomTags() {
+    public Taglet[] getOverviewCustomTaglets() {
         if (overviewTags == null) {
-            initCustomTagArrays();
+            initCustomTagletArrays();
         }
         return overviewTags;
     }
@@ -576,7 +575,7 @@
     /**
      * Initialize the custom tag arrays.
      */
-    private void initCustomTagArrays() {
+    private void initCustomTagletArrays() {
         Iterator<Taglet> it = customTags.values().iterator();
         ArrayList<Taglet> pTags = new ArrayList<Taglet>(customTags.size());
         ArrayList<Taglet> tTags = new ArrayList<Taglet>(customTags.size());
@@ -631,88 +630,72 @@
     /**
      * Initialize standard Javadoc tags for ordering purposes.
      */
-    private void initStandardTags() {
+    private void initStandardTaglets() {
         Taglet temp;
-        customTags.put((temp = new ParamTaglet()).getName(), temp);
-        customTags.put((temp = new ReturnTaglet()).getName(), temp);
-        customTags.put((temp = new ThrowsTaglet()).getName(), temp);
-        customTags.put((temp = new SimpleTaglet("exception",
-            null, SimpleTaglet.METHOD + SimpleTaglet.CONSTRUCTOR)).getName(), temp);
-        if (!nosince) {
-            customTags.put((temp = new SimpleTaglet("since", message.getText("doclet.Since"),
-               SimpleTaglet.ALL)).getName(), temp);
-        }
-        if (showversion) {
-            customTags.put((temp = new SimpleTaglet("version", message.getText("doclet.Version"),
-                SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)).getName(), temp);
-        }
-        if (showauthor) {
-            customTags.put((temp = new SimpleTaglet("author", message.getText("doclet.Author"),
-                SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)).getName(), temp);
-        }
-        customTags.put((temp = new SimpleTaglet("serialData", message.getText("doclet.SerialData"),
-            SimpleTaglet.EXCLUDED)).getName(), temp);
+        addStandardTaglet(new ParamTaglet());
+        addStandardTaglet(new ReturnTaglet());
+        addStandardTaglet(new ThrowsTaglet());
+        addStandardTaglet(new SimpleTaglet("exception", null,
+                SimpleTaglet.METHOD + SimpleTaglet.CONSTRUCTOR));
+        addStandardTaglet(!nosince, new SimpleTaglet("since", message.getText("doclet.Since"),
+               SimpleTaglet.ALL));
+        addStandardTaglet(showversion, new SimpleTaglet("version", message.getText("doclet.Version"),
+                SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
+        addStandardTaglet(showauthor, new SimpleTaglet("author", message.getText("doclet.Author"),
+                SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
+        addStandardTaglet(new SimpleTaglet("serialData", message.getText("doclet.SerialData"),
+            SimpleTaglet.EXCLUDED));
         customTags.put((temp = new SimpleTaglet("factory", message.getText("doclet.Factory"),
             SimpleTaglet.METHOD)).getName(), temp);
-        customTags.put((temp = new SeeTaglet()).getName(), temp);
+        addStandardTaglet(new SeeTaglet());
         //Standard inline tags
-        customTags.put((temp = new DocRootTaglet()).getName(), temp);
-        customTags.put((temp = new InheritDocTaglet()).getName(), temp);
-        customTags.put((temp = new ValueTaglet()).getName(), temp);
-        customTags.put((temp = new LegacyTaglet(new LiteralTaglet())).getName(),
-            temp);
-        customTags.put((temp = new LegacyTaglet(new CodeTaglet())).getName(),
-            temp);
+        addStandardTaglet(new DocRootTaglet());
+        addStandardTaglet(new InheritDocTaglet());
+        addStandardTaglet(new ValueTaglet());
+        addStandardTaglet(new LiteralTaglet());
+        addStandardTaglet(new CodeTaglet());
 
-        //Keep track of the names of standard tags for error
-        //checking purposes.
-        standardTags.add("param");
-        standardTags.add("return");
-        standardTags.add("throws");
-        standardTags.add("exception");
-        standardTags.add("since");
-        standardTags.add("version");
-        standardTags.add("author");
-        standardTags.add("see");
+        // 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("inheritDoc");
-        standardTags.add("docRoot");
-        standardTags.add("value");
         standardTags.add("serial");
-        standardTags.add("serialData");
         standardTags.add("serialField");
         standardTags.add("Text");
-        standardTags.add("literal");
-        standardTags.add("code");
 
         if (javafx) {
-            initJavaFXTags();
+            initJavaFXTaglets();
         }
     }
 
     /**
      * Initialize JavaFX-related tags.
      */
-    private void initJavaFXTags() {
-        Taglet temp;
-        customTags.put((temp = new PropertyGetterTaglet()).getName(), temp);
-        customTags.put((temp = new PropertySetterTaglet()).getName(), temp);
-        customTags.put((temp = new SimpleTaglet("propertyDescription", message.getText("doclet.PropertyDescription"),
-            SimpleTaglet.FIELD + SimpleTaglet.METHOD)).getName(), temp);
-        customTags.put((temp = new SimpleTaglet("defaultValue", message.getText("doclet.DefaultValue"),
-            SimpleTaglet.FIELD + SimpleTaglet.METHOD)).getName(), temp);
-        customTags.put((temp = new SimpleTaglet("treatAsPrivate", null,
-                SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE)).getName(), temp);
-        customTags.put((temp = new LegacyTaglet(new ExpertTaglet())).getName(), temp);
+    private void initJavaFXTaglets() {
+        addStandardTaglet(new PropertyGetterTaglet());
+        addStandardTaglet(new PropertySetterTaglet());
+        addStandardTaglet(new SimpleTaglet("propertyDescription",
+                message.getText("doclet.PropertyDescription"),
+                SimpleTaglet.FIELD + SimpleTaglet.METHOD));
+        addStandardTaglet(new SimpleTaglet("defaultValue", message.getText("doclet.DefaultValue"),
+            SimpleTaglet.FIELD + SimpleTaglet.METHOD));
+        addStandardTaglet(new SimpleTaglet("treatAsPrivate", null,
+                SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE));
+    }
 
-        standardTags.add("propertyGetter");
-        standardTags.add("propertySetter");
-        standardTags.add("propertyDescription");
-        standardTags.add("defaultValue");
-        standardTags.add("treatAsPrivate");
-        standardTags.add("expert");
+    void addStandardTaglet(Taglet taglet) {
+        String name = taglet.getName();
+        customTags.put(name, taglet);
+        standardTags.add(name);
+    }
+
+    void addStandardTaglet(boolean enable, Taglet taglet) {
+        String name = taglet.getName();
+        if (enable)
+            customTags.put(name, taglet);
+        standardTags.add(name);
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletOutput.java	Thu May 16 12:16:07 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.doclets.internal.toolkit.taglets;
-
-/**
- * The interface for taglet output.  This interface is needed because
- * different doclets work with different formats of output.  A single taglet can
- * work with any doclet that provides an implementation of taglet output.
- *
- *  <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.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- * @author Jamie Ho
- * @since 1.5
- */
-public interface TagletOutput {
-
-    /**
-     * Set the output for the taglet.
-     * @param o an object representing the output.
-     */
-    public abstract void setOutput(Object o);
-
-    /**
-     * Append the given output to this output.
-     * @param o a TagletOutput representing the output.
-     */
-    public abstract void appendOutput(TagletOutput o);
-
-    /**
-     * Return true if this output has any occurances of @inheritDoc.
-     * @return true if inheritDoc tag is found.
-     */
-    public abstract boolean hasInheritDocTag();
-}
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -53,15 +53,23 @@
     }
 
     /**
-     * @return an instance of the output object.
+     * @return an instance of an output object.
      */
-    public abstract TagletOutput getOutputInstance();
+    public abstract Content getOutputInstance();
+
+    /**
+     * Return the output for a {@code...} tag.
+     *
+     * @param tag the tag.
+     * @return the output of the taglet.
+     */
+    protected abstract Content codeTagOutput(Tag tag);
 
     /**
      * Returns the output for the DocRoot inline tag.
      * @return the output for the DocRoot inline tag.
      */
-    protected abstract TagletOutput getDocRootOutput();
+    protected abstract Content getDocRootOutput();
 
     /**
      * Return the deprecated tag output.
@@ -69,7 +77,15 @@
      * @param doc the doc to write deprecated documentation for.
      * @return the output of the deprecated tag.
      */
-    protected abstract TagletOutput deprecatedTagOutput(Doc doc);
+    protected abstract Content deprecatedTagOutput(Doc doc);
+
+    /**
+     * Return the output for a {@literal...} tag.
+     *
+     * @param tag the tag.
+     * @return the output of the taglet.
+     */
+    protected abstract Content literalTagOutput(Tag tag);
 
     /**
      * Returns {@link MessageRetriever} for output purposes.
@@ -84,7 +100,7 @@
      * @param header the header to display.
      * @return the header for the param tags.
      */
-    protected abstract TagletOutput getParamHeader(String header);
+    protected abstract Content getParamHeader(String header);
 
     /**
      * Return the output for param tags.
@@ -93,16 +109,25 @@
      * @param paramName the name of the parameter.
      * @return the output of the param tag.
      */
-    protected abstract TagletOutput paramTagOutput(ParamTag paramTag,
+    protected abstract Content paramTagOutput(ParamTag paramTag,
         String paramName);
 
     /**
+     * Return the output for property tags.
+     *
+     * @param propertyTag the parameter to document.
+     * @param prefix the text with which to prefix the property name.
+     * @return the output of the param tag.
+     */
+    protected abstract Content propertyTagOutput(Tag propertyTag, String prefix);
+
+    /**
      * Return the return tag output.
      *
      * @param returnTag the return tag to output.
      * @return the output of the return tag.
      */
-    protected abstract TagletOutput returnTagOutput(Tag returnTag);
+    protected abstract Content returnTagOutput(Tag returnTag);
 
     /**
      * Return the see tag output.
@@ -110,7 +135,7 @@
      * @param seeTags the array of See tags.
      * @return the output of the see tags.
      */
-    protected abstract TagletOutput seeTagOutput(Doc holder, SeeTag[] seeTags);
+    protected abstract Content seeTagOutput(Doc holder, SeeTag[] seeTags);
 
     /**
      * Return the output for a simple tag.
@@ -118,7 +143,7 @@
      * @param simpleTags the array of simple tags.
      * @return the output of the simple tags.
      */
-    protected abstract TagletOutput simpleTagOutput(Tag[] simpleTags,
+    protected abstract Content simpleTagOutput(Tag[] simpleTags,
         String header);
 
     /**
@@ -127,14 +152,14 @@
      * @param simpleTag the simple tag.
      * @return the output of the simple tag.
      */
-    protected abstract TagletOutput simpleTagOutput(Tag simpleTag, String header);
+    protected abstract Content simpleTagOutput(Tag simpleTag, String header);
 
     /**
      * Return the header for the throws tag.
      *
      * @return the header for the throws tag.
      */
-    protected abstract TagletOutput getThrowsHeader();
+    protected abstract Content getThrowsHeader();
 
     /**
      * Return the header for the throws tag.
@@ -142,7 +167,7 @@
      * @param throwsTag the throws tag.
      * @return the output of the throws tag.
      */
-    protected abstract TagletOutput throwsTagOutput(ThrowsTag throwsTag);
+    protected abstract Content throwsTagOutput(ThrowsTag throwsTag);
 
     /**
      * Return the output for the throws tag.
@@ -150,7 +175,7 @@
      * @param throwsType the throws type.
      * @return the output of the throws type.
      */
-    protected abstract TagletOutput throwsTagOutput(Type throwsType);
+    protected abstract Content throwsTagOutput(Type throwsType);
 
     /**
      * Return the output for the value tag.
@@ -161,7 +186,7 @@
      *                    constant field itself.
      * @return the output of the value tag.
      */
-    protected abstract TagletOutput valueTagOutput(FieldDoc field,
+    protected abstract Content valueTagOutput(FieldDoc field,
         String constantVal, boolean includeLink);
 
     /**
@@ -175,10 +200,10 @@
      * @param output the output buffer to store the output in.
      */
     public static void genTagOuput(TagletManager tagletManager, Doc doc,
-            Taglet[] taglets, TagletWriter writer, TagletOutput output) {
+            Taglet[] taglets, TagletWriter writer, Content output) {
         tagletManager.checkTags(doc, doc.tags(), false);
         tagletManager.checkTags(doc, doc.inlineTags(), true);
-        TagletOutput currentOutput = null;
+        Content currentOutput = null;
         for (int i = 0; i < taglets.length; i++) {
             currentOutput = null;
             if (doc instanceof ClassDoc && taglets[i] instanceof ParamTaglet) {
@@ -203,7 +228,7 @@
             }
             if (currentOutput != null) {
                 tagletManager.seenCustomTag(taglets[i].getName());
-                output.appendOutput(currentOutput);
+                output.addContent(currentOutput);
             }
         }
     }
@@ -217,16 +242,16 @@
      * @param tagletWriter The taglet writer to write the output.
      * @return The output of the inline tag.
      */
-    public static TagletOutput getInlineTagOuput(TagletManager tagletManager,
+    public static Content getInlineTagOuput(TagletManager tagletManager,
             Tag holderTag, Tag inlineTag, TagletWriter tagletWriter) {
-        Taglet[] definedTags = tagletManager.getInlineCustomTags();
+        Taglet[] definedTags = tagletManager.getInlineCustomTaglets();
         //This is a custom inline tag.
         for (int j = 0; j < definedTags.length; j++) {
             if (("@"+definedTags[j].getName()).equals(inlineTag.name())) {
                 //Given a name of a seen custom tag, remove it from the
                 // set of unseen custom tags.
                 tagletManager.seenCustomTag(definedTags[j].getName());
-                TagletOutput output = definedTags[j].getTagletOutput(
+                Content output = definedTags[j].getTagletOutput(
                     holderTag != null &&
                         definedTags[j].getName().equals("inheritDoc") ?
                             holderTag : inlineTag, tagletWriter);
@@ -245,9 +270,9 @@
      * @param holderTag the tag that holds the documentation.
      * @param tags   array of text tags and inline tags (often alternating)
      *               present in the text of interest for this doc.
-     * @return the {@link TagletOutput} representing the comments.
+     * @return the {@link Content} representing the comments.
      */
-    public abstract TagletOutput commentTagsToOutput(Tag holderTag, Tag[] tags);
+    public abstract Content commentTagsToOutput(Tag holderTag, Tag[] tags);
 
     /**
      * Converts inline tags and text to TagOutput, expanding the
@@ -258,9 +283,9 @@
      * @param holderDoc specific doc where comment resides.
      * @param tags   array of text tags and inline tags (often alternating)
      *               present in the text of interest for this doc.
-     * @return the {@link TagletOutput} representing the comments.
+     * @return the {@link Content} representing the comments.
      */
-    public abstract TagletOutput commentTagsToOutput(Doc holderDoc, Tag[] tags);
+    public abstract Content commentTagsToOutput(Doc holderDoc, Tag[] tags);
 
     /**
      * Converts inline tags and text to TagOutput, expanding the
@@ -273,18 +298,13 @@
      * @param tags   array of text tags and inline tags (often alternating)
      *               present in the text of interest for this doc.
      * @param isFirstSentence true if this is the first sentence.
-     * @return the {@link TagletOutput} representing the comments.
+     * @return the {@link Content} representing the comments.
      */
-    public abstract TagletOutput commentTagsToOutput(Tag holderTag,
+    public abstract Content commentTagsToOutput(Tag holderTag,
         Doc holderDoc, Tag[] tags, boolean isFirstSentence);
 
     /**
      * @return an instance of the configuration used for this doclet.
      */
     public abstract Configuration configuration();
-
-    /**
-     * @return an instance of the taglet output object.
-     */
-    public abstract TagletOutput getTagletOutputInstance();
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, 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
@@ -28,6 +28,7 @@
 import java.util.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
@@ -60,15 +61,15 @@
                 throwsTag.exceptionName() :
                 throwsTag.exception().qualifiedName();
         } else {
-            exception = input.method.containingClass().findClass(input.tagId);
+            exception = input.element.containingClass().findClass(input.tagId);
         }
 
-        ThrowsTag[] tags = input.method.throwsTags();
+        ThrowsTag[] tags = ((MethodDoc)input.element).throwsTags();
         for (int i = 0; i < tags.length; i++) {
             if (input.tagId.equals(tags[i].exceptionName()) ||
                 (tags[i].exception() != null &&
                     (input.tagId.equals(tags[i].exception().qualifiedName())))) {
-                output.holder = input.method;
+                output.holder = input.element;
                 output.holderTag = tags[i];
                 output.inlineTags = input.isFirstSentence ?
                     tags[i].firstSentenceTags() : tags[i].inlineTags();
@@ -83,10 +84,10 @@
     /**
      * Add links for exceptions that are declared but not documented.
      */
-    private TagletOutput linkToUndocumentedDeclaredExceptions(
+    private Content linkToUndocumentedDeclaredExceptions(
             Type[] declaredExceptionTypes, Set<String> alreadyDocumented,
             TagletWriter writer) {
-        TagletOutput result = writer.getOutputInstance();
+        Content result = writer.getOutputInstance();
         //Add links to the exceptions declared but not documented.
         for (int i = 0; i < declaredExceptionTypes.length; i++) {
             if (declaredExceptionTypes[i].asClassDoc() != null &&
@@ -95,9 +96,9 @@
                 ! alreadyDocumented.contains(
                     declaredExceptionTypes[i].asClassDoc().qualifiedName())) {
                 if (alreadyDocumented.size() == 0) {
-                    result.appendOutput(writer.getThrowsHeader());
+                    result.addContent(writer.getThrowsHeader());
                 }
-                result.appendOutput(writer.throwsTagOutput(declaredExceptionTypes[i]));
+                result.addContent(writer.throwsTagOutput(declaredExceptionTypes[i]));
                 alreadyDocumented.add(declaredExceptionTypes[i].asClassDoc().name());
             }
         }
@@ -108,10 +109,10 @@
      * Inherit throws documentation for exceptions that were declared but not
      * documented.
      */
-    private TagletOutput inheritThrowsDocumentation(Doc holder,
+    private Content inheritThrowsDocumentation(Doc holder,
             Type[] declaredExceptionTypes, Set<String> alreadyDocumented,
             TagletWriter writer) {
-        TagletOutput result = writer.getOutputInstance();
+        Content result = writer.getOutputInstance();
         if (holder instanceof MethodDoc) {
             Set<Tag> declaredExceptionTags = new LinkedHashSet<Tag>();
             for (int j = 0; j < declaredExceptionTypes.length; j++) {
@@ -125,7 +126,7 @@
                 }
                 declaredExceptionTags.addAll(inheritedDoc.tagList);
             }
-            result.appendOutput(throwsTagsOutput(
+            result.addContent(throwsTagsOutput(
                 declaredExceptionTags.toArray(new ThrowsTag[] {}),
                 writer, alreadyDocumented, false));
         }
@@ -135,18 +136,18 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
+    public Content getTagletOutput(Doc holder, TagletWriter writer) {
         ExecutableMemberDoc execHolder = (ExecutableMemberDoc) holder;
         ThrowsTag[] tags = execHolder.throwsTags();
-        TagletOutput result = writer.getOutputInstance();
+        Content result = writer.getOutputInstance();
         HashSet<String> alreadyDocumented = new HashSet<String>();
         if (tags.length > 0) {
-            result.appendOutput(throwsTagsOutput(
+            result.addContent(throwsTagsOutput(
                 execHolder.throwsTags(), writer, alreadyDocumented, true));
         }
-        result.appendOutput(inheritThrowsDocumentation(holder,
+        result.addContent(inheritThrowsDocumentation(holder,
             execHolder.thrownExceptionTypes(), alreadyDocumented, writer));
-        result.appendOutput(linkToUndocumentedDeclaredExceptions(
+        result.addContent(linkToUndocumentedDeclaredExceptions(
             execHolder.thrownExceptionTypes(), alreadyDocumented, writer));
         return result;
     }
@@ -160,11 +161,11 @@
      * @param alreadyDocumented the set of exceptions that have already
      *        been documented.
      * @param allowDups True if we allow duplicate throws tags to be documented.
-     * @return the TagletOutput representation of this <code>Tag</code>.
+     * @return the Content representation of this <code>Tag</code>.
      */
-    protected TagletOutput throwsTagsOutput(ThrowsTag[] throwTags,
+    protected Content throwsTagsOutput(ThrowsTag[] throwTags,
         TagletWriter writer, Set<String> alreadyDocumented, boolean allowDups) {
-        TagletOutput result = writer.getOutputInstance();
+        Content result = writer.getOutputInstance();
         if (throwTags.length > 0) {
             for (int i = 0; i < throwTags.length; ++i) {
                 ThrowsTag tt = throwTags[i];
@@ -174,9 +175,9 @@
                     continue;
                 }
                 if (alreadyDocumented.size() == 0) {
-                    result.appendOutput(writer.getThrowsHeader());
+                    result.addContent(writer.getThrowsHeader());
                 }
-                result.appendOutput(writer.throwsTagOutput(tt));
+                result.addContent(writer.throwsTagOutput(tt));
                 alreadyDocumented.add(cd != null ?
                     cd.qualifiedName() : tt.exceptionName());
             }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ValueTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ValueTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.Configuration;
+import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
@@ -160,7 +161,7 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
+    public Content getTagletOutput(Tag tag, TagletWriter writer) {
         FieldDoc field = getFieldDoc(
             writer.configuration(), tag, tag.text());
         if (field == null) {
@@ -169,7 +170,7 @@
                 "doclet.value_tag_invalid_reference", tag.text());
         } else if (field.constantValue() != null) {
             return writer.valueTagOutput(field,
-                Util.escapeHtmlChars(field.constantValueExpression()),
+                field.constantValueExpression(),
                 ! field.equals(tag.holder()));
         } else {
             //Referenced field is not a constant.
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -48,9 +48,9 @@
      */
     public static class Input {
         /**
-         * The method to search documentation from.
+         * The element to search documentation from.
          */
-        public MethodDoc method = null;
+        public ProgramElementDoc element;
         /**
          * The taglet to search for documentation on behalf of. Null if we want
          * to search for overall documentation.
@@ -84,54 +84,55 @@
          */
         public boolean isTypeVariableParamTag = false;
 
-        public Input() {}
-
-        public Input(MethodDoc method, InheritableTaglet taglet, Tag tag,
+        public Input(ProgramElementDoc element, InheritableTaglet taglet, Tag tag,
                 boolean isFirstSentence, boolean isInheritDocTag) {
-            this.method = method;
+            this(element);
             this.taglet = taglet;
             this.tag = tag;
             this.isFirstSentence = isFirstSentence;
             this.isInheritDocTag = isInheritDocTag;
         }
 
-        public Input(MethodDoc method, InheritableTaglet taglet, String tagId) {
-            this.method = method;
+        public Input(ProgramElementDoc element, InheritableTaglet taglet, String tagId) {
+            this(element);
             this.taglet = taglet;
             this.tagId = tagId;
         }
 
-        public Input(MethodDoc method, InheritableTaglet taglet, String tagId,
+        public Input(ProgramElementDoc element, InheritableTaglet taglet, String tagId,
             boolean isTypeVariableParamTag) {
-            this.method = method;
+            this(element);
             this.taglet = taglet;
             this.tagId = tagId;
             this.isTypeVariableParamTag = isTypeVariableParamTag;
         }
 
-        public Input(MethodDoc method, InheritableTaglet taglet) {
-            this.method = method;
+        public Input(ProgramElementDoc element, InheritableTaglet taglet) {
+            this(element);
             this.taglet = taglet;
         }
 
-        public Input(MethodDoc method) {
-            this.method = method;
+        public Input(ProgramElementDoc element) {
+            if (element == null)
+                throw new NullPointerException();
+            this.element = element;
         }
 
-        public Input(MethodDoc method, boolean isFirstSentence) {
-            this.method = method;
+        public Input(ProgramElementDoc element, boolean isFirstSentence) {
+            this(element);
             this.isFirstSentence = isFirstSentence;
         }
 
         public Input copy() {
-            Input clone = new Input();
-            clone.method = this.method;
+            Input clone = new Input(this.element);
             clone.taglet = this.taglet;
             clone.tagId = this.tagId;
             clone.tag = this.tag;
             clone.isFirstSentence = this.isFirstSentence;
             clone.isInheritDocTag = this.isInheritDocTag;
             clone.isTypeVariableParamTag = this.isTypeVariableParamTag;
+            if (clone.element == null)
+                throw new NullPointerException();
             return clone;
 
         }
@@ -164,8 +165,8 @@
 
         /**
          * When automatically inheriting throws tags, you sometime must inherit
-         * more than one tag.  For example if the method declares that it throws
-         * IOException and the overidden method has throws tags for IOException and
+         * more than one tag.  For example if the element declares that it throws
+         * IOException and the overridden element has throws tags for IOException and
          * ZipException, both tags would be inherited because ZipException is a
          * subclass of IOException.  This subclass of DocFinder.Output allows
          * multiple tag inheritence.
@@ -174,9 +175,9 @@
     }
 
     /**
-     * Search for the requested comments in the given method.  If it does not
-     * have comments, return documentation from the overriden method if possible.
-     * If the overriden method does not exist or does not have documentation to
+     * Search for the requested comments in the given element.  If it does not
+     * have comments, return documentation from the overriden element if possible.
+     * If the overriden element does not exist or does not have documentation to
      * inherit, search for documentation to inherit from implemented methods.
      *
      * @param input the input object used to perform the search.
@@ -186,14 +187,14 @@
     public static Output search(Input input) {
         Output output = new Output();
         if (input.isInheritDocTag) {
-            //Do nothing because "method" does not have any documentation.
+            //Do nothing because "element" does not have any documentation.
             //All it has it {@inheritDoc}.
         } else if (input.taglet == null) {
             //We want overall documentation.
             output.inlineTags = input.isFirstSentence ?
-                input.method.firstSentenceTags() :
-                input.method.inlineTags();
-            output.holder = input.method;
+                input.element.firstSentenceTags() :
+                input.element.inlineTags();
+            output.holder = input.element;
         } else {
             input.taglet.inherit(input, output);
         }
@@ -204,25 +205,38 @@
         output.isValidInheritDocTag = false;
         Input inheritedSearchInput = input.copy();
         inheritedSearchInput.isInheritDocTag = false;
-        if (input.method.overriddenMethod() != null) {
-            inheritedSearchInput.method = input.method.overriddenMethod();
-            output = search(inheritedSearchInput);
-            output.isValidInheritDocTag = true;
-            if (output != null && output.inlineTags.length > 0) {
-                return output;
+        if (input.element instanceof MethodDoc) {
+            MethodDoc overriddenMethod = ((MethodDoc) input.element).overriddenMethod();
+            if (overriddenMethod != null) {
+                inheritedSearchInput.element = overriddenMethod;
+                output = search(inheritedSearchInput);
+                output.isValidInheritDocTag = true;
+                if (output.inlineTags.length > 0) {
+                    return output;
+                }
             }
-        }
-        //NOTE:  When we fix the bug where ClassDoc.interfaceTypes() does
-        //       not pass all implemented interfaces, we will use the
-        //       appropriate method here.
-        MethodDoc[] implementedMethods =
-            (new ImplementedMethods(input.method, null)).build(false);
-        for (int i = 0; i < implementedMethods.length; i++) {
-            inheritedSearchInput.method = implementedMethods[i];
-            output = search(inheritedSearchInput);
-            output.isValidInheritDocTag = true;
-            if (output != null && output.inlineTags.length > 0) {
-                return output;
+            //NOTE:  When we fix the bug where ClassDoc.interfaceTypes() does
+            //       not pass all implemented interfaces, we will use the
+            //       appropriate element here.
+            MethodDoc[] implementedMethods =
+                (new ImplementedMethods((MethodDoc) input.element, null)).build(false);
+            for (int i = 0; i < implementedMethods.length; i++) {
+                inheritedSearchInput.element = implementedMethods[i];
+                output = search(inheritedSearchInput);
+                output.isValidInheritDocTag = true;
+                if (output.inlineTags.length > 0) {
+                    return output;
+                }
+            }
+        } else if (input.element instanceof ClassDoc) {
+            ProgramElementDoc superclass = ((ClassDoc) input.element).superclass();
+            if (superclass != null) {
+                inheritedSearchInput.element = superclass;
+                output = search(inheritedSearchInput);
+                output.isValidInheritDocTag = true;
+                if (output.inlineTags.length > 0) {
+                    return output;
+                }
             }
         }
         return output;
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -52,7 +52,7 @@
     /**
      * The default package name.
      */
-    public static final String DEFAULT_PACKAGE_NAME = "&lt;Unnamed&gt;";
+    public static final String DEFAULT_PACKAGE_NAME = "<Unnamed>";
 
     /**
      * The default package file name.
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Fri May 17 10:13:34 2013 -0700
@@ -420,69 +420,6 @@
     }
 
     /**
-     * Given a string, escape all special html characters and
-     * return the result.
-     *
-     * @param s The string to check.
-     * @return the original string with all of the HTML characters escaped.
-     */
-    public static String escapeHtmlChars(String s) {
-        for (int i = 0; i < s.length(); i++) {
-            char ch = s.charAt(i);
-            switch (ch) {
-                // only start building a new string if we need to
-                case '<': case '>': case '&':
-                    StringBuilder sb = new StringBuilder(s.substring(0, i));
-                    for ( ; i < s.length(); i++) {
-                        ch = s.charAt(i);
-                        switch (ch) {
-                            case '<': sb.append("&lt;");  break;
-                            case '>': sb.append("&gt;");  break;
-                            case '&': sb.append("&amp;"); break;
-                            default:  sb.append(ch);      break;
-                        }
-                    }
-                    return sb.toString();
-            }
-        }
-        return s;
-    }
-
-    /**
-     * Escape all special html characters in a string buffer.
-     *
-     * @param sb The string buffer to update
-     */
-    public static void escapeHtmlChars(StringBuilder sb) {
-        // scan backwards, replacing characters as needed.
-        for (int i = sb.length() - 1; i >= 0; i--) {
-            switch (sb.charAt(i)) {
-                case '<': sb.replace(i, i+1, "&lt;"); break;
-                case '>': sb.replace(i, i+1, "&gt;"); break;
-                case '&': sb.replace(i, i+1, "&amp;"); break;
-            }
-        }
-    }
-
-    /**
-     * Given a string, strips all html characters and
-     * return the result.
-     *
-     * @param rawString The string to check.
-     * @return the original string with all of the HTML characters
-     * stripped.
-     *
-     */
-    public static String stripHtml(String rawString) {
-        // remove HTML tags
-        rawString = rawString.replaceAll("\\<.*?>", " ");
-        // consolidate multiple spaces between a word to a single space
-        rawString = rawString.replaceAll("\\b\\s{2,}\\b", " ");
-        // remove extra whitespaces
-        return rawString.trim();
-    }
-
-    /**
      * Given an annotation, return true if it should be documented and false
      * otherwise.
      *
@@ -656,20 +593,42 @@
     }
 
     /**
-     * Replace all tabs with the appropriate number of spaces.
+     * Replace all tabs in a string with the appropriate number of spaces.
+     * The string may be a multi-line string.
      * @param configuration the doclet configuration defining the setting for the
      *                      tab length.
-     * @param sb the StringBuilder in which to replace the tabs
+     * @param text the text for which the tabs should be expanded
+     * @return the text with all tabs expanded
      */
-    public static void replaceTabs(Configuration configuration, StringBuilder sb) {
-        int tabLength = configuration.sourcetab;
-        String whitespace = configuration.tabSpaces;
-        int index = 0;
-        while ((index = sb.indexOf("\t", index)) != -1) {
-            int spaceCount = tabLength - index % tabLength;
-            sb.replace(index, index+1, whitespace.substring(0, spaceCount));
-            index += spaceCount;
+    public static String replaceTabs(Configuration configuration, String text) {
+        if (text.indexOf("\t") == -1)
+            return text;
+
+        final int tabLength = configuration.sourcetab;
+        final String whitespace = configuration.tabSpaces;
+        final int textLength = text.length();
+        StringBuilder result = new StringBuilder(textLength);
+        int pos = 0;
+        int lineLength = 0;
+        for (int i = 0; i < textLength; i++) {
+            char ch = text.charAt(i);
+            switch (ch) {
+                case '\n': case '\r':
+                    lineLength = 0;
+                    break;
+                case '\t':
+                    result.append(text, pos, i);
+                    int spaceCount = tabLength - lineLength % tabLength;
+                    result.append(whitespace, 0, spaceCount);
+                    lineLength += spaceCount;
+                    pos = i + 1;
+                    break;
+                default:
+                    lineLength++;
+            }
         }
+        result.append(text, pos, textLength);
+        return result.toString();
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java	Fri May 17 10:13:34 2013 -0700
@@ -26,6 +26,7 @@
 package com.sun.tools.doclets.internal.toolkit.util.links;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * A factory that constructs links from given link information.
@@ -41,11 +42,11 @@
 public abstract class LinkFactory {
 
     /**
-     * Return an empty instance of the link output object.
+     * Return an empty instance of a content object.
      *
-     * @return an empty instance of the link output object.
+     * @return an empty instance of a content object.
      */
-    protected abstract LinkOutput getOutputInstance();
+    protected abstract Content newContent();
 
     /**
      * Constructs a link from the given link information.
@@ -53,63 +54,59 @@
      * @param linkInfo the information about the link.
      * @return the output of the link.
      */
-    public LinkOutput getLinkOutput(LinkInfo linkInfo) {
+    public Content getLink(LinkInfo linkInfo) {
         if (linkInfo.type != null) {
             Type type = linkInfo.type;
-            LinkOutput linkOutput = getOutputInstance();
+            Content link = newContent();
             if (type.isPrimitive()) {
                 //Just a primitive.
-                linkInfo.displayLength += type.typeName().length();
-                linkOutput.append(type.typeName());
+                link.addContent(type.typeName());
             } else if (type.asAnnotatedType() != null && type.dimension().length() == 0) {
-                linkOutput.append(getTypeAnnotationLinks(linkInfo));
+                link.addContent(getTypeAnnotationLinks(linkInfo));
                 linkInfo.type = type.asAnnotatedType().underlyingType();
-                linkOutput.append(getLinkOutput(linkInfo));
-                return linkOutput;
+                link.addContent(getLink(linkInfo));
+                return link;
             } else if (type.asWildcardType() != null) {
                 //Wildcard type.
                 linkInfo.isTypeBound = true;
-                linkInfo.displayLength += 1;
-                linkOutput.append("?");
+                link.addContent("?");
                 WildcardType wildcardType = type.asWildcardType();
                 Type[] extendsBounds = wildcardType.extendsBounds();
                 for (int i = 0; i < extendsBounds.length; i++) {
-                    linkInfo.displayLength += i > 0 ? 2 : 9;
-                    linkOutput.append(i > 0 ? ", " : " extends ");
+                    link.addContent(i > 0 ? ", " : " extends ");
                     setBoundsLinkInfo(linkInfo, extendsBounds[i]);
-                    linkOutput.append(getLinkOutput(linkInfo));
+                    link.addContent(getLink(linkInfo));
                 }
                 Type[] superBounds = wildcardType.superBounds();
                 for (int i = 0; i < superBounds.length; i++) {
-                    linkInfo.displayLength += i > 0 ? 2 : 7;
-                    linkOutput.append(i > 0 ? ", " : " super ");
+                    link.addContent(i > 0 ? ", " : " super ");
                     setBoundsLinkInfo(linkInfo, superBounds[i]);
-                    linkOutput.append(getLinkOutput(linkInfo));
+                    link.addContent(getLink(linkInfo));
                 }
             } else if (type.asTypeVariable()!= null) {
-                linkOutput.append(getTypeAnnotationLinks(linkInfo));
+                link.addContent(getTypeAnnotationLinks(linkInfo));
                 linkInfo.isTypeBound = true;
                 //A type variable.
                 Doc owner = type.asTypeVariable().owner();
                 if ((! linkInfo.excludeTypeParameterLinks) &&
                         owner instanceof ClassDoc) {
                     linkInfo.classDoc = (ClassDoc) owner;
-                    linkInfo.label = type.typeName();
-                    linkOutput.append(getClassLink(linkInfo));
+                    Content label = newContent();
+                    label.addContent(type.typeName());
+                    linkInfo.label = label;
+                    link.addContent(getClassLink(linkInfo));
                 } else {
                     //No need to link method type parameters.
-                    linkInfo.displayLength += type.typeName().length();
-                    linkOutput.append(type.typeName());
+                    link.addContent(type.typeName());
                 }
 
                 Type[] bounds = type.asTypeVariable().bounds();
                 if (! linkInfo.excludeTypeBounds) {
                     linkInfo.excludeTypeBounds = true;
                     for (int i = 0; i < bounds.length; i++) {
-                        linkInfo.displayLength += i > 0 ? 2 : 9;
-                        linkOutput.append(i > 0 ? " & " : " extends ");
+                        link.addContent(i > 0 ? " & " : " extends ");
                         setBoundsLinkInfo(linkInfo, bounds[i]);
-                        linkOutput.append(getLinkOutput(linkInfo));
+                        link.addContent(getLink(linkInfo));
                     }
                 }
             } else if (type.asClassDoc() != null) {
@@ -118,15 +115,15 @@
                         linkInfo.excludeTypeBoundsLinks) {
                     //Since we are excluding type parameter links, we should not
                     //be linking to the type bound.
-                    linkInfo.displayLength += type.typeName().length();
-                    linkOutput.append(type.typeName());
-                    linkOutput.append(getTypeParameterLinks(linkInfo));
-                    return linkOutput;
+                    link.addContent(type.typeName());
+                    link.addContent(getTypeParameterLinks(linkInfo));
+                    return link;
                 } else {
                     linkInfo.classDoc = type.asClassDoc();
-                    linkOutput = getClassLink(linkInfo);
+                    link = newContent();
+                    link.addContent(getClassLink(linkInfo));
                     if (linkInfo.includeTypeAsSepLink) {
-                        linkOutput.append(getTypeParameterLinks(linkInfo, false));
+                        link.addContent(getTypeParameterLinks(linkInfo, false));
                     }
                 }
             }
@@ -135,36 +132,37 @@
                 if (type.dimension().length() > 2) {
                     //Javadoc returns var args as array.
                     //Strip out the first [] from the var arg.
-                    linkInfo.displayLength += type.dimension().length()-2;
-                    linkOutput.append(type.dimension().substring(2));
+                    link.addContent(type.dimension().substring(2));
                 }
-                linkInfo.displayLength += 3;
-                linkOutput.append("...");
+                link.addContent("...");
             } else {
                 while (type != null && type.dimension().length() > 0) {
-                    linkInfo.displayLength += type.dimension().length();
                     if (type.asAnnotatedType() != null) {
                         linkInfo.type = type;
-                        linkOutput.append(" ");
-                        linkOutput.append(getTypeAnnotationLinks(linkInfo));
-                        linkOutput.append("[]");
+                        link.addContent(" ");
+                        link.addContent(getTypeAnnotationLinks(linkInfo));
+                        link.addContent("[]");
                         type = type.asAnnotatedType().underlyingType().getElementType();
                     } else {
-                        linkOutput.append("[]");
+                        link.addContent("[]");
                         type = type.getElementType();
                     }
                 }
                 linkInfo.type = type;
-                linkOutput.insert(0, getTypeAnnotationLinks(linkInfo));
+                Content newLink = newContent();
+                newLink.addContent(getTypeAnnotationLinks(linkInfo));
+                newLink.addContent(link);
+                link = newLink;
             }
-            return linkOutput;
+            return link;
         } else if (linkInfo.classDoc != null) {
             //Just a class link
-            LinkOutput linkOutput = getClassLink(linkInfo);
+            Content link = newContent();
+            link.addContent(getClassLink(linkInfo));
             if (linkInfo.includeTypeAsSepLink) {
-                linkOutput.append(getTypeParameterLinks(linkInfo, false));
+                link.addContent(getTypeParameterLinks(linkInfo, false));
             }
-            return linkOutput;
+            return link;
         } else {
             return null;
         }
@@ -183,7 +181,7 @@
      *
      * @return the link for the given class.
      */
-    protected abstract LinkOutput getClassLink(LinkInfo linkInfo);
+    protected abstract Content getClassLink(LinkInfo linkInfo);
 
     /**
      * Return the link to the given type parameter.
@@ -191,10 +189,10 @@
      * @param linkInfo     the information about the link to construct.
      * @param typeParam the type parameter to link to.
      */
-    protected abstract LinkOutput getTypeParameterLink(LinkInfo linkInfo,
+    protected abstract Content getTypeParameterLink(LinkInfo linkInfo,
         Type typeParam);
 
-    protected abstract LinkOutput getTypeAnnotationLink(LinkInfo linkInfo,
+    protected abstract Content getTypeAnnotationLink(LinkInfo linkInfo,
             AnnotationDesc annotation);
 
     /**
@@ -203,7 +201,7 @@
      * @param linkInfo     the information about the link to construct.
      * @return the links to the type parameters.
      */
-    public LinkOutput getTypeParameterLinks(LinkInfo linkInfo) {
+    public Content getTypeParameterLinks(LinkInfo linkInfo) {
         return getTypeParameterLinks(linkInfo, true);
     }
 
@@ -215,8 +213,8 @@
      *                     the type parameters portion of the link.
      * @return the links to the type parameters.
      */
-    public LinkOutput getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel) {
-        LinkOutput output = getOutputInstance();
+    public Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel) {
+        Content links = newContent();
         Type[] vars;
         if (linkInfo.executableMemberDoc != null) {
             vars = linkInfo.executableMemberDoc.typeParameters();
@@ -227,62 +225,37 @@
             vars = linkInfo.classDoc.typeParameters();
         } else {
             //Nothing to document.
-            return output;
+            return links;
         }
         if (((linkInfo.includeTypeInClassLinkLabel && isClassLabel) ||
              (linkInfo.includeTypeAsSepLink && ! isClassLabel)
               )
             && vars.length > 0) {
-            linkInfo.displayLength += 1;
-            output.append(getLessThanString());
+            links.addContent("<");
             for (int i = 0; i < vars.length; i++) {
                 if (i > 0) {
-                    linkInfo.displayLength += 1;
-                    output.append(",");
+                    links.addContent(",");
                 }
-                output.append(getTypeParameterLink(linkInfo, vars[i]));
+                links.addContent(getTypeParameterLink(linkInfo, vars[i]));
             }
-            linkInfo.displayLength += 1;
-            output.append(getGreaterThanString());
+            links.addContent(">");
         }
-        return output;
+        return links;
     }
 
-    public LinkOutput getTypeAnnotationLinks(LinkInfo linkInfo) {
-        LinkOutput output = getOutputInstance();
+    public Content getTypeAnnotationLinks(LinkInfo linkInfo) {
+        Content links = newContent();
         if (linkInfo.type.asAnnotatedType() == null)
-            return output;
+            return links;
         AnnotationDesc[] annotations = linkInfo.type.asAnnotatedType().annotations();
         for (int i = 0; i < annotations.length; i++) {
             if (i > 0) {
-                linkInfo.displayLength += 1;
-                output.append(" ");
+                links.addContent(" ");
             }
-            output.append(getTypeAnnotationLink(linkInfo, annotations[i]));
+            links.addContent(getTypeAnnotationLink(linkInfo, annotations[i]));
         }
 
-        linkInfo.displayLength += 1;
-        output.append(" ");
-        return output;
-    }
-
-    /**
-     * Return &amp;lt;, which is used in type parameters.  Override this
-     * if your doclet uses something different.
-     *
-     * @return return &amp;lt;, which is used in type parameters.
-     */
-    protected String getLessThanString() {
-        return "&lt;";
-    }
-
-    /**
-     * Return &amp;gt;, which is used in type parameters.  Override this
-     * if your doclet uses something different.
-     *
-     * @return return &amp;gt;, which is used in type parameters.
-     */
-    protected String getGreaterThanString() {
-        return "&gt;";
+        links.addContent(" ");
+        return links;
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java	Fri May 17 10:13:34 2013 -0700
@@ -27,6 +27,7 @@
 
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.Configuration;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * Encapsulates information about a link.
@@ -77,7 +78,7 @@
     /**
      * The label for the link.
      */
-    public String label;
+    public Content label;
 
     /**
      * True if the link should be strong.
@@ -90,7 +91,7 @@
     public boolean includeTypeInClassLinkLabel = true;
 
     /**
-     * True if we should include the type as seperate link.  False otherwise.
+     * True if we should include the type as separate link.  False otherwise.
      */
     public boolean includeTypeAsSepLink = false;
 
@@ -116,24 +117,11 @@
     public boolean linkToSelf = true;
 
     /**
-     * The display length for the link.
-     */
-    public int displayLength = 0;
-
-    /**
-     * Return the id indicating where the link appears in the documentation.
-     * This is used for special processing of different types of links.
+     * Return an empty instance of a content object.
      *
-     * @return the id indicating where the link appears in the documentation.
+     * @return an empty instance of a content object.
      */
-    public abstract int getContext();
-
-    /**
-     * Set the context.
-     *
-     * @param c the context id to set.
-     */
-    public abstract void setContext(int c);
+    protected abstract Content newContent();
 
     /**
      * Return true if this link is linkable and false if we can't link to the
@@ -150,13 +138,17 @@
      * @param configuration the current configuration of the doclet.
      * @return the label for this class link.
      */
-    public String getClassLinkLabel(Configuration configuration) {
-        if (label != null && label.length() > 0) {
+    public Content getClassLinkLabel(Configuration configuration) {
+        if (label != null && !label.isEmpty()) {
             return label;
         } else if (isLinkable()) {
-            return classDoc.name();
+            Content label = newContent();
+            label.addContent(classDoc.name());
+            return label;
         } else {
-            return configuration.getClassName(classDoc);
+            Content label = newContent();
+            label.addContent(configuration.getClassName(classDoc));
+            return label;
         }
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclint/Checker.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclint/Checker.java	Fri May 17 10:13:34 2013 -0700
@@ -42,7 +42,6 @@
 import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.Name;
-import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.TypeKind;
 import javax.lang.model.type.TypeMirror;
 import javax.tools.Diagnostic.Kind;
@@ -70,7 +69,8 @@
 import com.sun.source.doctree.ThrowsTree;
 import com.sun.source.doctree.ValueTree;
 import com.sun.source.doctree.VersionTree;
-import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTreePath;
+import com.sun.source.util.DocTreePathScanner;
 import com.sun.source.util.TreePath;
 import com.sun.tools.doclint.HtmlTag.AttrKind;
 import com.sun.tools.javac.tree.DocPretty;
@@ -85,7 +85,7 @@
  * risk.  This code and its internal interfaces are subject to change
  * or deletion without notice.</b></p>
  */
-public class Checker extends DocTreeScanner<Void, Void> {
+public class Checker extends DocTreePathScanner<Void, Void> {
     final Env env;
 
     Set<Element> foundParams = new HashSet<Element>();
@@ -152,7 +152,7 @@
         foundInheritDoc = false;
         foundReturn = false;
 
-        scan(tree, (Void) null);
+        scan(new DocTreePath(p, tree), null);
 
         if (!isOverridingMethod) {
             switch (env.currElement.getKind()) {
@@ -620,47 +620,36 @@
     }
 
     @Override
+    @SuppressWarnings("fallthrough")
     public Void visitParam(ParamTree tree, Void ignore) {
         boolean typaram = tree.isTypeParameter();
         IdentifierTree nameTree = tree.getName();
-        Element e = env.currElement;
-        switch (e.getKind()) {
-            case METHOD: case CONSTRUCTOR: {
-                ExecutableElement ee = (ExecutableElement) e;
-                checkParamDeclared(nameTree, typaram ? ee.getTypeParameters() : ee.getParameters());
-                break;
-            }
+        Element paramElement = nameTree != null ? env.trees.getElement(new DocTreePath(getCurrentPath(), nameTree)) : null;
 
-            case CLASS: case INTERFACE: {
-                TypeElement te = (TypeElement) e;
-                if (typaram) {
-                    checkParamDeclared(nameTree, te.getTypeParameters());
-                } else {
-                    env.messages.error(REFERENCE, tree, "dc.invalid.param");
+        if (paramElement == null) {
+            switch (env.currElement.getKind()) {
+                case CLASS: case INTERFACE: {
+                    if (!typaram) {
+                        env.messages.error(REFERENCE, tree, "dc.invalid.param");
+                        break;
+                    }
                 }
-                break;
-            }
+                case METHOD: case CONSTRUCTOR: {
+                    env.messages.error(REFERENCE, nameTree, "dc.param.name.not.found");
+                    break;
+                }
 
-            default:
-                env.messages.error(REFERENCE, tree, "dc.invalid.param");
-                break;
+                default:
+                    env.messages.error(REFERENCE, tree, "dc.invalid.param");
+                    break;
+            }
+        } else {
+            foundParams.add(paramElement);
         }
+
         warnIfEmpty(tree, tree.getDescription());
         return super.visitParam(tree, ignore);
     }
-    // where
-    private void checkParamDeclared(IdentifierTree nameTree, List<? extends Element> list) {
-        Name name = nameTree.getName();
-        boolean found = false;
-        for (Element e: list) {
-            if (name.equals(e.getSimpleName())) {
-                foundParams.add(e);
-                found = true;
-            }
-        }
-        if (!found)
-            env.messages.error(REFERENCE, nameTree, "dc.param.name.not.found");
-    }
 
     private void checkParamsDocumented(List<? extends Element> list) {
         if (foundInheritDoc)
@@ -678,7 +667,7 @@
 
     @Override
     public Void visitReference(ReferenceTree tree, Void ignore) {
-        Element e = env.trees.getElement(env.currPath, tree);
+        Element e = env.trees.getElement(getCurrentPath());
         if (e == null)
             env.messages.error(REFERENCE, tree, "dc.ref.not.found");
         return super.visitReference(tree, ignore);
@@ -716,7 +705,7 @@
     @Override
     public Void visitThrows(ThrowsTree tree, Void ignore) {
         ReferenceTree exName = tree.getExceptionName();
-        Element ex = env.trees.getElement(env.currPath, exName);
+        Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName));
         if (ex == null) {
             env.messages.error(REFERENCE, tree, "dc.ref.not.found");
         } else if (ex.asType().getKind() == TypeKind.DECLARED
--- a/langtools/src/share/classes/com/sun/tools/doclint/Env.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclint/Env.java	Fri May 17 10:13:34 2013 -0700
@@ -29,6 +29,7 @@
 import java.util.Set;
 
 import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.Modifier;
 import javax.lang.model.type.TypeMirror;
@@ -144,7 +145,7 @@
         AccessKind ak = null;
         for (TreePath p = path; p != null; p = p.getParentPath()) {
             Element e = trees.getElement(p);
-            if (e != null) {
+            if (e != null && e.getKind() != ElementKind.PACKAGE) {
                 ak = min(ak, AccessKind.of(e.getModifiers()));
             }
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Fri May 17 10:13:34 2013 -0700
@@ -33,6 +33,7 @@
 import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.AnnotationValue;
 import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.DeclaredType;
@@ -44,12 +45,12 @@
 
 import com.sun.source.doctree.DocCommentTree;
 import com.sun.source.doctree.DocTree;
-import com.sun.source.doctree.ReferenceTree;
 import com.sun.source.tree.CatchTree;
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.DocSourcePositions;
+import com.sun.source.util.DocTreePath;
 import com.sun.source.util.DocTreeScanner;
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.JavacTask;
@@ -314,7 +315,7 @@
         return TreePath.getPath(treeTopLevel.snd, treeTopLevel.fst);
     }
 
-    public Element getElement(TreePath path) {
+    public Symbol getElement(TreePath path) {
         JCTree tree = (JCTree) path.getLeaf();
         Symbol sym = TreeInfo.symbolFor(tree);
         if (sym == null) {
@@ -332,22 +333,25 @@
                         }
                     }
                 }
-            } else if (tree.hasTag(Tag.TOPLEVEL)) {
-                JCCompilationUnit cu = (JCCompilationUnit) tree;
-                if (cu.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
-                    sym = cu.packge;
-                }
             }
         }
         return sym;
     }
 
     @Override
-    public Element getElement(TreePath path, ReferenceTree reference) {
-        if (!(reference instanceof DCReference))
-            return null;
-        DCReference ref = (DCReference) reference;
+    public Element getElement(DocTreePath path) {
+        DocTree forTree = path.getLeaf();
+        if (forTree instanceof DCReference)
+            return attributeDocReference(path.getTreePath(), ((DCReference) forTree));
+        if (forTree instanceof DCIdentifier) {
+            if (path.getParentPath().getLeaf() instanceof DCParam) {
+                return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf());
+            }
+        }
+        return null;
+    }
 
+    private Symbol attributeDocReference(TreePath path, DCReference ref) {
         Env<AttrContext> env = getAttrContext(path);
 
         Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
@@ -427,6 +431,30 @@
         }
     }
 
+    private Symbol attributeParamIdentifier(TreePath path, DCParam ptag) {
+        Symbol javadocSymbol = getElement(path);
+        if (javadocSymbol == null)
+            return null;
+        ElementKind kind = javadocSymbol.getKind();
+        List<? extends Symbol> params = List.nil();
+        if (kind == ElementKind.METHOD || kind == ElementKind.CONSTRUCTOR) {
+            MethodSymbol ee = (MethodSymbol) javadocSymbol;
+            params = ptag.isTypeParameter()
+                    ? ee.getTypeParameters()
+                    : ee.getParameters();
+        } else if (kind.isClass() || kind.isInterface()) {
+            ClassSymbol te = (ClassSymbol) javadocSymbol;
+            params = te.getTypeParameters();
+        }
+
+        for (Symbol param : params) {
+            if (param.getSimpleName() == ptag.getName().getName()) {
+                return param;
+            }
+        }
+        return null;
+    }
+
     /** @see com.sun.tools.javadoc.ClassDocImpl#findField */
     private VarSymbol findField(ClassSymbol tsym, Name fieldName) {
         return searchField(tsym, fieldName, new HashSet<ClassSymbol>());
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Annotations.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Annotations.java	Fri May 17 10:13:34 2013 -0700
@@ -76,11 +76,24 @@
     private List<Attribute.Compound> attributes = DECL_NOT_STARTED;
 
     /*
-     * This field should never be null
+     * Type attributes for this symbol.
+     * This field should never be null.
      */
     private List<Attribute.TypeCompound> type_attributes = List.<Attribute.TypeCompound>nil();
 
     /*
+     * Type attributes of initializers in this class.
+     * Unused if the current symbol is not a ClassSymbol.
+     */
+    private List<Attribute.TypeCompound> init_type_attributes = List.<Attribute.TypeCompound>nil();
+
+    /*
+     * Type attributes of class initializers in this class.
+     * Unused if the current symbol is not a ClassSymbol.
+     */
+    private List<Attribute.TypeCompound> clinit_type_attributes = List.<Attribute.TypeCompound>nil();
+
+    /*
      * The Symbol this Annotations instance belongs to
      */
     private final Symbol sym;
@@ -97,6 +110,14 @@
         return type_attributes;
     }
 
+    public List<Attribute.TypeCompound> getInitTypeAttributes() {
+        return init_type_attributes;
+    }
+
+    public List<Attribute.TypeCompound> getClassInitTypeAttributes() {
+        return clinit_type_attributes;
+    }
+
     public void setDeclarationAttributes(List<Attribute.Compound> a) {
         Assert.check(pendingCompletion() || !isStarted());
         if (a == null) {
@@ -112,12 +133,28 @@
         type_attributes = a;
     }
 
+    public void setInitTypeAttributes(List<Attribute.TypeCompound> a) {
+        if (a == null) {
+            throw new NullPointerException();
+        }
+        init_type_attributes = a;
+    }
+
+    public void setClassInitTypeAttributes(List<Attribute.TypeCompound> a) {
+        if (a == null) {
+            throw new NullPointerException();
+        }
+        clinit_type_attributes = a;
+    }
+
     public void setAttributes(Annotations other) {
         if (other == null) {
             throw new NullPointerException();
         }
         setDeclarationAttributes(other.getDeclarationAttributes());
         setTypeAttributes(other.getTypeAttributes());
+        setInitTypeAttributes(other.getInitTypeAttributes());
+        setClassInitTypeAttributes(other.getClassInitTypeAttributes());
     }
 
     public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) {
@@ -232,6 +269,28 @@
         return this;
     }
 
+    public Annotations appendInitTypeAttributes(List<Attribute.TypeCompound> l) {
+        if (l.isEmpty()) {
+            ; // no-op
+        } else if (init_type_attributes.isEmpty()) {
+            init_type_attributes = l;
+        } else {
+            init_type_attributes = init_type_attributes.appendList(l);
+        }
+        return this;
+    }
+
+    public Annotations appendClassInitTypeAttributes(List<Attribute.TypeCompound> l) {
+        if (l.isEmpty()) {
+            ; // no-op
+        } else if (clinit_type_attributes.isEmpty()) {
+            clinit_type_attributes = l;
+        } else {
+            clinit_type_attributes = clinit_type_attributes.appendList(l);
+        }
+        return this;
+    }
+
     public Annotations prepend(List<Attribute.Compound> l) {
         attributes = filterDeclSentinels(attributes);
 
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java	Fri May 17 10:13:34 2013 -0700
@@ -230,6 +230,42 @@
             this.position = position;
         }
 
+        public boolean hasUnknownPosition() {
+            return position == null || position.type == TargetType.UNKNOWN;
+        }
+
+        public boolean isContainerTypeCompound() {
+            if (isSynthesized() && values.size() == 1)
+                return getFirstEmbeddedTC() != null;
+            return false;
+        }
+
+        private TypeCompound getFirstEmbeddedTC() {
+            if (values.size() == 1) {
+                Pair<MethodSymbol, Attribute> val = values.get(0);
+                if (val.fst.getSimpleName().contentEquals("value")
+                        && val.snd instanceof Array) {
+                    Array arr = (Array) val.snd;
+                    if (arr.values.length != 0
+                            && arr.values[0] instanceof Attribute.TypeCompound)
+                        return (Attribute.TypeCompound) arr.values[0];
+                }
+            }
+            return null;
+        }
+
+        public boolean tryFixPosition() {
+            if (!isContainerTypeCompound())
+                return false;
+
+            TypeCompound from = getFirstEmbeddedTC();
+            if (from != null && from.position != null &&
+                    from.position.type != TargetType.UNKNOWN) {
+                position = from.position;
+                return true;
+            }
+            return false;
+        }
     }
 
     /** The value for an annotation element of an array type.
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java	Fri May 17 10:13:34 2013 -0700
@@ -31,6 +31,7 @@
 
 import com.sun.tools.javac.api.Messages;
 import com.sun.tools.javac.code.Type.AnnotatedType;
+import com.sun.tools.javac.code.Type.ArrayType;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.util.List;
@@ -127,7 +128,7 @@
     }
 
     /**
-     * Get a localized string represenation for a given type.
+     * Get a localized string representation for a given type.
      *
      * @param t type to be displayed
      * @param locale the locale in which the string is to be rendered
@@ -138,7 +139,7 @@
     }
 
     /**
-     * Get a localized string represenation for a given symbol.
+     * Get a localized string representation for a given symbol.
      *
      * @param s symbol to be displayed
      * @param locale the locale in which the string is to be rendered
@@ -182,7 +183,33 @@
 
     @Override
     public String visitArrayType(ArrayType t, Locale locale) {
-        return visit(t.elemtype, locale) + "[]";
+        StringBuilder res = new StringBuilder();
+        printBaseElementType(t, res, locale);
+        printBrackets(t, res, locale);
+        return res.toString();
+    }
+
+    void printBaseElementType(Type t, StringBuilder sb, Locale locale) {
+        Type arrel = t;
+        while (arrel.getKind() == TypeKind.ARRAY) {
+            arrel = arrel.unannotatedType();
+            arrel = ((ArrayType) arrel).elemtype;
+        }
+        sb.append(visit(arrel, locale));
+    }
+
+    void printBrackets(Type t, StringBuilder sb, Locale locale) {
+        Type arrel = t;
+        while (arrel.getKind() == TypeKind.ARRAY) {
+            if (arrel.isAnnotated()) {
+                sb.append(' ');
+                sb.append(arrel.getAnnotationMirrors());
+                sb.append(' ');
+            }
+            sb.append("[]");
+            arrel = arrel.unannotatedType();
+            arrel = ((ArrayType) arrel).elemtype;
+        }
     }
 
     @Override
@@ -237,10 +264,22 @@
     public String visitAnnotatedType(AnnotatedType t, Locale locale) {
         if (t.typeAnnotations != null &&
                 t.typeAnnotations.nonEmpty()) {
-            // TODO: better logic for arrays, ...
-            return "(" + t.typeAnnotations + " :: " + visit(t.underlyingType, locale) + ")";
+            if (t.underlyingType.getKind() == TypeKind.ARRAY) {
+                StringBuilder res = new StringBuilder();
+                printBaseElementType(t, res, locale);
+                printBrackets(t, res, locale);
+                return res.toString();
+            } else if (t.underlyingType.getKind() == TypeKind.DECLARED &&
+                    t.underlyingType.getEnclosingType() != Type.noType) {
+                return visit(t.underlyingType.getEnclosingType(), locale) +
+                        ". " +
+                        t.typeAnnotations +
+                        " " + className((ClassType)t.underlyingType, false, locale);
+            } else {
+                return t.typeAnnotations + " " + visit(t.underlyingType, locale);
+            }
         } else {
-            return "({} :: " + visit(t.underlyingType, locale) + ")";
+            return visit(t.underlyingType, locale);
         }
     }
 
@@ -253,7 +292,7 @@
 
     /**
      * Converts a class name into a (possibly localized) string. Anonymous
-     * inner classes gets converted into a localized string.
+     * inner classes get converted into a localized string.
      *
      * @param t the type of the class whose name is to be rendered
      * @param longform if set, the class' fullname is displayed - if unset the
@@ -266,7 +305,7 @@
         if (sym.name.length() == 0 && (sym.flags() & COMPOUND) != 0) {
             StringBuilder s = new StringBuilder(visit(t.supertype_field, locale));
             for (List<Type> is = t.interfaces_field; is.nonEmpty(); is = is.tail) {
-                s.append("&");
+                s.append('&');
                 s.append(visit(is.head, locale));
             }
             return s.toString();
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java	Fri May 17 10:13:34 2013 -0700
@@ -131,7 +131,6 @@
     public final Type methodHandleLookupType;
     public final Type methodTypeType;
     public final Type nativeHeaderType;
-    public final Type nativeHeaderType_old;
     public final Type throwableType;
     public final Type errorType;
     public final Type interruptedExceptionType;
@@ -526,7 +525,6 @@
                              autoCloseableType.tsym);
         trustMeType = enterClass("java.lang.SafeVarargs");
         nativeHeaderType = enterClass("java.lang.annotation.Native");
-        nativeHeaderType_old = enterClass("javax.tools.annotation.GenerateNativeHeader");
         lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
         functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
 
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java	Fri May 17 10:13:34 2013 -0700
@@ -25,8 +25,6 @@
 
 package com.sun.tools.javac.code;
 
-import com.sun.tools.javac.model.JavacAnnoConstructs;
-import com.sun.tools.javac.model.JavacTypes;
 import java.lang.annotation.Annotation;
 import java.util.Collections;
 import java.util.EnumMap;
@@ -34,10 +32,10 @@
 import java.util.Map;
 import java.util.Set;
 
-import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.type.*;
 
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.model.JavacAnnoConstructs;
 import com.sun.tools.javac.util.*;
 import static com.sun.tools.javac.code.BoundKind.*;
 import static com.sun.tools.javac.code.Flags.*;
@@ -729,7 +727,7 @@
                     return s.toString();
                 } else if (sym.name.isEmpty()) {
                     String s;
-                    ClassType norm = (ClassType) tsym.type;
+                    ClassType norm = (ClassType) tsym.type.unannotatedType();
                     if (norm == null) {
                         s = Log.getLocalizedString("anonymous.class", (Object)null);
                     } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) {
@@ -781,7 +779,7 @@
             return
                 getEnclosingType().isErroneous() ||
                 isErroneous(getTypeArguments()) ||
-                this != tsym.type && tsym.type.isErroneous();
+                this != tsym.type.unannotatedType() && tsym.type.isErroneous();
         }
 
         public boolean isParameterized() {
@@ -1693,7 +1691,10 @@
 
         @Override
         public String toString() {
-            // TODO more logic for arrays, etc.
+            // This method is only used for internal debugging output.
+            // See
+            // com.sun.tools.javac.code.Printer.visitAnnotatedType(AnnotatedType, Locale)
+            // for the user-visible logic.
             if (typeAnnotations != null &&
                     !typeAnnotations.isEmpty()) {
                 return "(" + typeAnnotations.toString() + " :: " + underlyingType.toString() + ")";
@@ -1705,9 +1706,13 @@
         @Override
         public boolean contains(Type t)          { return underlyingType.contains(t); }
 
-        // TODO: attach annotations?
         @Override
-        public Type withTypeVar(Type t)          { return underlyingType.withTypeVar(t); }
+        public Type withTypeVar(Type t) {
+            // Don't create a new AnnotatedType, as 'this' will
+            // get its annotations set later.
+            underlyingType = underlyingType.withTypeVar(t);
+            return this;
+        }
 
         // TODO: attach annotations?
         @Override
--- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java	Fri May 17 10:13:34 2013 -0700
@@ -27,6 +27,7 @@
 
 import java.util.Iterator;
 
+import com.sun.tools.javac.tree.JCTree.JCLambda;
 import com.sun.tools.javac.util.*;
 
 /** A type annotation position.
@@ -145,9 +146,18 @@
     // For class extends, implements, and throws clauses
     public int type_index = Integer.MIN_VALUE;
 
-    // For exception parameters, index into exception table
+    // For exception parameters, index into exception table.
+    // In com.sun.tools.javac.jvm.Gen.genCatch we first set the type_index
+    // to the catch type index - that value is only temporary.
+    // Then in com.sun.tools.javac.jvm.Code.fillExceptionParameterPositions
+    // we use that value to determine the exception table index.
     public int exception_index = Integer.MIN_VALUE;
 
+    // If this type annotation is within a lambda expression,
+    // store a pointer to the lambda expression tree in order
+    // to allow a later translation to the right method.
+    public JCLambda onLambda = null;
+
     public TypeAnnotationPosition() {}
 
     @Override
@@ -258,6 +268,11 @@
         sb.append(", pos = ");
         sb.append(pos);
 
+        if (onLambda != null) {
+            sb.append(", onLambda hash = ");
+            sb.append(onLambda.hashCode());
+        }
+
         sb.append(']');
         return sb.toString();
     }
@@ -271,6 +286,17 @@
         return !type.isLocal() || isValidOffset;
     }
 
+
+    public boolean matchesPos(int pos) {
+        return this.pos == pos;
+    }
+
+    public void updatePosOffset(int to) {
+        offset = to;
+        lvarOffset = new int[]{to};
+        isValidOffset = true;
+    }
+
     /**
      * Decode the binary representation for a type path and set
      * the {@code location} field.
--- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Fri May 17 10:13:34 2013 -0700
@@ -49,12 +49,16 @@
 import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntryKind;
 import com.sun.tools.javac.code.TypeTag;
 import com.sun.tools.javac.code.Symbol.VarSymbol;
+import com.sun.tools.javac.code.Symbol.MethodSymbol;
+import com.sun.tools.javac.comp.Annotate;
 import com.sun.tools.javac.comp.Annotate.Annotator;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCBlock;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import com.sun.tools.javac.tree.JCTree.JCExpression;
+import com.sun.tools.javac.tree.JCTree.JCLambda;
 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
+import com.sun.tools.javac.tree.JCTree.JCNewClass;
 import com.sun.tools.javac.tree.JCTree.JCTypeApply;
 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
 import com.sun.tools.javac.tree.TreeScanner;
@@ -81,17 +85,18 @@
      * determine the correct positions for type annotations.
      * This version only visits types in signatures and should be
      * called from MemberEnter.
-     * The method returns the Annotator object that should be added
-     * to the correct Annotate queue for later processing.
+     * The method takes the Annotate object as parameter and
+     * adds an Annotator to the correct Annotate queue for
+     * later processing.
      */
-    public static Annotator organizeTypeAnnotationsSignatures(final Symtab syms, final Names names,
-            final Log log, final JCClassDecl tree) {
-        return new Annotator() {
+    public static void organizeTypeAnnotationsSignatures(final Symtab syms, final Names names,
+            final Log log, final JCClassDecl tree, Annotate annotate) {
+        annotate.afterRepeated( new Annotator() {
             @Override
             public void enterAnnotation() {
                 new TypeAnnotationPositions(syms, names, log, true).scan(tree);
             }
-        };
+        } );
     }
 
     /**
@@ -102,9 +107,103 @@
         new TypeAnnotationPositions(syms, names, log, false).scan(tree);
     }
 
-    private static class TypeAnnotationPositions extends TreeScanner {
+    public enum AnnotationType { DECLARATION, TYPE, BOTH };
 
-        private enum AnnotationType { DECLARATION, TYPE, BOTH };
+    /**
+     * Determine whether an annotation is a declaration annotation,
+     * a type annotation, or both.
+     */
+    public static AnnotationType annotationType(Symtab syms, Names names,
+            Attribute.Compound a, Symbol s) {
+        Attribute.Compound atTarget =
+            a.type.tsym.attribute(syms.annotationTargetType.tsym);
+        if (atTarget == null) {
+            return inferTargetMetaInfo(a, s);
+        }
+        Attribute atValue = atTarget.member(names.value);
+        if (!(atValue instanceof Attribute.Array)) {
+            Assert.error("annotationType(): bad @Target argument " + atValue +
+                    " (" + atValue.getClass() + ")");
+            return AnnotationType.DECLARATION; // error recovery
+        }
+        Attribute.Array arr = (Attribute.Array) atValue;
+        boolean isDecl = false, isType = false;
+        for (Attribute app : arr.values) {
+            if (!(app instanceof Attribute.Enum)) {
+                Assert.error("annotationType(): unrecognized Attribute kind " + app +
+                        " (" + app.getClass() + ")");
+                isDecl = true;
+                continue;
+            }
+            Attribute.Enum e = (Attribute.Enum) app;
+            if (e.value.name == names.TYPE) {
+                if (s.kind == Kinds.TYP)
+                    isDecl = true;
+            } else if (e.value.name == names.FIELD) {
+                if (s.kind == Kinds.VAR &&
+                        s.owner.kind != Kinds.MTH)
+                    isDecl = true;
+            } else if (e.value.name == names.METHOD) {
+                if (s.kind == Kinds.MTH &&
+                        !s.isConstructor())
+                    isDecl = true;
+            } else if (e.value.name == names.PARAMETER) {
+                if (s.kind == Kinds.VAR &&
+                        s.owner.kind == Kinds.MTH &&
+                        (s.flags() & Flags.PARAMETER) != 0)
+                    isDecl = true;
+            } else if (e.value.name == names.CONSTRUCTOR) {
+                if (s.kind == Kinds.MTH &&
+                        s.isConstructor())
+                    isDecl = true;
+            } else if (e.value.name == names.LOCAL_VARIABLE) {
+                if (s.kind == Kinds.VAR &&
+                        s.owner.kind == Kinds.MTH &&
+                        (s.flags() & Flags.PARAMETER) == 0)
+                    isDecl = true;
+            } else if (e.value.name == names.ANNOTATION_TYPE) {
+                if (s.kind == Kinds.TYP &&
+                        (s.flags() & Flags.ANNOTATION) != 0)
+                    isDecl = true;
+            } else if (e.value.name == names.PACKAGE) {
+                if (s.kind == Kinds.PCK)
+                    isDecl = true;
+            } else if (e.value.name == names.TYPE_USE) {
+                if (s.kind == Kinds.TYP ||
+                        s.kind == Kinds.VAR ||
+                        (s.kind == Kinds.MTH && !s.isConstructor() &&
+                        !s.type.getReturnType().hasTag(TypeTag.VOID)) ||
+                        (s.kind == Kinds.MTH && s.isConstructor()))
+                    isType = true;
+            } else if (e.value.name == names.TYPE_PARAMETER) {
+                /* Irrelevant in this case */
+                // TYPE_PARAMETER doesn't aid in distinguishing between
+                // Type annotations and declaration annotations on an
+                // Element
+            } else {
+                Assert.error("annotationType(): unrecognized Attribute name " + e.value.name +
+                        " (" + e.value.name.getClass() + ")");
+                isDecl = true;
+            }
+        }
+        if (isDecl && isType) {
+            return AnnotationType.BOTH;
+        } else if (isType) {
+            return AnnotationType.TYPE;
+        } else {
+            return AnnotationType.DECLARATION;
+        }
+    }
+
+    /** Infer the target annotation kind, if none is give.
+     * We only infer declaration annotations.
+     */
+    private static AnnotationType inferTargetMetaInfo(Attribute.Compound a, Symbol s) {
+        return AnnotationType.DECLARATION;
+    }
+
+
+    private static class TypeAnnotationPositions extends TreeScanner {
 
         private final Symtab syms;
         private final Names names;
@@ -154,7 +253,7 @@
             ListBuffer<Attribute.TypeCompound> typeAnnos = new ListBuffer<Attribute.TypeCompound>();
 
             for (Attribute.Compound a : annotations) {
-                switch (annotationType(a, sym)) {
+                switch (annotationType(syms, names, a, sym)) {
                 case DECLARATION:
                     declAnnos.append(a);
                     break;
@@ -175,6 +274,10 @@
             sym.annotations.reset();
             sym.annotations.setDeclarationAttributes(declAnnos.toList());
 
+            if (typeAnnos.isEmpty()) {
+                return;
+            }
+
             List<Attribute.TypeCompound> typeAnnotations = typeAnnos.toList();
 
             if (type == null) {
@@ -190,16 +293,33 @@
 
             if (sym.getKind() == ElementKind.METHOD) {
                 sym.type.asMethodType().restype = type;
+            } else if (sym.getKind() == ElementKind.PARAMETER) {
+                sym.type = type;
+                if (sym.getQualifiedName().equals(names._this)) {
+                    sym.owner.type.asMethodType().recvtype = type;
+                    // note that the typeAnnotations will also be added to the owner below.
+                } else {
+                    MethodType methType = sym.owner.type.asMethodType();
+                    List<VarSymbol> params = ((MethodSymbol)sym.owner).params;
+                    List<Type> oldArgs = methType.argtypes;
+                    ListBuffer<Type> newArgs = new ListBuffer<Type>();
+                    while (params.nonEmpty()) {
+                        if (params.head == sym) {
+                            newArgs.add(type);
+                        } else {
+                            newArgs.add(oldArgs.head);
+                        }
+                        oldArgs = oldArgs.tail;
+                        params = params.tail;
+                    }
+                    methType.argtypes = newArgs.toList();
+                }
             } else {
                 sym.type = type;
             }
 
             sym.annotations.appendUniqueTypes(typeAnnotations);
-            if (sym.getKind() == ElementKind.PARAMETER &&
-                    sym.getQualifiedName().equals(names._this)) {
-                sym.owner.type.asMethodType().recvtype = type;
-                // note that the typeAnnotations will also be added to the owner below.
-            }
+
             if (sym.getKind() == ElementKind.PARAMETER ||
                     sym.getKind() == ElementKind.LOCAL_VARIABLE ||
                     sym.getKind() == ElementKind.RESOURCE_VARIABLE ||
@@ -276,10 +396,21 @@
                     TypeAnnotationPosition p = a.position;
                     p.location = p.location.prependList(depth.toList());
                 }
+                typetree.type = toreturn;
                 return toreturn;
             } else if (type.hasTag(TypeTag.TYPEVAR)) {
                 // Nothing to do for type variables.
                 return type;
+            } else if (type.getKind() == TypeKind.UNION) {
+                // There is a TypeKind, but no TypeTag.
+                JCTypeUnion tutree = (JCTypeUnion) typetree;
+                JCExpression fst = tutree.alternatives.get(0);
+                Type res = typeWithAnnotations(fst, fst.type, annotations, log);
+                fst.type = res;
+                // TODO: do we want to set res as first element in uct.alternatives?
+                // UnionClassType uct = (com.sun.tools.javac.code.Type.UnionClassType)type;
+                // Return the un-annotated union-type.
+                return type;
             } else {
                 Type enclTy = type;
                 Element enclEl = type.asElement();
@@ -357,6 +488,7 @@
                 }
 
                 Type ret = typeWithAnnotations(type, enclTy, annotations);
+                typetree.type = ret;
                 return ret;
             }
         }
@@ -480,94 +612,6 @@
             return new Attribute.TypeCompound(a, p);
         }
 
-        private AnnotationType annotationType(Attribute.Compound a, Symbol s) {
-            Attribute.Compound atTarget =
-                a.type.tsym.attribute(syms.annotationTargetType.tsym);
-            if (atTarget == null) {
-                return inferTargetMetaInfo(a, s);
-            }
-            Attribute atValue = atTarget.member(names.value);
-            if (!(atValue instanceof Attribute.Array)) {
-                Assert.error("annotationType(): bad @Target argument " + atValue +
-                        " (" + atValue.getClass() + ")");
-                return AnnotationType.DECLARATION; // error recovery
-            }
-            Attribute.Array arr = (Attribute.Array) atValue;
-            boolean isDecl = false, isType = false;
-            for (Attribute app : arr.values) {
-                if (!(app instanceof Attribute.Enum)) {
-                    Assert.error("annotationType(): unrecognized Attribute kind " + app +
-                            " (" + app.getClass() + ")");
-                    isDecl = true;
-                    continue;
-                }
-                Attribute.Enum e = (Attribute.Enum) app;
-                if (e.value.name == names.TYPE) {
-                    if (s.kind == Kinds.TYP)
-                        isDecl = true;
-                } else if (e.value.name == names.FIELD) {
-                    if (s.kind == Kinds.VAR &&
-                            s.owner.kind != Kinds.MTH)
-                        isDecl = true;
-                } else if (e.value.name == names.METHOD) {
-                    if (s.kind == Kinds.MTH &&
-                            !s.isConstructor())
-                        isDecl = true;
-                } else if (e.value.name == names.PARAMETER) {
-                    if (s.kind == Kinds.VAR &&
-                            s.owner.kind == Kinds.MTH &&
-                            (s.flags() & Flags.PARAMETER) != 0)
-                        isDecl = true;
-                } else if (e.value.name == names.CONSTRUCTOR) {
-                    if (s.kind == Kinds.MTH &&
-                            s.isConstructor())
-                        isDecl = true;
-                } else if (e.value.name == names.LOCAL_VARIABLE) {
-                    if (s.kind == Kinds.VAR &&
-                            s.owner.kind == Kinds.MTH &&
-                            (s.flags() & Flags.PARAMETER) == 0)
-                        isDecl = true;
-                } else if (e.value.name == names.ANNOTATION_TYPE) {
-                    if (s.kind == Kinds.TYP &&
-                            (s.flags() & Flags.ANNOTATION) != 0)
-                        isDecl = true;
-                } else if (e.value.name == names.PACKAGE) {
-                    if (s.kind == Kinds.PCK)
-                        isDecl = true;
-                } else if (e.value.name == names.TYPE_USE) {
-                    if (s.kind == Kinds.TYP ||
-                            s.kind == Kinds.VAR ||
-                            (s.kind == Kinds.MTH && !s.isConstructor() &&
-                            !s.type.getReturnType().hasTag(TypeTag.VOID)) ||
-                            (s.kind == Kinds.MTH && s.isConstructor()))
-                        isType = true;
-                } else if (e.value.name == names.TYPE_PARAMETER) {
-                    /* Irrelevant in this case */
-                    // TYPE_PARAMETER doesn't aid in distinguishing between
-                    // Type annotations and declaration annotations on an
-                    // Element
-                } else {
-                    Assert.error("annotationType(): unrecognized Attribute name " + e.value.name +
-                            " (" + e.value.name.getClass() + ")");
-                    isDecl = true;
-                }
-            }
-            if (isDecl && isType) {
-                return AnnotationType.BOTH;
-            } else if (isType) {
-                return AnnotationType.TYPE;
-            } else {
-                return AnnotationType.DECLARATION;
-            }
-        }
-
-        /** Infer the target annotation kind, if none is give.
-         * We only infer declaration annotations.
-         */
-        private static AnnotationType inferTargetMetaInfo(Attribute.Compound a, Symbol s) {
-            return AnnotationType.DECLARATION;
-        }
-
 
         /* This is the beginning of the second part of organizing
          * type annotations: determine the type annotation positions.
@@ -585,7 +629,13 @@
 
             switch (frame.getKind()) {
                 case TYPE_CAST:
+                    JCTypeCast frameTC = (JCTypeCast) frame;
                     p.type = TargetType.CAST;
+                    if (frameTC.clazz.hasTag(Tag.TYPEINTERSECTION)) {
+                        // This case was already handled by INTERSECTION_TYPE
+                    } else {
+                        p.type_index = 0;
+                    }
                     p.pos = frame.pos;
                     return;
 
@@ -595,8 +645,22 @@
                     return;
 
                 case NEW_CLASS:
-                    JCNewClass frameNewClass = (JCNewClass)frame;
-                    if (frameNewClass.typeargs.contains(tree)) {
+                    JCNewClass frameNewClass = (JCNewClass) frame;
+                    if (frameNewClass.def != null) {
+                        // Special handling for anonymous class instantiations
+                        JCClassDecl frameClassDecl = frameNewClass.def;
+                        if (frameClassDecl.extending == tree) {
+                            p.type = TargetType.CLASS_EXTENDS;
+                            p.type_index = -1;
+                        } else if (frameClassDecl.implementing.contains(tree)) {
+                            p.type = TargetType.CLASS_EXTENDS;
+                            p.type_index = frameClassDecl.implementing.indexOf(tree);
+                        } else {
+                            // In contrast to CLASS below, typarams cannot occur here.
+                            Assert.error("Could not determine position of tree " + tree +
+                                    " within frame " + frame);
+                        }
+                    } else if (frameNewClass.typeargs.contains(tree)) {
                         p.type = TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT;
                         p.type_index = frameNewClass.typeargs.indexOf(tree);
                     } else {
@@ -649,6 +713,8 @@
                 }
 
                 case PARAMETERIZED_TYPE: {
+                    List<JCTree> newPath = path.tail;
+
                     if (((JCTypeApply)frame).clazz == tree) {
                         // generic: RAW; noop
                     } else if (((JCTypeApply)frame).arguments.contains(tree)) {
@@ -656,13 +722,21 @@
                         int arg = taframe.arguments.indexOf(tree);
                         p.location = p.location.prepend(new TypePathEntry(TypePathEntryKind.TYPE_ARGUMENT, arg));
 
-                        locateNestedTypes(taframe.type, p);
+                        Type typeToUse;
+                        if (newPath.tail != null && newPath.tail.head.hasTag(Tag.NEWCLASS)) {
+                            // If we are within an anonymous class instantiation, use its type,
+                            // because it contains a correctly nested type.
+                            typeToUse = newPath.tail.head.type;
+                        } else {
+                            typeToUse = taframe.type;
+                        }
+
+                        locateNestedTypes(typeToUse, p);
                     } else {
                         Assert.error("Could not determine type argument position of tree " + tree +
                                 " within frame " + frame);
                     }
 
-                    List<JCTree> newPath = path.tail;
                     resolveFrame(newPath.head, newPath.tail.head, newPath, p);
                     return;
                 }
@@ -780,6 +854,9 @@
                         default:
                             Assert.error("Found unexpected type annotation for variable: " + v + " with kind: " + v.getKind());
                     }
+                    if (v.getKind() != ElementKind.FIELD) {
+                        v.owner.annotations.appendUniqueTypes(v.getRawTypeAttributes());
+                    }
                     return;
 
                 case ANNOTATED_TYPE: {
@@ -789,6 +866,11 @@
                         // not care about inner types.
                         JCAnnotatedType atypetree = (JCAnnotatedType) frame;
                         final Type utype = atypetree.underlyingType.type;
+                        if (utype == null) {
+                            // This might happen during DeferredAttr;
+                            // we will be back later.
+                            return;
+                        }
                         Symbol tsym = utype.tsym;
                         if (tsym.getKind().equals(ElementKind.TYPE_PARAMETER) ||
                                 utype.getKind().equals(TypeKind.WILDCARD) ||
@@ -806,8 +888,6 @@
                 }
 
                 case UNION_TYPE: {
-                    // TODO: can we store any information here to help in
-                    // determining the final position?
                     List<JCTree> newPath = path.tail;
                     resolveFrame(newPath.head, newPath.tail.head, newPath, p);
                     return;
@@ -873,11 +953,20 @@
 
         private static int methodParamIndex(List<JCTree> path, JCTree param) {
             List<JCTree> curr = path;
-            while (curr.head.getTag() != Tag.METHODDEF) {
+            while (curr.head.getTag() != Tag.METHODDEF &&
+                    curr.head.getTag() != Tag.LAMBDA) {
                 curr = curr.tail;
             }
-            JCMethodDecl method = (JCMethodDecl)curr.head;
-            return method.params.indexOf(param);
+            if (curr.head.getTag() == Tag.METHODDEF) {
+                JCMethodDecl method = (JCMethodDecl)curr.head;
+                return method.params.indexOf(param);
+            } else if (curr.head.getTag() == Tag.LAMBDA) {
+                JCLambda lambda = (JCLambda)curr.head;
+                return lambda.params.indexOf(param);
+            } else {
+                Assert.error("methodParamIndex expected to find method or lambda for param: " + param);
+                return -1;
+            }
         }
 
         // Each class (including enclosed inner classes) is visited separately.
@@ -889,6 +978,7 @@
             if (isInClass)
                 return;
             isInClass = true;
+
             if (sigOnly) {
                 scan(tree.mods);
                 scan(tree.typarams);
@@ -910,7 +1000,9 @@
                 return;
             }
             if (sigOnly) {
-                {
+                if (!tree.mods.annotations.isEmpty()) {
+                    // Nothing to do for separateAnnotationsKinds if
+                    // there are no annotations of either kind.
                     TypeAnnotationPosition pos = new TypeAnnotationPosition();
                     pos.type = TargetType.METHOD_RETURN;
                     if (tree.sym.isConstructor()) {
@@ -923,7 +1015,10 @@
                                 tree.sym, pos);
                     }
                 }
-                if (tree.recvparam != null && tree.recvparam.sym != null) {
+                if (tree.recvparam != null && tree.recvparam.sym != null &&
+                        !tree.recvparam.mods.annotations.isEmpty()) {
+                    // Nothing to do for separateAnnotationsKinds if
+                    // there are no annotations of either kind.
                     // TODO: make sure there are no declaration annotations.
                     TypeAnnotationPosition pos = new TypeAnnotationPosition();
                     pos.type = TargetType.METHOD_RECEIVER;
@@ -933,11 +1028,15 @@
                 }
                 int i = 0;
                 for (JCVariableDecl param : tree.params) {
-                    TypeAnnotationPosition pos = new TypeAnnotationPosition();
-                    pos.type = TargetType.METHOD_FORMAL_PARAMETER;
-                    pos.parameter_index = i;
-                    pos.pos = param.vartype.pos;
-                    separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos);
+                    if (!param.mods.annotations.isEmpty()) {
+                        // Nothing to do for separateAnnotationsKinds if
+                        // there are no annotations of either kind.
+                        TypeAnnotationPosition pos = new TypeAnnotationPosition();
+                        pos.type = TargetType.METHOD_FORMAL_PARAMETER;
+                        pos.parameter_index = i;
+                        pos.pos = param.vartype.pos;
+                        separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos);
+                    }
                     ++i;
                 }
             }
@@ -958,16 +1057,53 @@
             pop();
         }
 
+        /* Store a reference to the current lambda expression, to
+         * be used by all type annotations within this expression.
+         */
+        private JCLambda currentLambda = null;
+
+        public void visitLambda(JCLambda tree) {
+            JCLambda prevLambda = currentLambda;
+            try {
+                currentLambda = tree;
+
+                int i = 0;
+                for (JCVariableDecl param : tree.params) {
+                    if (!param.mods.annotations.isEmpty()) {
+                        // Nothing to do for separateAnnotationsKinds if
+                        // there are no annotations of either kind.
+                        TypeAnnotationPosition pos = new TypeAnnotationPosition();
+                        pos.type = TargetType.METHOD_FORMAL_PARAMETER;
+                        pos.parameter_index = i;
+                        pos.pos = param.vartype.pos;
+                        pos.onLambda = tree;
+                        separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos);
+                    }
+                    ++i;
+                }
+
+                push(tree);
+                scan(tree.body);
+                scan(tree.params);
+                pop();
+            } finally {
+                currentLambda = prevLambda;
+            }
+        }
+
         /**
          * Resolve declaration vs. type annotations in variable declarations and
          * then determine the positions.
          */
         @Override
         public void visitVarDef(final JCVariableDecl tree) {
-            if (tree.sym == null) {
+            if (tree.mods.annotations.isEmpty()) {
+                // Nothing to do for separateAnnotationsKinds if
+                // there are no annotations of either kind.
+            } else if (tree.sym == null) {
                 // Something is wrong already. Quietly ignore.
             } else if (tree.sym.getKind() == ElementKind.PARAMETER) {
-                // Parameters are handled in visitMethodDef above.
+                // Parameters are handled in visitMethodDef or visitLambda.
             } else if (tree.sym.getKind() == ElementKind.FIELD) {
                 if (sigOnly) {
                     TypeAnnotationPosition pos = new TypeAnnotationPosition();
@@ -979,16 +1115,19 @@
                 TypeAnnotationPosition pos = new TypeAnnotationPosition();
                 pos.type = TargetType.LOCAL_VARIABLE;
                 pos.pos = tree.pos;
+                pos.onLambda = currentLambda;
                 separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos);
             } else if (tree.sym.getKind() == ElementKind.EXCEPTION_PARAMETER) {
                 TypeAnnotationPosition pos = new TypeAnnotationPosition();
                 pos.type = TargetType.EXCEPTION_PARAMETER;
                 pos.pos = tree.pos;
+                pos.onLambda = currentLambda;
                 separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos);
             } else if (tree.sym.getKind() == ElementKind.RESOURCE_VARIABLE) {
                 TypeAnnotationPosition pos = new TypeAnnotationPosition();
                 pos.type = TargetType.RESOURCE_VARIABLE;
                 pos.pos = tree.pos;
+                pos.onLambda = currentLambda;
                 separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos);
             } else if (tree.sym.getKind() == ElementKind.ENUM_CONSTANT) {
                 // No type annotations can occur here.
@@ -1031,6 +1170,40 @@
         }
 
         @Override
+        public void visitNewClass(JCNewClass tree) {
+            if (tree.def != null &&
+                    !tree.def.mods.annotations.isEmpty()) {
+                JCClassDecl classdecl = tree.def;
+                TypeAnnotationPosition pos = new TypeAnnotationPosition();
+                pos.type = TargetType.CLASS_EXTENDS;
+                pos.pos = tree.pos;
+                if (classdecl.extending == tree.clazz) {
+                    pos.type_index = -1;
+                } else if (classdecl.implementing.contains(tree.clazz)) {
+                    pos.type_index = classdecl.implementing.indexOf(tree.clazz);
+                } else {
+                    // In contrast to CLASS elsewhere, typarams cannot occur here.
+                    Assert.error("Could not determine position of tree " + tree);
+                }
+                Type before = classdecl.sym.type;
+                separateAnnotationsKinds(classdecl, tree.clazz.type, classdecl.sym, pos);
+
+                // classdecl.sym.type now contains an annotated type, which
+                // is not what we want there.
+                // TODO: should we put this type somewhere in the superclass/interface?
+                classdecl.sym.type = before;
+            }
+
+            scan(tree.encl);
+            scan(tree.typeargs);
+            scan(tree.clazz);
+            scan(tree.args);
+
+            // The class body will already be scanned.
+            // scan(tree.def);
+        }
+
+        @Override
         public void visitNewArray(JCNewArray tree) {
             findPosition(tree, tree, tree.annotations);
             int dimAnnosCount = tree.dimAnnotations.size();
@@ -1040,6 +1213,7 @@
             for (int i = 0; i < dimAnnosCount; ++i) {
                 TypeAnnotationPosition p = new TypeAnnotationPosition();
                 p.pos = tree.pos;
+                p.onLambda = currentLambda;
                 p.type = TargetType.NEW;
                 if (i != 0) {
                     depth = depth.append(TypePathEntry.ARRAY);
@@ -1053,18 +1227,23 @@
             // int i = dimAnnosCount == 0 ? 0 : dimAnnosCount - 1;
             // TODO: is depth.size == i here?
             JCExpression elemType = tree.elemtype;
+            depth = depth.append(TypePathEntry.ARRAY);
             while (elemType != null) {
                 if (elemType.hasTag(JCTree.Tag.ANNOTATED_TYPE)) {
                     JCAnnotatedType at = (JCAnnotatedType)elemType;
                     TypeAnnotationPosition p = new TypeAnnotationPosition();
                     p.type = TargetType.NEW;
                     p.pos = tree.pos;
-                    p.location = p.location.appendList(depth.toList());
+                    p.onLambda = currentLambda;
+                    locateNestedTypes(elemType.type, p);
+                    p.location = p.location.prependList(depth.toList());
                     setTypeAnnotationPos(at.annotations, p);
                     elemType = at.underlyingType;
                 } else if (elemType.hasTag(JCTree.Tag.TYPEARRAY)) {
                     depth = depth.append(TypePathEntry.ARRAY);
                     elemType = ((JCArrayTypeTree)elemType).elemtype;
+                } else if (elemType.hasTag(JCTree.Tag.SELECT)) {
+                    elemType = ((JCFieldAccess)elemType).selected;
                 } else {
                     break;
                 }
@@ -1076,10 +1255,11 @@
             if (!annotations.isEmpty()) {
                 /*
                 System.out.println("Finding pos for: " + annotations);
-                System.out.println("    tree: " + tree);
-                System.out.println("    frame: " + frame);
+                System.out.println("    tree: " + tree + " kind: " + tree.getKind());
+                System.out.println("    frame: " + frame + " kind: " + frame.getKind());
                 */
                 TypeAnnotationPosition p = new TypeAnnotationPosition();
+                p.onLambda = currentLambda;
                 resolveFrame(tree, frame, frames.toList(), p);
                 setTypeAnnotationPos(annotations, p);
             }
@@ -1088,8 +1268,17 @@
         private static void setTypeAnnotationPos(List<JCAnnotation> annotations,
                 TypeAnnotationPosition position) {
             for (JCAnnotation anno : annotations) {
-                ((Attribute.TypeCompound) anno.attribute).position = position;
+                // attribute might be null during DeferredAttr;
+                // we will be back later.
+                if (anno.attribute != null) {
+                    ((Attribute.TypeCompound) anno.attribute).position = position;
+                }
             }
         }
+
+        @Override
+        public String toString() {
+            return super.toString() + ": sigOnly: " + sigOnly;
+        }
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Fri May 17 10:13:34 2013 -0700
@@ -26,7 +26,6 @@
 package com.sun.tools.javac.code;
 
 import java.lang.ref.SoftReference;
-import java.util.Comparator;
 import java.util.HashSet;
 import java.util.HashMap;
 import java.util.Locale;
@@ -34,8 +33,6 @@
 import java.util.Set;
 import java.util.WeakHashMap;
 
-import javax.lang.model.type.TypeKind;
-
 import com.sun.tools.javac.code.Attribute.RetentionPolicy;
 import com.sun.tools.javac.code.Lint.LintCategory;
 import com.sun.tools.javac.code.Type.UndetVar.InferenceBound;
@@ -204,7 +201,7 @@
                     WildcardType unb = new WildcardType(syms.objectType,
                                                         BoundKind.UNBOUND,
                                                         syms.boundClass,
-                                                        (TypeVar)parms.head);
+                                                        (TypeVar)parms.head.unannotatedType());
                     if (!containsType(args.head, unb))
                         return false;
                     parms = parms.tail;
@@ -268,7 +265,7 @@
                         List<Type> opens = openVars.toList();
                         ListBuffer<Type> qs = new ListBuffer<Type>();
                         for (List<Type> iter = opens; iter.nonEmpty(); iter = iter.tail) {
-                            qs.append(new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass, (TypeVar) iter.head));
+                            qs.append(new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass, (TypeVar) iter.head.unannotatedType()));
                         }
                         res = subst(res, opens, qs.toList());
                     }
@@ -581,12 +578,12 @@
             //simply replace the wildcards with its bound
             for (Type t : formalInterface.getTypeArguments()) {
                 if (actualTypeargs.head.hasTag(WILDCARD)) {
-                    WildcardType wt = (WildcardType)actualTypeargs.head;
+                    WildcardType wt = (WildcardType)actualTypeargs.head.unannotatedType();
                     Type bound;
                     switch (wt.kind) {
                         case EXTENDS:
                         case UNBOUND:
-                            CapturedType capVar = (CapturedType)capturedTypeargs.head;
+                            CapturedType capVar = (CapturedType)capturedTypeargs.head.unannotatedType();
                             //use declared bound if it doesn't depend on formal type-args
                             bound = capVar.bound.containsAny(capturedSite.getTypeArguments()) ?
                                     wt.type : capVar.bound;
@@ -964,6 +961,9 @@
                 isSameTypeStrict.visit(t, s) :
                 isSameTypeLoose.visit(t, s);
     }
+    public boolean isSameAnnotatedType(Type t, Type s) {
+        return isSameAnnotatedType.visit(t, s);
+    }
     // where
         abstract class SameTypeVisitor extends TypeRelation {
 
@@ -982,7 +982,7 @@
                     if (s.tag == TYPEVAR) {
                         //type-substitution does not preserve type-var types
                         //check that type var symbols and bounds are indeed the same
-                        return sameTypeVars((TypeVar)t, (TypeVar)s);
+                        return sameTypeVars((TypeVar)t.unannotatedType(), (TypeVar)s.unannotatedType());
                     }
                     else {
                         //special case for s == ? super X, where upper(s) = u
@@ -1096,7 +1096,9 @@
          * Standard type-equality relation - type variables are considered
          * equals if they share the same type symbol.
          */
-        TypeRelation isSameTypeLoose = new SameTypeVisitor() {
+        TypeRelation isSameTypeLoose = new LooseSameTypeVisitor();
+
+        private class LooseSameTypeVisitor extends SameTypeVisitor {
             @Override
             boolean sameTypeVars(TypeVar tv1, TypeVar tv2) {
                 return tv1.tsym == tv2.tsym && visit(tv1.getUpperBound(), tv2.getUpperBound());
@@ -1126,12 +1128,29 @@
                 if (!s.hasTag(WILDCARD)) {
                     return false;
                 } else {
-                    WildcardType t2 = (WildcardType)s;
+                    WildcardType t2 = (WildcardType)s.unannotatedType();
                     return t.kind == t2.kind &&
                             isSameType(t.type, t2.type, true);
                 }
             }
         };
+
+        /**
+         * A version of LooseSameTypeVisitor that takes AnnotatedTypes
+         * into account.
+         */
+        TypeRelation isSameAnnotatedType = new LooseSameTypeVisitor() {
+            @Override
+            public Boolean visitAnnotatedType(AnnotatedType t, Type s) {
+                if (!s.isAnnotated())
+                    return false;
+                if (!t.getAnnotationMirrors().containsAll(s.getAnnotationMirrors()))
+                    return false;
+                if (!s.getAnnotationMirrors().containsAll(t.getAnnotationMirrors()))
+                    return false;
+                return visit(t.underlyingType, s);
+            }
+        };
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="Contains Type">
@@ -1140,7 +1159,7 @@
         case UNDETVAR:
             if (s.tag == WILDCARD) {
                 UndetVar undetvar = (UndetVar)t;
-                WildcardType wt = (WildcardType)s;
+                WildcardType wt = (WildcardType)s.unannotatedType();
                 switch(wt.kind) {
                     case UNBOUND: //similar to ? extends Object
                     case EXTENDS: {
@@ -1207,7 +1226,7 @@
 
             private Type U(Type t) {
                 while (t.tag == WILDCARD) {
-                    WildcardType w = (WildcardType)t;
+                    WildcardType w = (WildcardType)t.unannotatedType();
                     if (w.isSuperBound())
                         return w.bound == null ? syms.objectType : w.bound.bound;
                     else
@@ -1218,7 +1237,7 @@
 
             private Type L(Type t) {
                 while (t.tag == WILDCARD) {
-                    WildcardType w = (WildcardType)t;
+                    WildcardType w = (WildcardType)t.unannotatedType();
                     if (w.isExtendsBound())
                         return syms.botType;
                     else
@@ -1276,15 +1295,15 @@
         };
 
     public boolean isCaptureOf(Type s, WildcardType t) {
-        if (s.tag != TYPEVAR || !((TypeVar)s).isCaptured())
+        if (s.tag != TYPEVAR || !((TypeVar)s.unannotatedType()).isCaptured())
             return false;
-        return isSameWildcard(t, ((CapturedType)s).wildcard);
+        return isSameWildcard(t, ((CapturedType)s.unannotatedType()).wildcard);
     }
 
     public boolean isSameWildcard(WildcardType t, Type s) {
         if (s.tag != WILDCARD)
             return false;
-        WildcardType w = (WildcardType)s;
+        WildcardType w = (WildcardType)s.unannotatedType();
         return w.kind == t.kind && w.type == t.type;
     }
 
@@ -1373,8 +1392,8 @@
 
                 if (t.isCompound() || s.isCompound()) {
                     return !t.isCompound() ?
-                            visitIntersectionType((IntersectionClassType)s, t, true) :
-                            visitIntersectionType((IntersectionClassType)t, s, false);
+                            visitIntersectionType((IntersectionClassType)s.unannotatedType(), t, true) :
+                            visitIntersectionType((IntersectionClassType)t.unannotatedType(), s, false);
                 }
 
                 if (s.tag == CLASS || s.tag == ARRAY) {
@@ -3070,7 +3089,7 @@
             for (Type t : tvars) {
                 if (!first) s.append(", ");
                 first = false;
-                appendTyparamString(((TypeVar)t), s);
+                appendTyparamString(((TypeVar)t.unannotatedType()), s);
             }
             s.append('>');
             return s.toString();
@@ -3710,9 +3729,9 @@
                !currentS.isEmpty()) {
             if (currentS.head != currentT.head) {
                 captured = true;
-                WildcardType Ti = (WildcardType)currentT.head;
+                WildcardType Ti = (WildcardType)currentT.head.unannotatedType();
                 Type Ui = currentA.head.getUpperBound();
-                CapturedType Si = (CapturedType)currentS.head;
+                CapturedType Si = (CapturedType)currentS.head.unannotatedType();
                 if (Ui == null)
                     Ui = syms.objectType;
                 switch (Ti.kind) {
@@ -3749,6 +3768,7 @@
             ListBuffer<Type> result = lb();
             for (Type t : types) {
                 if (t.tag == WILDCARD) {
+                    t = t.unannotatedType();
                     Type bound = ((WildcardType)t).getExtendsBound();
                     if (bound == null)
                         bound = syms.objectType;
@@ -3842,7 +3862,7 @@
 
     private boolean giveWarning(Type from, Type to) {
         List<Type> bounds = to.isCompound() ?
-                ((IntersectionClassType)to).getComponents() : List.of(to);
+                ((IntersectionClassType)to.unannotatedType()).getComponents() : List.of(to);
         for (Type b : bounds) {
             Type subFrom = asSub(from, b.tsym);
             if (b.isParameterized() &&
@@ -4107,7 +4127,7 @@
 
         Type B(Type t) {
             while (t.tag == WILDCARD) {
-                WildcardType w = (WildcardType)t;
+                WildcardType w = (WildcardType)t.unannotatedType();
                 t = high ?
                     w.getExtendsBound() :
                     w.getSuperBound();
@@ -4182,7 +4202,7 @@
 
         public boolean equals(Object obj) {
             return (obj instanceof UniqueType) &&
-                types.isSameType(type, ((UniqueType)obj).type);
+                types.isSameAnnotatedType(type, ((UniqueType)obj).type);
         }
 
         public String toString() {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Fri May 17 10:13:34 2013 -0700
@@ -216,18 +216,42 @@
     Attribute.Compound enterAnnotation(JCAnnotation a,
                                        Type expected,
                                        Env<AttrContext> env) {
+        return enterAnnotation(a, expected, env, false);
+    }
+
+    Attribute.TypeCompound enterTypeAnnotation(JCAnnotation a,
+            Type expected,
+            Env<AttrContext> env) {
+        return (Attribute.TypeCompound) enterAnnotation(a, expected, env, true);
+    }
+
+    // boolean typeAnnotation determines whether the method returns
+    // a Compound (false) or TypeCompound (true).
+    Attribute.Compound enterAnnotation(JCAnnotation a,
+            Type expected,
+            Env<AttrContext> env,
+            boolean typeAnnotation) {
         // The annotation might have had its type attributed (but not checked)
         // by attr.attribAnnotationTypes during MemberEnter, in which case we do not
         // need to do it again.
         Type at = (a.annotationType.type != null ? a.annotationType.type
                   : attr.attribType(a.annotationType, env));
         a.type = chk.checkType(a.annotationType.pos(), at, expected);
-        if (a.type.isErroneous())
-            return new Attribute.Compound(a.type, List.<Pair<MethodSymbol,Attribute>>nil());
+        if (a.type.isErroneous()) {
+            if (typeAnnotation) {
+                return new Attribute.TypeCompound(a.type, List.<Pair<MethodSymbol,Attribute>>nil(), null);
+            } else {
+                return new Attribute.Compound(a.type, List.<Pair<MethodSymbol,Attribute>>nil());
+            }
+        }
         if ((a.type.tsym.flags() & Flags.ANNOTATION) == 0) {
             log.error(a.annotationType.pos(),
                       "not.annotation.type", a.type.toString());
-            return new Attribute.Compound(a.type, List.<Pair<MethodSymbol,Attribute>>nil());
+            if (typeAnnotation) {
+                return new Attribute.TypeCompound(a.type, List.<Pair<MethodSymbol,Attribute>>nil(), null);
+            } else {
+                return new Attribute.Compound(a.type, List.<Pair<MethodSymbol,Attribute>>nil());
+            }
         }
         List<JCExpression> args = a.args;
         if (args.length() == 1 && !args.head.hasTag(ASSIGN)) {
@@ -266,12 +290,21 @@
                            ((MethodSymbol)method, value));
             t.type = result;
         }
-        // TODO: this should be a TypeCompound if "a" is a JCTypeAnnotation.
-        // However, how do we find the correct position?
-        Attribute.Compound ac = new Attribute.Compound(a.type, buf.toList());
-        // TODO: is this something we want? Who would use it?
-        // a.attribute = ac;
-        return ac;
+        if (typeAnnotation) {
+            if (a.attribute == null || !(a.attribute instanceof Attribute.TypeCompound)) {
+                // Create a new TypeCompound
+                Attribute.TypeCompound tc = new Attribute.TypeCompound(a.type, buf.toList(), new TypeAnnotationPosition());
+                a.attribute = tc;
+                return tc;
+            } else {
+                // Use an existing TypeCompound
+                return a.attribute;
+            }
+        } else {
+            Attribute.Compound ac = new Attribute.Compound(a.type, buf.toList());
+            a.attribute = ac;
+            return ac;
+        }
     }
 
     Attribute enterAttributeValue(Type expected,
@@ -354,15 +387,6 @@
         return new Attribute.Error(attr.attribExpr(tree, env, expected));
     }
 
-    Attribute.TypeCompound enterTypeAnnotation(JCAnnotation a,
-            Type expected,
-            Env<AttrContext> env) {
-        Attribute.Compound c = enterAnnotation(a, expected, env);
-        Attribute.TypeCompound tc = new Attribute.TypeCompound(c.type, c.values, new TypeAnnotationPosition());
-        a.attribute = tc;
-        return tc;
-    }
-
     /* *********************************
      * Support for repeating annotations
      ***********************************/
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri May 17 10:13:34 2013 -0700
@@ -768,7 +768,12 @@
         JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile);
 
         try {
-            memberEnter.typeAnnotate(initializer, env, env.info.enclVar);
+            // Use null as symbol to not attach the type annotation to any symbol.
+            // The initializer will later also be visited and then we'll attach
+            // to the symbol.
+            // This prevents having multiple type annotations, just because of
+            // lazy constant value evaluation.
+            memberEnter.typeAnnotate(initializer, env, null);
             annotate.flush();
             Type itype = attribExpr(initializer, env, type);
             if (itype.constValue() != null)
@@ -935,11 +940,6 @@
                 Env<AttrContext> newEnv = memberEnter.methodEnv(tree, env);
                 attribType(tree.recvparam, newEnv);
                 chk.validate(tree.recvparam, newEnv);
-                if (!(tree.recvparam.type == m.owner.type || types.isSameType(tree.recvparam.type, m.owner.type))) {
-                    // The == covers the common non-generic case, but for generic classes we need isSameType;
-                    // note that equals didn't work.
-                    log.error(tree.recvparam.pos(), "incorrect.receiver.type");
-                }
             }
 
             // annotation method checks
@@ -1056,7 +1056,10 @@
         Lint prevLint = chk.setLint(lint);
 
         // Check that the variable's declared type is well-formed.
-        chk.validate(tree.vartype, env);
+        boolean isImplicitLambdaParameter = env.tree.hasTag(LAMBDA) &&
+                ((JCLambda)env.tree).paramKind == JCLambda.ParameterKind.IMPLICIT &&
+                (tree.sym.flags() & PARAMETER) != 0;
+        chk.validate(tree.vartype, env, !isImplicitLambdaParameter);
         deferredLintHandler.flush(tree.pos());
 
         try {
@@ -1112,6 +1115,18 @@
             memberEnter.typeAnnotate(tree, localEnv, localEnv.info.scope.owner);
             annotate.flush();
 
+            {
+                // Store init and clinit type annotations with the ClassSymbol
+                // to allow output in Gen.normalizeDefs.
+                ClassSymbol cs = (ClassSymbol)env.info.scope.owner;
+                List<Attribute.TypeCompound> tas = localEnv.info.scope.owner.getRawTypeAttributes();
+                if ((tree.flags & STATIC) != 0) {
+                    cs.annotations.appendClassInitTypeAttributes(tas);
+                } else {
+                    cs.annotations.appendInitTypeAttributes(tas);
+                }
+            }
+
             attribStats(tree.stats, localEnv);
         } else {
             // Create a new local environment with a local scope.
@@ -1338,7 +1353,7 @@
                         //check that resource type cannot throw InterruptedException
                         checkAutoCloseable(resource.pos(), localEnv, resource.type);
 
-                        VarSymbol var = (VarSymbol)TreeInfo.symbolFor(resource);
+                        VarSymbol var = ((JCVariableDecl) resource).sym;
                         var.setData(ElementKind.RESOURCE_VARIABLE);
                     } else {
                         attribTree(resource, tryEnv, twrResult);
@@ -2131,6 +2146,11 @@
                     tree.constructor,
                     localEnv,
                     new ResultInfo(VAL, newMethodTemplate(syms.voidType, argtypes, typeargtypes)));
+            } else {
+                if (tree.clazz.hasTag(ANNOTATED_TYPE)) {
+                    checkForDeclarationAnnotations(((JCAnnotatedType) tree.clazz).annotations,
+                            tree.clazz.type.tsym);
+                }
             }
 
             if (tree.constructor != null && tree.constructor.kind == MTH)
@@ -2195,6 +2215,20 @@
                 }
             }
 
+    private void checkForDeclarationAnnotations(List<? extends JCAnnotation> annotations,
+            Symbol sym) {
+        // Ensure that no declaration annotations are present.
+        // Note that a tree type might be an AnnotatedType with
+        // empty annotations, if only declaration annotations were given.
+        // This method will raise an error for such a type.
+        for (JCAnnotation ai : annotations) {
+            if (TypeAnnotations.annotationType(syms, names, ai.attribute, sym) == TypeAnnotations.AnnotationType.DECLARATION) {
+                log.error(ai.pos(), "annotation.type.not.applicable");
+            }
+        }
+    }
+
+
     /** Make an attributed null check tree.
      */
     public JCExpression makeNullCheck(JCExpression arg) {
@@ -2221,6 +2255,10 @@
                 attribExpr(l.head, localEnv, syms.intType);
                 owntype = new ArrayType(owntype, syms.arrayClass);
             }
+            if (tree.elemtype.hasTag(ANNOTATED_TYPE)) {
+                checkForDeclarationAnnotations(((JCAnnotatedType) tree.elemtype).annotations,
+                        tree.elemtype.type.tsym);
+            }
         } else {
             // we are seeing an untyped aggregate { ... }
             // this is allowed only if the prototype is an array
@@ -2309,7 +2347,7 @@
                     Type argType = arityMismatch ?
                             syms.errType :
                             actuals.head;
-                    params.head.vartype = make.Type(argType);
+                    params.head.vartype = make.at(params.head).Type(argType);
                     params.head.sym = null;
                     actuals = actuals.isEmpty() ?
                             actuals :
@@ -2356,7 +2394,8 @@
                     for (JCDiagnostic deferredDiag : lambdaDeferredHandler.getDiagnostics()) {
                         if (deferredDiag.getKind() == JCDiagnostic.Kind.ERROR) {
                             resultInfo.checkContext
-                                    .report(that, diags.fragment("bad.arg.types.in.lambda", TreeInfo.types(that.params)));
+                                    .report(that, diags.fragment("bad.arg.types.in.lambda", TreeInfo.types(that.params),
+                                    deferredDiag)); //hidden diag parameter
                             //we mark the lambda as erroneous - this is crucial in the recovery step
                             //as parameter-dependent type error won't be reported in that stage,
                             //meaning that a lambda will be deemed erroeneous only if there is
@@ -2606,10 +2645,11 @@
                 return;
             }
 
-            if (TreeInfo.isStaticSelector(that.expr, names) &&
-                    (that.getMode() != ReferenceMode.NEW || !that.expr.type.isRaw())) {
-                //if the qualifier is a type, validate it
-                chk.validate(that.expr, env);
+            if (TreeInfo.isStaticSelector(that.expr, names)) {
+                //if the qualifier is a type, validate it; raw warning check is
+                //omitted as we don't know at this stage as to whether this is a
+                //raw selector (because of inference)
+                chk.validate(that.expr, env, false);
             }
 
             //attrib type-arguments
@@ -2695,6 +2735,13 @@
 
             if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
 
+                if (that.getMode() == ReferenceMode.INVOKE &&
+                        TreeInfo.isStaticSelector(that.expr, names) &&
+                        that.kind.isUnbound() &&
+                        !desc.getParameterTypes().head.isParameterized()) {
+                    chk.checkRaw(that.expr, localEnv);
+                }
+
                 if (!that.kind.isUnbound() &&
                         that.getMode() == ReferenceMode.INVOKE &&
                         TreeInfo.isStaticSelector(that.expr, names) &&
@@ -3763,6 +3810,12 @@
                     }
                 }
                 owntype = new ClassType(clazzOuter, actuals, clazztype.tsym);
+                if (clazztype.isAnnotated()) {
+                    // Use the same AnnotatedType, because it will have
+                    // its annotations set later.
+                    ((AnnotatedType)clazztype).underlyingType = owntype;
+                    owntype = clazztype;
+                }
             } else {
                 if (formals.length() != 0) {
                     log.error(tree.pos(), "wrong.number.type.args",
@@ -3961,7 +4014,14 @@
 
         ListBuffer<Attribute.TypeCompound> buf = ListBuffer.lb();
         for (JCAnnotation anno : annotations) {
-            buf.append((Attribute.TypeCompound) anno.attribute);
+            if (anno.attribute != null) {
+                // TODO: this null-check is only needed for an obscure
+                // ordering issue, where annotate.flush is called when
+                // the attribute is not set yet. For an example failure
+                // try the referenceinfos/NestedTypes.java test.
+                // Any better solutions?
+                buf.append((Attribute.TypeCompound) anno.attribute);
+            }
         }
         return buf.toList();
     }
@@ -4266,15 +4326,12 @@
         tree.accept(typeAnnotationsValidator);
     }
     //where
-    private final JCTree.Visitor typeAnnotationsValidator =
-        new TreeScanner() {
+    private final JCTree.Visitor typeAnnotationsValidator = new TreeScanner() {
+
+        private boolean checkAllAnnotations = false;
+
         public void visitAnnotation(JCAnnotation tree) {
-            if (tree.hasTag(TYPE_ANNOTATION)) {
-                // TODO: It seems to WMD as if the annotation in
-                // parameters, in particular also the recvparam, are never
-                // of type JCTypeAnnotation and therefore never checked!
-                // Luckily this check doesn't really do anything that isn't
-                // also done elsewhere.
+            if (tree.hasTag(TYPE_ANNOTATION) || checkAllAnnotations) {
                 chk.validateTypeAnnotation(tree, false);
             }
             super.visitAnnotation(tree);
@@ -4288,15 +4345,10 @@
             // super.visitTypeParameter(tree);
         }
         public void visitMethodDef(JCMethodDecl tree) {
-            // Static methods cannot have receiver type annotations.
-            // In test case FailOver15.java, the nested method getString has
-            // a null sym, because an unknown class is instantiated.
-            // I would say it's safe to skip.
-            if (tree.sym != null && (tree.sym.flags() & Flags.STATIC) != 0) {
-                if (tree.recvparam != null) {
-                    // TODO: better error message. Is the pos good?
-                    log.error(tree.recvparam.pos(), "annotation.type.not.applicable");
-                }
+            if (tree.recvparam != null &&
+                    tree.recvparam.vartype.type.getKind() != TypeKind.ERROR) {
+                checkForDeclarationAnnotations(tree.recvparam.mods.annotations,
+                        tree.recvparam.vartype.type.tsym);
             }
             if (tree.restype != null && tree.restype.type != null) {
                 validateAnnotatedType(tree.restype, tree.restype.type);
@@ -4318,9 +4370,30 @@
                 validateAnnotatedType(tree.clazz, tree.clazz.type);
             super.visitTypeTest(tree);
         }
-        // TODO: what else do we need?
-        // public void visitNewClass(JCNewClass tree) {
-        // public void visitNewArray(JCNewArray tree) {
+        public void visitNewClass(JCNewClass tree) {
+            if (tree.clazz.hasTag(ANNOTATED_TYPE)) {
+                boolean prevCheck = this.checkAllAnnotations;
+                try {
+                    this.checkAllAnnotations = true;
+                    scan(((JCAnnotatedType)tree.clazz).annotations);
+                } finally {
+                    this.checkAllAnnotations = prevCheck;
+                }
+            }
+            super.visitNewClass(tree);
+        }
+        public void visitNewArray(JCNewArray tree) {
+            if (tree.elemtype != null && tree.elemtype.hasTag(ANNOTATED_TYPE)) {
+                boolean prevCheck = this.checkAllAnnotations;
+                try {
+                    this.checkAllAnnotations = true;
+                    scan(((JCAnnotatedType)tree.elemtype).annotations);
+                } finally {
+                    this.checkAllAnnotations = prevCheck;
+                }
+            }
+            super.visitNewArray(tree);
+        }
 
         /* I would want to model this after
          * com.sun.tools.javac.comp.Check.Validator.visitSelectInternal(JCFieldAccess)
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri May 17 10:13:34 2013 -0700
@@ -1213,7 +1213,7 @@
 
     /** Validate a type expression. That is,
      *  check that all type arguments of a parametric type are within
-     *  their bounds. This must be done in a second phase after type attributon
+     *  their bounds. This must be done in a second phase after type attribution
      *  since a class might have a subclass as type parameter bound. E.g:
      *
      *  <pre>{@code
@@ -1361,23 +1361,23 @@
             for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail)
                 validateTree(l.head, checkRaw, isOuter);
         }
-
-        void checkRaw(JCTree tree, Env<AttrContext> env) {
-            if (lint.isEnabled(LintCategory.RAW) &&
-                tree.type.hasTag(CLASS) &&
-                !TreeInfo.isDiamond(tree) &&
-                !withinAnonConstr(env) &&
-                tree.type.isRaw()) {
-                log.warning(LintCategory.RAW,
-                        tree.pos(), "raw.class.use", tree.type, tree.type.tsym.type);
-            }
+    }
+
+    void checkRaw(JCTree tree, Env<AttrContext> env) {
+        if (lint.isEnabled(LintCategory.RAW) &&
+            tree.type.hasTag(CLASS) &&
+            !TreeInfo.isDiamond(tree) &&
+            !withinAnonConstr(env) &&
+            tree.type.isRaw()) {
+            log.warning(LintCategory.RAW,
+                    tree.pos(), "raw.class.use", tree.type, tree.type.tsym.type);
         }
-
-        boolean withinAnonConstr(Env<AttrContext> env) {
+    }
+    //where
+        private boolean withinAnonConstr(Env<AttrContext> env) {
             return env.enclClass.name.isEmpty() &&
                     env.enclMethod != null && env.enclMethod.name == names.init;
         }
-    }
 
 /* *************************************************************************
  * Exception checking
@@ -3024,9 +3024,9 @@
         // collect an inventory of the annotation elements
         Set<MethodSymbol> members = new LinkedHashSet<MethodSymbol>();
         for (Scope.Entry e = a.annotationType.type.tsym.members().elems;
-             e != null;
-             e = e.sibling)
-            if (e.sym.kind == MTH)
+                e != null;
+                e = e.sibling)
+            if (e.sym.kind == MTH && e.sym.name != names.clinit)
                 members.add((MethodSymbol) e.sym);
 
         // remove the ones that are assigned values
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Fri May 17 10:13:34 2013 -0700
@@ -25,12 +25,11 @@
 package com.sun.tools.javac.comp;
 
 import com.sun.tools.javac.tree.*;
-import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind;
 import com.sun.tools.javac.tree.TreeMaker;
-import com.sun.tools.javac.tree.TreeScanner;
 import com.sun.tools.javac.tree.TreeTranslator;
+import com.sun.tools.javac.code.Attribute;
 import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Scope;
 import com.sun.tools.javac.code.Symbol;
@@ -46,7 +45,6 @@
 import com.sun.tools.javac.comp.Lower.BasicFreeVarCollector;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
 
@@ -166,7 +164,7 @@
         return translate(tree, newContext != null ? newContext : context);
     }
 
-    public <T extends JCTree> T translate(T tree, TranslationContext<?> newContext) {
+    <T extends JCTree> T translate(T tree, TranslationContext<?> newContext) {
         TranslationContext<?> prevContext = context;
         try {
             context = newContext;
@@ -177,7 +175,7 @@
         }
     }
 
-    public <T extends JCTree> List<T> translate(List<T> trees, TranslationContext<?> newContext) {
+    <T extends JCTree> List<T> translate(List<T> trees, TranslationContext<?> newContext) {
         ListBuffer<T> buf = ListBuffer.lb();
         for (T tree : trees) {
             buf.append(translate(tree, newContext));
@@ -238,6 +236,24 @@
         MethodSymbol sym = (MethodSymbol)localContext.translatedSym;
         MethodType lambdaType = (MethodType) sym.type;
 
+        {
+            MethodSymbol owner = (MethodSymbol) localContext.owner;
+            ListBuffer<Attribute.TypeCompound> ownerTypeAnnos = new ListBuffer<Attribute.TypeCompound>();
+            ListBuffer<Attribute.TypeCompound> lambdaTypeAnnos = new ListBuffer<Attribute.TypeCompound>();
+
+            for (Attribute.TypeCompound tc : owner.getRawTypeAttributes()) {
+                if (tc.position.onLambda == tree) {
+                    lambdaTypeAnnos.append(tc);
+                } else {
+                    ownerTypeAnnos.append(tc);
+                }
+            }
+            if (lambdaTypeAnnos.nonEmpty()) {
+                owner.annotations.setTypeAttributes(ownerTypeAnnos.toList());
+                sym.annotations.setTypeAttributes(lambdaTypeAnnos.toList());
+            }
+        }
+
         //create the method declaration hoisting the lambda body
         JCMethodDecl lambdaDecl = make.MethodDef(make.Modifiers(sym.flags_field),
                 sym.name,
@@ -373,12 +389,15 @@
             if (lambdaContext.getSymbolMap(PARAM).containsKey(tree.sym)) {
                 Symbol translatedSym = lambdaContext.getSymbolMap(PARAM).get(tree.sym);
                 result = make.Ident(translatedSym).setType(tree.type);
+                translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes());
             } else if (lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) {
                 Symbol translatedSym = lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym);
                 result = make.Ident(translatedSym).setType(tree.type);
+                translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes());
             } else if (lambdaContext.getSymbolMap(TYPE_VAR).containsKey(tree.sym)) {
                 Symbol translatedSym = lambdaContext.getSymbolMap(TYPE_VAR).get(tree.sym);
                 result = make.Ident(translatedSym).setType(translatedSym.type);
+                translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes());
             } else if (lambdaContext.getSymbolMap(CAPTURED_VAR).containsKey(tree.sym)) {
                 Symbol translatedSym = lambdaContext.getSymbolMap(CAPTURED_VAR).get(tree.sym);
                 result = make.Ident(translatedSym).setType(tree.type);
@@ -1252,8 +1271,17 @@
                 List<Type> ptypes = ((MethodType) consSym.type).getParameterTypes();
                 Type classType = consSym.owner.type;
 
+                // Build lambda parameters
+                // partially cloned from TreeMaker.Params until 8014021 is fixed
+                Symbol owner = owner();
+                ListBuffer<JCVariableDecl> paramBuff = new ListBuffer<JCVariableDecl>();
+                int i = 0;
+                for (List<Type> l = ptypes; l.nonEmpty(); l = l.tail) {
+                    paramBuff.append(make.Param(make.paramName(i++), l.head, owner));
+                }
+                List<JCVariableDecl> params = paramBuff.toList();
+
                 // Make new-class call
-                List<JCVariableDecl> params = make.Params(ptypes, owner());
                 JCNewClass nc = makeNewClass(classType, make.Idents(params));
                 nc.pos = tree.pos;
 
@@ -1274,7 +1302,11 @@
 
         @Override
         public void visitSelect(JCFieldAccess tree) {
-            if (context() != null && lambdaSelectSymbolFilter(tree.sym)) {
+            if (context() != null && tree.sym.kind == VAR &&
+                        (tree.sym.name == names._this ||
+                         tree.sym.name == names._super)) {
+                // A select of this or super means, if we are in a lambda,
+                // we much have an instance context
                 TranslationContext<?> localContext = context();
                 while (localContext != null) {
                     if (localContext.tree.hasTag(LAMBDA)) {
@@ -1525,13 +1557,6 @@
                     && sym.name != names.init;
         }
 
-        private boolean lambdaSelectSymbolFilter(Symbol sym) {
-            return (sym.kind == VAR || sym.kind == MTH) &&
-                        !sym.isStatic() &&
-                        (sym.name == names._this ||
-                        sym.name == names._super);
-        }
-
         /**
          * This is used to filter out those new class expressions that need to
          * be qualified with an enclosing tree
@@ -1667,24 +1692,33 @@
              * synthetic lambda body
              */
             Symbol translate(Name name, final Symbol sym, LambdaSymbolKind skind) {
+                Symbol ret;
                 switch (skind) {
                     case CAPTURED_THIS:
-                        return sym;  // self represented
+                        ret = sym;  // self represented
+                        break;
                     case TYPE_VAR:
                         // Just erase the type var
-                        return new VarSymbol(sym.flags(), name,
+                        ret = new VarSymbol(sym.flags(), name,
                                 types.erasure(sym.type), sym.owner);
+                        break;
                     case CAPTURED_VAR:
-                        return new VarSymbol(SYNTHETIC | FINAL, name, types.erasure(sym.type), translatedSym) {
+                        ret = new VarSymbol(SYNTHETIC | FINAL, name, types.erasure(sym.type), translatedSym) {
                             @Override
                             public Symbol baseSymbol() {
                                 //keep mapping with original captured symbol
                                 return sym;
                             }
                         };
+                        break;
                     default:
-                        return makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym);
+                        ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym);
                 }
+                if (ret != sym) {
+                    ret.annotations.setDeclarationAttributes(sym.getRawAttributes());
+                    ret.annotations.setTypeAttributes(sym.getRawTypeAttributes());
+                }
+                return ret;
             }
 
             void addSymbol(Symbol sym, LambdaSymbolKind skind) {
@@ -1755,12 +1789,13 @@
                 }
                 boolean inInterface = translatedSym.owner.isInterface();
                 boolean thisReferenced = !getSymbolMap(CAPTURED_THIS).isEmpty();
-                boolean needInstance = thisReferenced || inInterface;
 
-                // If instance access isn't needed, make it static
-                // Interface methods much be public default methods, otherwise make it private
-                translatedSym.flags_field = SYNTHETIC | (needInstance? 0 : STATIC) |
-                        (inInterface? PUBLIC | DEFAULT : PRIVATE);
+                // If instance access isn't needed, make it static.
+                // Interface instance methods must be default methods.
+                // Awaiting VM channges, default methods are public
+                translatedSym.flags_field = SYNTHETIC |
+                        ((inInterface && thisReferenced)? PUBLIC : PRIVATE) |
+                        (thisReferenced? (inInterface? DEFAULT : 0) : STATIC);
 
                 //compute synthetic params
                 ListBuffer<JCVariableDecl> params = ListBuffer.lb();
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Fri May 17 10:13:34 2013 -0700
@@ -28,6 +28,7 @@
 import java.util.*;
 
 import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Type.AnnotatedType;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.main.Option.PkgInfo;
 import com.sun.tools.javac.tree.*;
@@ -2767,10 +2768,28 @@
         }
 
     public void visitAnnotatedType(JCAnnotatedType tree) {
-        // No need to retain type annotations any longer.
+        // No need to retain type annotations in the tree
         // tree.annotations = translate(tree.annotations);
+        tree.annotations = List.nil();
         tree.underlyingType = translate(tree.underlyingType);
-        result = tree.underlyingType;
+        // but maintain type annotations in the type.
+        if (tree.type.isAnnotated()) {
+            if (tree.underlyingType.type.isAnnotated()) {
+                // The erasure of a type variable might be annotated.
+                // Merge all annotations.
+                AnnotatedType newat = (AnnotatedType) tree.underlyingType.type;
+                AnnotatedType at = (AnnotatedType) tree.type;
+                at.underlyingType = newat.underlyingType;
+                newat.typeAnnotations = at.typeAnnotations.appendList(newat.typeAnnotations);
+                tree.type = newat;
+            } else {
+                // Create a new AnnotatedType to have the correct tag.
+                AnnotatedType oldat = (AnnotatedType) tree.type;
+                tree.type = new AnnotatedType(tree.underlyingType.type);
+                ((AnnotatedType) tree.type).typeAnnotations = oldat.typeAnnotations;
+            }
+        }
+        result = tree;
     }
 
     public void visitTypeCast(JCTypeCast tree) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Fri May 17 10:13:34 2013 -0700
@@ -31,7 +31,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import javax.lang.model.type.TypeKind;
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.code.*;
@@ -617,7 +616,26 @@
             if (TreeInfo.isEnumInit(tree)) {
                 attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype);
             } else {
+                // Make sure type annotations are processed.
+                // But we don't have a symbol to attach them to yet - use null.
+                typeAnnotate(tree.vartype, env, null);
                 attr.attribType(tree.vartype, localEnv);
+                if (tree.nameexpr != null) {
+                    attr.attribExpr(tree.nameexpr, localEnv);
+                    MethodSymbol m = localEnv.enclMethod.sym;
+                    if (m.isConstructor()) {
+                        Type outertype = m.owner.owner.type;
+                        if (outertype.hasTag(TypeTag.CLASS)) {
+                            checkType(tree.vartype, outertype, "incorrect.constructor.receiver.type");
+                            checkType(tree.nameexpr, outertype, "incorrect.constructor.receiver.name");
+                        } else {
+                            log.error(tree, "receiver.parameter.not.applicable.constructor.toplevel.class");
+                        }
+                    } else {
+                        checkType(tree.vartype, m.owner.type, "incorrect.receiver.type");
+                        checkType(tree.nameexpr, m.owner.type, "incorrect.receiver.name");
+                    }
+                }
             }
         } finally {
             chk.setDeferredLintHandler(prevLintHandler);
@@ -651,10 +669,16 @@
             enclScope.enter(v);
         }
         annotateLater(tree.mods.annotations, localEnv, v);
-        typeAnnotate(tree.vartype, env, tree.sym);
+        typeAnnotate(tree.vartype, env, v);
         annotate.flush();
         v.pos = tree.pos;
     }
+    // where
+    void checkType(JCTree tree, Type type, String diag) {
+        if (!tree.type.isErroneous() && !types.isSameType(tree.type, type)) {
+            log.error(tree, diag, type, tree.type);
+        }
+    }
 
     /** Create a fresh environment for a variable's initializer.
      *  If the variable is a field, the owner of the environment's scope
@@ -1040,9 +1064,12 @@
                 isFirst = true;
             }
         }
-        annotate.afterRepeated(TypeAnnotations.organizeTypeAnnotationsSignatures(syms, names, log, tree));
+        TypeAnnotations.organizeTypeAnnotationsSignatures(syms, names, log, tree, annotate);
     }
 
+    /*
+     * If the symbol is non-null, attach the type annotation to it.
+     */
     private void actualEnterTypeAnnotations(final List<JCAnnotation> annotations,
             final Env<AttrContext> env,
             final Symbol s) {
@@ -1075,8 +1102,10 @@
             }
         }
 
-        s.annotations.appendTypeAttributesWithCompletion(
-                annotate.new AnnotateRepeatedContext<Attribute.TypeCompound>(env, annotated, pos, log, true));
+        if (s != null) {
+            s.annotations.appendTypeAttributesWithCompletion(
+                    annotate.new AnnotateRepeatedContext<Attribute.TypeCompound>(env, annotated, pos, log, true));
+        }
     }
 
     public void typeAnnotate(final JCTree tree, final Env<AttrContext> env, final Symbol sym) {
@@ -1150,6 +1179,33 @@
             // Do not annotate the body, just the signature.
             // scan(tree.body);
         }
+
+        @Override
+        public void visitVarDef(final JCVariableDecl tree) {
+            if (sym != null && sym.kind == Kinds.VAR) {
+                // Don't visit a parameter once when the sym is the method
+                // and once when the sym is the parameter.
+                scan(tree.mods);
+                scan(tree.vartype);
+            }
+            scan(tree.init);
+        }
+
+        @Override
+        public void visitClassDef(JCClassDecl tree) {
+            // We can only hit a classdef if it is declared within
+            // a method. Ignore it - the class will be visited
+            // separately later.
+        }
+
+        @Override
+        public void visitNewClass(JCNewClass tree) {
+            if (tree.def == null) {
+                // For an anonymous class instantiation the class
+                // will be visited separately.
+                super.visitNewClass(tree);
+            }
+        }
     }
 
 
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri May 17 10:13:34 2013 -0700
@@ -37,7 +37,10 @@
 import com.sun.tools.javac.comp.Infer.InferenceContext;
 import com.sun.tools.javac.comp.Infer.FreeTypeListener;
 import com.sun.tools.javac.comp.Resolve.MethodResolutionContext.Candidate;
+import com.sun.tools.javac.comp.Resolve.MethodResolutionDiagHelper.DiagnosticRewriter;
+import com.sun.tools.javac.comp.Resolve.MethodResolutionDiagHelper.Template;
 import com.sun.tools.javac.jvm.*;
+import com.sun.tools.javac.main.Option;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind;
@@ -94,6 +97,7 @@
     public final boolean allowDefaultMethods;
     public final boolean allowStructuralMostSpecific;
     private final boolean debugResolve;
+    private final boolean compactMethodDiags;
     final EnumSet<VerboseResolutionMode> verboseResolutionMode;
 
     Scope polymorphicSignatureScope;
@@ -124,6 +128,8 @@
         varargsEnabled = source.allowVarargs();
         Options options = Options.instance(context);
         debugResolve = options.isSet("debugresolve");
+        compactMethodDiags = options.isSet(Option.XDIAGS, "compact") ||
+                options.isUnset(Option.XDIAGS) && options.isUnset("rawDiagnostics");
         verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options);
         Target target = Target.instance(context);
         allowMethodHandles = target.hasMethodHandles();
@@ -661,6 +667,10 @@
             this.basicKey = basicKey;
             this.inferKey = inferKey;
         }
+
+        String regex() {
+            return String.format("([a-z]*\\.)*(%s|%s)", basicKey, inferKey);
+        }
     }
 
     /**
@@ -691,6 +701,7 @@
                                     Warner warn) {
             //should we expand formals?
             boolean useVarargs = deferredAttrContext.phase.isVarargsRequired();
+            List<JCExpression> trees = TreeInfo.args(env.tree);
 
             //inference context used during this method check
             InferenceContext inferenceContext = deferredAttrContext.inferenceContext;
@@ -699,17 +710,19 @@
 
             if (varargsFormal == null &&
                     argtypes.size() != formals.size()) {
-                reportMC(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
+                reportMC(env.tree, MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
             }
 
             while (argtypes.nonEmpty() && formals.head != varargsFormal) {
-                checkArg(false, argtypes.head, formals.head, deferredAttrContext, warn);
+                DiagnosticPosition pos = trees != null ? trees.head : null;
+                checkArg(pos, false, argtypes.head, formals.head, deferredAttrContext, warn);
                 argtypes = argtypes.tail;
                 formals = formals.tail;
+                trees = trees != null ? trees.tail : trees;
             }
 
             if (formals.head != varargsFormal) {
-                reportMC(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
+                reportMC(env.tree, MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
             }
 
             if (useVarargs) {
@@ -717,8 +730,10 @@
                 //the last argument of a varargs is _not_ an array type (see JLS 15.12.2.5)
                 final Type elt = types.elemtype(varargsFormal);
                 while (argtypes.nonEmpty()) {
-                    checkArg(true, argtypes.head, elt, deferredAttrContext, warn);
+                    DiagnosticPosition pos = trees != null ? trees.head : null;
+                    checkArg(pos, true, argtypes.head, elt, deferredAttrContext, warn);
                     argtypes = argtypes.tail;
+                    trees = trees != null ? trees.tail : trees;
                 }
             }
         }
@@ -726,9 +741,9 @@
         /**
          * Does the actual argument conforms to the corresponding formal?
          */
-        abstract void checkArg(boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn);
-
-        protected void reportMC(MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
+        abstract void checkArg(DiagnosticPosition pos, boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn);
+
+        protected void reportMC(DiagnosticPosition pos, MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
             boolean inferDiag = inferenceContext != infer.emptyContext;
             InapplicableMethodException ex = inferDiag ?
                     infer.inferenceException : inapplicableMethodException;
@@ -738,7 +753,8 @@
                 args2[0] = inferenceContext.inferenceVars();
                 args = args2;
             }
-            throw ex.setMessage(inferDiag ? diag.inferKey : diag.basicKey, args);
+            String key = inferDiag ? diag.inferKey : diag.basicKey;
+            throw ex.setMessage(diags.create(DiagnosticType.FRAGMENT, log.currentSource(), pos, key, args));
         }
 
         public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
@@ -752,7 +768,7 @@
      */
     MethodCheck arityMethodCheck = new AbstractMethodCheck() {
         @Override
-        void checkArg(boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) {
+        void checkArg(DiagnosticPosition pos, boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) {
             //do nothing - actual always compatible to formals
         }
     };
@@ -778,9 +794,9 @@
     MethodCheck resolveMethodCheck = new AbstractMethodCheck() {
 
         @Override
-        void checkArg(boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) {
+        void checkArg(DiagnosticPosition pos, boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) {
             ResultInfo mresult = methodCheckResult(varargs, formal, deferredAttrContext, warn);
-            mresult.check(null, actual);
+            mresult.check(pos, actual);
         }
 
         @Override
@@ -809,7 +825,7 @@
             } else {
                 if (!isAccessible(env, t)) {
                     Symbol location = env.enclClass.sym;
-                    reportMC(MethodCheckDiag.INACCESSIBLE_VARARGS, inferenceContext, t, Kinds.kindName(location), location);
+                    reportMC(env.tree, MethodCheckDiag.INACCESSIBLE_VARARGS, inferenceContext, t, Kinds.kindName(location), location);
                 }
             }
         }
@@ -822,7 +838,7 @@
 
                 @Override
                 public void report(DiagnosticPosition pos, JCDiagnostic details) {
-                    reportMC(methodDiag, deferredAttrContext.inferenceContext, details);
+                    reportMC(pos, methodDiag, deferredAttrContext.inferenceContext, details);
                 }
             };
             return new MethodResultInfo(to, checkContext);
@@ -3327,6 +3343,18 @@
             }
             else {
                 Candidate c = errCandidate();
+                if (compactMethodDiags) {
+                    for (Map.Entry<Template, DiagnosticRewriter> _entry :
+                            MethodResolutionDiagHelper.rewriters.entrySet()) {
+                        if (_entry.getKey().matches(c.details)) {
+                            JCDiagnostic simpleDiag =
+                                    _entry.getValue().rewriteDiagnostic(diags, pos,
+                                        log.currentSource(), dkind, c.details);
+                            simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
+                            return simpleDiag;
+                        }
+                    }
+                }
                 Symbol ws = c.sym.asMemberOf(site, types);
                 return diags.create(dkind, log.currentSource(), pos,
                           "cant.apply.symbol",
@@ -3375,35 +3403,75 @@
                 Name name,
                 List<Type> argtypes,
                 List<Type> typeargtypes) {
-            if (!resolveContext.candidates.isEmpty()) {
+            Map<Symbol, JCDiagnostic> candidatesMap = mapCandidates();
+            Map<Symbol, JCDiagnostic> filteredCandidates = filterCandidates(candidatesMap);
+            if (filteredCandidates.isEmpty()) {
+                filteredCandidates = candidatesMap;
+            }
+            boolean truncatedDiag = candidatesMap.size() != filteredCandidates.size();
+            if (filteredCandidates.size() > 1) {
                 JCDiagnostic err = diags.create(dkind,
+                        null,
+                        truncatedDiag ?
+                            EnumSet.of(DiagnosticFlag.COMPRESSED) :
+                            EnumSet.noneOf(DiagnosticFlag.class),
                         log.currentSource(),
                         pos,
                         "cant.apply.symbols",
                         name == names.init ? KindName.CONSTRUCTOR : absentKind(kind),
                         name == names.init ? site.tsym.name : name,
                         methodArguments(argtypes));
-                return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(site));
+                return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(filteredCandidates, site));
+            } else if (filteredCandidates.size() == 1) {
+                JCDiagnostic d =  new InapplicableSymbolError(resolveContext).getDiagnostic(dkind, pos,
+                    location, site, name, argtypes, typeargtypes);
+                if (truncatedDiag) {
+                    d.setFlag(DiagnosticFlag.COMPRESSED);
+                }
+                return d;
             } else {
                 return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos,
                     location, site, name, argtypes, typeargtypes);
             }
         }
-
         //where
-        List<JCDiagnostic> candidateDetails(Type site) {
-            Map<Symbol, JCDiagnostic> details = new LinkedHashMap<Symbol, JCDiagnostic>();
-            for (Candidate c : resolveContext.candidates) {
-                if (c.isApplicable()) continue;
-                JCDiagnostic detailDiag = diags.fragment("inapplicable.method",
-                        Kinds.kindName(c.sym),
-                        c.sym.location(site, types),
-                        c.sym.asMemberOf(site, types),
-                        c.details);
-                details.put(c.sym, detailDiag);
+            private Map<Symbol, JCDiagnostic> mapCandidates() {
+                Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<Symbol, JCDiagnostic>();
+                for (Candidate c : resolveContext.candidates) {
+                    if (c.isApplicable()) continue;
+                    candidates.put(c.sym, c.details);
+                }
+                return candidates;
             }
-            return List.from(details.values());
-        }
+
+            Map<Symbol, JCDiagnostic> filterCandidates(Map<Symbol, JCDiagnostic> candidatesMap) {
+                Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<Symbol, JCDiagnostic>();
+                for (Map.Entry<Symbol, JCDiagnostic> _entry : candidatesMap.entrySet()) {
+                    JCDiagnostic d = _entry.getValue();
+                    if (!compactMethodDiags ||
+                            !new Template(MethodCheckDiag.ARITY_MISMATCH.regex()).matches(d)) {
+                        candidates.put(_entry.getKey(), d);
+                    }
+                }
+                return candidates;
+            }
+
+            private List<JCDiagnostic> candidateDetails(Map<Symbol, JCDiagnostic> candidatesMap, Type site) {
+                List<JCDiagnostic> details = List.nil();
+                for (Map.Entry<Symbol, JCDiagnostic> _entry : candidatesMap.entrySet()) {
+                    Symbol sym = _entry.getKey();
+                    JCDiagnostic detailDiag = diags.fragment("inapplicable.method",
+                            Kinds.kindName(sym),
+                            sym.location(site, types),
+                            sym.asMemberOf(site, types),
+                            _entry.getValue());
+                    details = details.prepend(detailDiag);
+                }
+                //typically members are visited in reverse order (see Scope)
+                //so we need to reverse the candidate list so that candidates
+                //conform to source order
+                return details;
+            }
     }
 
     /**
@@ -3624,6 +3692,105 @@
         }
     }
 
+    /**
+     * Helper class for method resolution diagnostic simplification.
+     * Certain resolution diagnostic are rewritten as simpler diagnostic
+     * where the enclosing resolution diagnostic (i.e. 'inapplicable method')
+     * is stripped away, as it doesn't carry additional info. The logic
+     * for matching a given diagnostic is given in terms of a template
+     * hierarchy: a diagnostic template can be specified programmatically,
+     * so that only certain diagnostics are matched. Each templete is then
+     * associated with a rewriter object that carries out the task of rewtiting
+     * the diagnostic to a simpler one.
+     */
+    static class MethodResolutionDiagHelper {
+
+        /**
+         * A diagnostic rewriter transforms a method resolution diagnostic
+         * into a simpler one
+         */
+        interface DiagnosticRewriter {
+            JCDiagnostic rewriteDiagnostic(JCDiagnostic.Factory diags,
+                    DiagnosticPosition preferedPos, DiagnosticSource preferredSource,
+                    DiagnosticType preferredKind, JCDiagnostic d);
+        }
+
+        /**
+         * A diagnostic template is made up of two ingredients: (i) a regular
+         * expression for matching a diagnostic key and (ii) a list of sub-templates
+         * for matching diagnostic arguments.
+         */
+        static class Template {
+
+            /** regex used to match diag key */
+            String regex;
+
+            /** templates used to match diagnostic args */
+            Template[] subTemplates;
+
+            Template(String key, Template... subTemplates) {
+                this.regex = key;
+                this.subTemplates = subTemplates;
+            }
+
+            /**
+             * Returns true if the regex matches the diagnostic key and if
+             * all diagnostic arguments are matches by corresponding sub-templates.
+             */
+            boolean matches(Object o) {
+                JCDiagnostic d = (JCDiagnostic)o;
+                Object[] args = d.getArgs();
+                if (!d.getCode().matches(regex) ||
+                        subTemplates.length != d.getArgs().length) {
+                    return false;
+                }
+                for (int i = 0; i < args.length ; i++) {
+                    if (!subTemplates[i].matches(args[i])) {
+                        return false;
+                    }
+                }
+                return true;
+            }
+        }
+
+        /** a dummy template that match any diagnostic argument */
+        static final Template skip = new Template("") {
+            @Override
+            boolean matches(Object d) {
+                return true;
+            }
+        };
+
+        /** rewriter map used for method resolution simplification */
+        static final Map<Template, DiagnosticRewriter> rewriters =
+                new LinkedHashMap<Template, DiagnosticRewriter>();
+
+        static {
+            String argMismatchRegex = MethodCheckDiag.ARG_MISMATCH.regex();
+            rewriters.put(new Template(argMismatchRegex, new Template("(.*)(bad.arg.types.in.lambda)", skip, skip)),
+                    new DiagnosticRewriter() {
+                @Override
+                public JCDiagnostic rewriteDiagnostic(JCDiagnostic.Factory diags,
+                        DiagnosticPosition preferedPos, DiagnosticSource preferredSource,
+                        DiagnosticType preferredKind, JCDiagnostic d) {
+                    return (JCDiagnostic)((JCDiagnostic)d.getArgs()[0]).getArgs()[1];
+                }
+            });
+
+            rewriters.put(new Template(argMismatchRegex, skip),
+                    new DiagnosticRewriter() {
+                @Override
+                public JCDiagnostic rewriteDiagnostic(JCDiagnostic.Factory diags,
+                        DiagnosticPosition preferedPos, DiagnosticSource preferredSource,
+                        DiagnosticType preferredKind, JCDiagnostic d) {
+                    JCDiagnostic cause = (JCDiagnostic)d.getArgs()[0];
+                    return diags.create(preferredKind, preferredSource, d.getDiagnosticPosition(),
+                            "prob.found.req", cause);
+                }
+            });
+        }
+    }
+
     enum MethodResolutionPhase {
         BASIC(false, false),
         BOX(true, false),
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri May 17 10:13:34 2013 -0700
@@ -1518,7 +1518,7 @@
             break;
         // exception parameter
         case EXCEPTION_PARAMETER:
-            position.exception_index = nextByte();
+            position.exception_index = nextChar();
             break;
         // method receiver
         case METHOD_RECEIVER:
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -632,7 +632,7 @@
             acount++;
         }
         acount += writeJavaAnnotations(sym.getRawAttributes());
-        acount += writeTypeAnnotations(sym.getRawTypeAttributes());
+        acount += writeTypeAnnotations(sym.getRawTypeAttributes(), false);
         return acount;
     }
 
@@ -759,44 +759,30 @@
         return attrCount;
     }
 
-    int writeTypeAnnotations(List<Attribute.TypeCompound> typeAnnos) {
+    int writeTypeAnnotations(List<Attribute.TypeCompound> typeAnnos, boolean inCode) {
         if (typeAnnos.isEmpty()) return 0;
 
         ListBuffer<Attribute.TypeCompound> visibles = ListBuffer.lb();
         ListBuffer<Attribute.TypeCompound> invisibles = ListBuffer.lb();
 
         for (Attribute.TypeCompound tc : typeAnnos) {
-            if (tc.position == null || tc.position.type == TargetType.UNKNOWN) {
-                boolean found = false;
-                // TODO: the position for the container annotation of a
-                // repeating type annotation has to be set.
-                // This cannot be done when the container is created, because
-                // then the position is not determined yet.
-                // How can we link these pieces better together?
-                if (tc.values.size() == 1) {
-                    Pair<MethodSymbol, Attribute> val = tc.values.get(0);
-                    if (val.fst.getSimpleName().contentEquals("value") &&
-                            val.snd instanceof Attribute.Array) {
-                        Attribute.Array arr = (Attribute.Array) val.snd;
-                        if (arr.values.length != 0 &&
-                                arr.values[0] instanceof Attribute.TypeCompound) {
-                            TypeCompound atycomp = (Attribute.TypeCompound) arr.values[0];
-                            if (atycomp.position.type != TargetType.UNKNOWN) {
-                                tc.position = atycomp.position;
-                                found = true;
-                            }
-                        }
-                    }
-                }
-                if (!found) {
+            if (tc.hasUnknownPosition()) {
+                boolean fixed = tc.tryFixPosition();
+
+                // Could we fix it?
+                if (!fixed) {
                     // This happens for nested types like @A Outer. @B Inner.
                     // For method parameters we get the annotation twice! Once with
                     // a valid position, once unknown.
                     // TODO: find a cleaner solution.
-                    // System.err.println("ClassWriter: Position UNKNOWN in type annotation: " + tc);
+                    PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
+                    pw.println("ClassWriter: Position UNKNOWN in type annotation: " + tc);
                     continue;
                 }
             }
+
+            if (tc.position.type.isLocal() != inCode)
+                continue;
             if (!tc.position.emitToClassfile())
                 continue;
             switch (types.getRetention(tc)) {
@@ -936,7 +922,7 @@
             break;
         // exception parameter
         case EXCEPTION_PARAMETER:
-            databuf.appendByte(p.exception_index);
+            databuf.appendChar(p.exception_index);
             break;
         // method receiver
         case METHOD_RECEIVER:
@@ -1241,6 +1227,9 @@
             endAttr(alenIdx);
             acount++;
         }
+
+        acount += writeTypeAnnotations(code.meth.getRawTypeAttributes(), true);
+
         endAttrs(acountIdx, acount);
     }
     //where
@@ -1627,7 +1616,7 @@
             out = null;
         } finally {
             if (out != null) {
-                // if we are propogating an exception, delete the file
+                // if we are propagating an exception, delete the file
                 out.close();
                 outFile.delete();
                 outFile = null;
@@ -1741,7 +1730,7 @@
 
         acount += writeFlagAttrs(c.flags());
         acount += writeJavaAnnotations(c.getRawAttributes());
-        acount += writeTypeAnnotations(c.getRawTypeAttributes());
+        acount += writeTypeAnnotations(c.getRawTypeAttributes(), false);
         acount += writeEnclosingMethodAttribute(c);
         acount += writeExtraClassAttributes(c);
 
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java	Fri May 17 10:13:34 2013 -0700
@@ -1010,7 +1010,16 @@
             state.pop(((Symbol)(pool.pool[od])).erasure(types));
             break;
         case new_:
-            state.push(uninitializedObject(((Symbol)(pool.pool[od])).erasure(types), cp-3));
+            Symbol sym;
+            if (pool.pool[od] instanceof UniqueType) {
+                // Required by change in Gen.makeRef to allow
+                // annotated types.
+                // TODO: is this needed anywhere else?
+                sym = ((UniqueType)(pool.pool[od])).type.tsym;
+            } else {
+                sym = (Symbol)(pool.pool[od]);
+            }
+            state.push(uninitializedObject(sym.erasure(types), cp-3));
             break;
         case sipush:
             state.push(syms.intType);
@@ -1972,25 +1981,38 @@
             if (lv == null || lv.sym == null
                     || lv.sym.annotations.isTypesEmpty()
                     || !lv.sym.isExceptionParameter())
-                return;
-
-            int exidx = findExceptionIndex(lv);
+                continue;
 
             for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) {
                 TypeAnnotationPosition p = ta.position;
-                p.exception_index = exidx;
+                // At this point p.type_index contains the catch type index.
+                // Use that index to determine the exception table index.
+                // We can afterwards discard the type_index.
+                // A TA position is shared for all type annotations in the
+                // same location; updating one is enough.
+                // Use -666 as a marker that the exception_index was already updated.
+                if (p.type_index != -666) {
+                    p.exception_index = findExceptionIndex(p.type_index);
+                    p.type_index = -666;
+                }
             }
         }
     }
 
-    private int findExceptionIndex(LocalVar lv) {
+    private int findExceptionIndex(int catchType) {
+        if (catchType == Integer.MIN_VALUE) {
+            // We didn't set the catch type index correctly.
+            // This shouldn't happen.
+            // TODO: issue error?
+            return -1;
+        }
         List<char[]> iter = catchInfo.toList();
         int len = catchInfo.length();
         for (int i = 0; i < len; ++i) {
             char[] catchEntry = iter.head;
             iter = iter.tail;
-            char handlerpc = catchEntry[2];
-            if (lv.start_pc == handlerpc + 1) {
+            char ct = catchEntry[3];
+            if (catchType == ct) {
                 return i;
             }
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Fri May 17 10:13:34 2013 -0700
@@ -30,6 +30,8 @@
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Attribute.TypeCompound;
+import com.sun.tools.javac.code.Symbol.VarSymbol;
 import com.sun.tools.javac.comp.*;
 import com.sun.tools.javac.tree.*;
 
@@ -47,7 +49,6 @@
 import static com.sun.tools.javac.jvm.CRTFlags.*;
 import static com.sun.tools.javac.main.Option.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
-import static com.sun.tools.javac.tree.JCTree.Tag.BLOCK;
 
 /** This pass maps flat Java (i.e. without inner classes) to bytecodes.
  *
@@ -308,7 +309,15 @@
      */
     int makeRef(DiagnosticPosition pos, Type type) {
         checkDimension(pos, type);
-        return pool.put(type.hasTag(CLASS) ? (Object)type.tsym : (Object)type);
+        if (type.isAnnotated()) {
+            // Treat annotated types separately - we don't want
+            // to collapse all of them - at least for annotated
+            // exceptions.
+            // TODO: review this.
+            return pool.put((Object)type);
+        } else {
+            return pool.put(type.hasTag(CLASS) ? (Object)type.tsym : (Object)type);
+        }
     }
 
     /** Check if the given type is an array with too many dimensions.
@@ -456,7 +465,9 @@
      */
     List<JCTree> normalizeDefs(List<JCTree> defs, ClassSymbol c) {
         ListBuffer<JCStatement> initCode = new ListBuffer<JCStatement>();
+        ListBuffer<Attribute.TypeCompound> initTAs = new ListBuffer<Attribute.TypeCompound>();
         ListBuffer<JCStatement> clinitCode = new ListBuffer<JCStatement>();
+        ListBuffer<Attribute.TypeCompound> clinitTAs = new ListBuffer<Attribute.TypeCompound>();
         ListBuffer<JCTree> methodDefs = new ListBuffer<JCTree>();
         // Sort definitions into three listbuffers:
         //  - initCode for instance initializers
@@ -486,6 +497,7 @@
                             Assignment(sym, vdef.init);
                         initCode.append(init);
                         endPosTable.replaceTree(vdef, init);
+                        initTAs.addAll(getAndRemoveNonFieldTAs(sym));
                     } else if (sym.getConstValue() == null) {
                         // Initialize class (static) variables only if
                         // they are not compile-time constants.
@@ -493,6 +505,7 @@
                             Assignment(sym, vdef.init);
                         clinitCode.append(init);
                         endPosTable.replaceTree(vdef, init);
+                        clinitTAs.addAll(getAndRemoveNonFieldTAs(sym));
                     } else {
                         checkStringConstant(vdef.init.pos(), sym.getConstValue());
                     }
@@ -505,8 +518,10 @@
         // Insert any instance initializers into all constructors.
         if (initCode.length() != 0) {
             List<JCStatement> inits = initCode.toList();
+            initTAs.addAll(c.annotations.getInitTypeAttributes());
+            List<Attribute.TypeCompound> initTAlist = initTAs.toList();
             for (JCTree t : methodDefs) {
-                normalizeMethod((JCMethodDecl)t, inits);
+                normalizeMethod((JCMethodDecl)t, inits, initTAlist);
             }
         }
         // If there are class initializers, create a <clinit> method
@@ -524,11 +539,31 @@
             JCBlock block = make.at(clinitStats.head.pos()).Block(0, clinitStats);
             block.endpos = TreeInfo.endPos(clinitStats.last());
             methodDefs.append(make.MethodDef(clinit, block));
+
+            if (!clinitTAs.isEmpty())
+                clinit.annotations.appendUniqueTypes(clinitTAs.toList());
+            if (!c.annotations.getClassInitTypeAttributes().isEmpty())
+                clinit.annotations.appendUniqueTypes(c.annotations.getClassInitTypeAttributes());
         }
         // Return all method definitions.
         return methodDefs.toList();
     }
 
+    private List<Attribute.TypeCompound> getAndRemoveNonFieldTAs(VarSymbol sym) {
+        List<TypeCompound> tas = sym.getRawTypeAttributes();
+        ListBuffer<Attribute.TypeCompound> fieldTAs = new ListBuffer<Attribute.TypeCompound>();
+        ListBuffer<Attribute.TypeCompound> nonfieldTAs = new ListBuffer<Attribute.TypeCompound>();
+        for (TypeCompound ta : tas) {
+            if (ta.position.type == TargetType.FIELD) {
+                fieldTAs.add(ta);
+            } else {
+                nonfieldTAs.add(ta);
+            }
+        }
+        sym.annotations.setTypeAttributes(fieldTAs.toList());
+        return nonfieldTAs.toList();
+    }
+
     /** Check a constant value and report if it is a string that is
      *  too large.
      */
@@ -546,8 +581,9 @@
      *  @param md        The tree potentially representing a
      *                   constructor's definition.
      *  @param initCode  The list of instance initializer statements.
+     *  @param initTAs  Type annotations from the initializer expression.
      */
-    void normalizeMethod(JCMethodDecl md, List<JCStatement> initCode) {
+    void normalizeMethod(JCMethodDecl md, List<JCStatement> initCode, List<TypeCompound> initTAs) {
         if (md.name == names.init && TreeInfo.isInitialConstructor(md)) {
             // We are seeing a constructor that does not call another
             // constructor of the same class.
@@ -581,6 +617,8 @@
             md.body.stats = newstats.toList();
             if (md.body.endpos == Position.NOPOS)
                 md.body.endpos = TreeInfo.endPos(md.body.stats.last());
+
+            md.sym.annotations.appendUniqueTypes(initTAs);
         }
     }
 
@@ -1527,6 +1565,11 @@
                         registerCatch(tree.pos(),
                                       startpc,  end, code.curPc(),
                                       catchType);
+                        if (subCatch.type.isAnnotated()) {
+                            // All compounds share the same position, simply update the
+                            // first one.
+                            subCatch.type.getAnnotationMirrors().head.position.type_index = catchType;
+                        }
                     }
                     gaps = gaps.tail;
                     startpc = gaps.head.intValue();
@@ -1538,6 +1581,11 @@
                         registerCatch(tree.pos(),
                                       startpc, endpc, code.curPc(),
                                       catchType);
+                        if (subCatch.type.isAnnotated()) {
+                            // All compounds share the same position, simply update the
+                            // first one.
+                            subCatch.type.getAnnotationMirrors().head.position.type_index = catchType;
+                        }
                     }
                 }
                 VarSymbol exparam = tree.param.sym;
@@ -1783,42 +1831,44 @@
         result = items.makeStackItem(pt);
     }
 
-   private void setTypeAnnotationPositions(int treePos) {
-       MethodSymbol meth = code.meth;
+    private void setTypeAnnotationPositions(int treePos) {
+        MethodSymbol meth = code.meth;
+        boolean initOrClinit = code.meth.getKind() == javax.lang.model.element.ElementKind.CONSTRUCTOR
+                || code.meth.getKind() == javax.lang.model.element.ElementKind.STATIC_INIT;
 
-       for (Attribute.TypeCompound ta : meth.getRawTypeAttributes()) {
-           if (ta.position.pos == treePos) {
-               ta.position.offset = code.cp;
-               ta.position.lvarOffset = new int[] { code.cp };
-               ta.position.isValidOffset = true;
-           }
-       }
+        for (Attribute.TypeCompound ta : meth.getRawTypeAttributes()) {
+            if (ta.hasUnknownPosition())
+                ta.tryFixPosition();
 
-       if (code.meth.getKind() != javax.lang.model.element.ElementKind.CONSTRUCTOR
-               && code.meth.getKind() != javax.lang.model.element.ElementKind.STATIC_INIT)
-           return;
+            if (ta.position.matchesPos(treePos))
+                ta.position.updatePosOffset(code.cp);
+        }
+
+        if (!initOrClinit)
+            return;
 
-       for (Attribute.TypeCompound ta : meth.owner.getRawTypeAttributes()) {
-           if (ta.position.pos == treePos) {
-               ta.position.offset = code.cp;
-               ta.position.lvarOffset = new int[] { code.cp };
-               ta.position.isValidOffset = true;
-           }
-       }
+        for (Attribute.TypeCompound ta : meth.owner.getRawTypeAttributes()) {
+            if (ta.hasUnknownPosition())
+                ta.tryFixPosition();
+
+            if (ta.position.matchesPos(treePos))
+                ta.position.updatePosOffset(code.cp);
+        }
 
-       ClassSymbol clazz = meth.enclClass();
-       for (Symbol s : new com.sun.tools.javac.model.FilteredMemberList(clazz.members())) {
-           if (!s.getKind().isField())
-               continue;
-           for (Attribute.TypeCompound ta : s.getRawTypeAttributes()) {
-               if (ta.position.pos == treePos) {
-                   ta.position.offset = code.cp;
-                   ta.position.lvarOffset = new int[] { code.cp };
-                   ta.position.isValidOffset = true;
-               }
-           }
-       }
-   }
+        ClassSymbol clazz = meth.enclClass();
+        for (Symbol s : new com.sun.tools.javac.model.FilteredMemberList(clazz.members())) {
+            if (!s.getKind().isField())
+                continue;
+
+            for (Attribute.TypeCompound ta : s.getRawTypeAttributes()) {
+                if (ta.hasUnknownPosition())
+                    ta.tryFixPosition();
+
+                if (ta.position.matchesPos(treePos))
+                    ta.position.updatePosOffset(code.cp);
+            }
+        }
+    }
 
     public void visitNewClass(JCNewClass tree) {
         // Enclosing instances or anonymous classes should have been eliminated
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java	Fri May 17 10:13:34 2013 -0700
@@ -157,13 +157,6 @@
         if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0)
             return false;
 
-        /* temporary code for backwards compatibility */
-        for (Attribute.Compound a: c.annotations.getDeclarationAttributes()) {
-            if (a.type.tsym == syms.nativeHeaderType_old.tsym)
-                return true;
-        }
-        /* end of temporary code for backwards compatibility */
-
         for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) {
             if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0)
                 return true;
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri May 17 10:13:34 2013 -0700
@@ -25,7 +25,6 @@
 
 package com.sun.tools.javac.main;
 
-import com.sun.tools.javac.comp.CompileStates;
 import java.io.*;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -55,6 +54,7 @@
 import com.sun.tools.javac.code.Lint.LintCategory;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.comp.*;
+import com.sun.tools.javac.comp.CompileStates.CompileState;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.parser.*;
@@ -62,7 +62,6 @@
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.comp.CompileStates.CompileState;
 import com.sun.tools.javac.util.Log.WriterKind;
 
 import static com.sun.tools.javac.code.TypeTag.CLASS;
@@ -484,7 +483,7 @@
      */
     protected boolean werror;
 
-    /** Switch: is annotation processing requested explitly via
+    /** Switch: is annotation processing requested explicitly via
      * CompilationTask.setProcessors?
      */
     protected boolean explicitAnnotationProcessingRequested = false;
@@ -1615,6 +1614,9 @@
                 log.warning("proc.use.proc.or.implicit");
         }
         chk.reportDeferredDiagnostics();
+        if (log.compressedOutput) {
+            log.mandatoryNote(null, "compressed.diags");
+        }
     }
 
     /** Close the compiler, flushing the logs
@@ -1666,6 +1668,7 @@
                     throw new FatalError(msg, e);
                 }
             }
+            closeables = List.nil();
         }
     }
 
--- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java	Fri May 17 10:13:34 2013 -0700
@@ -35,7 +35,6 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
-import java.util.ServiceLoader;
 import java.util.Set;
 
 import javax.annotation.processing.Processor;
@@ -56,6 +55,7 @@
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.Log.PrefixKind;
 import com.sun.tools.javac.util.Log.WriterKind;
+import com.sun.tools.javac.util.ServiceLoader;
 import static com.sun.tools.javac.main.Option.*;
 
 /** This class provides a command line interface to the javac compiler.
@@ -469,7 +469,6 @@
                                 pluginMessage(ex);
                                 return Result.SYSERR;
                             }
-
                         }
                     }
                 }
--- a/langtools/src/share/classes/com/sun/tools/javac/main/Option.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Option.java	Fri May 17 10:13:34 2013 -0700
@@ -407,6 +407,8 @@
         }
     },
 
+    XDIAGS("-Xdiags:", "opt.diags", EXTENDED, BASIC, ONEOF, "compact", "verbose"),
+
     /* This is a back door to the compiler's option table.
      * -XDx=y sets the option x to the value y.
      * -XDx sets the option x to the value x.
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri May 17 10:13:34 2013 -0700
@@ -2013,7 +2013,7 @@
     /** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
      */
     JCExpression creator(int newpos, List<JCExpression> typeArgs) {
-        List<JCAnnotation> newAnnotations = typeAnnotationsOpt();
+        List<JCAnnotation> newAnnotations = annotationsOpt(Tag.ANNOTATION);
 
         switch (token.kind) {
         case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT:
@@ -2030,11 +2030,6 @@
         }
         JCExpression t = qualident(true);
 
-        // handle type annotations for non primitive arrays
-        if (newAnnotations.nonEmpty()) {
-            t = insertAnnotationsToMostInner(t, newAnnotations, false);
-        }
-
         int oldmode = mode;
         mode = TYPE;
         boolean diamondFound = false;
@@ -2068,6 +2063,11 @@
         }
         mode = oldmode;
         if (token.kind == LBRACKET || token.kind == MONKEYS_AT) {
+            // handle type annotations for non primitive arrays
+            if (newAnnotations.nonEmpty()) {
+                t = insertAnnotationsToMostInner(t, newAnnotations, false);
+            }
+
             JCExpression e = arrayCreatorRest(newpos, t);
             if (diamondFound) {
                 reportSyntaxError(lastTypeargsPos, "cannot.create.array.with.diamond");
@@ -2092,8 +2092,18 @@
             if (newClass.def != null) {
                 assert newClass.def.mods.annotations.isEmpty();
                 if (newAnnotations.nonEmpty()) {
+                    // Add type and declaration annotations to the new class;
+                    // com.sun.tools.javac.code.TypeAnnotations.TypeAnnotationPositions.visitNewClass(JCNewClass)
+                    // will later remove all type annotations and only leave the
+                    // declaration annotations.
                     newClass.def.mods.pos = earlier(newClass.def.mods.pos, newAnnotations.head.pos);
-                    newClass.def.mods.annotations = List.convert(JCAnnotation.class, newAnnotations);
+                    newClass.def.mods.annotations = newAnnotations;
+                }
+            } else {
+                // handle type annotations for instantiations
+                if (newAnnotations.nonEmpty()) {
+                    t = insertAnnotationsToMostInner(t, newAnnotations, false);
+                    newClass.clazz = t;
                 }
             }
             return newClass;
@@ -2987,7 +2997,22 @@
             syntaxError(pos, "expected", IDENTIFIER);
             name = token.name();
         } else {
-            name = ident();
+            if (allowThisIdent) {
+                JCExpression pn = qualident(false);
+                if (pn.hasTag(Tag.IDENT) && ((JCIdent)pn).name != names._this) {
+                    name = ((JCIdent)pn).name;
+                } else {
+                    if ((mods.flags & Flags.VARARGS) != 0) {
+                        log.error(token.pos, "varargs.and.receiver");
+                    }
+                    if (token.kind == LBRACKET) {
+                        log.error(token.pos, "array.and.receiver");
+                    }
+                    return toP(F.at(pos).ReceiverVarDef(mods, pn, type));
+                }
+            } else {
+                name = ident();
+            }
         }
         if ((mods.flags & Flags.VARARGS) != 0 &&
                 token.kind == LBRACKET) {
@@ -3526,18 +3551,24 @@
         ListBuffer<JCExpression> ts = new ListBuffer<JCExpression>();
 
         List<JCAnnotation> typeAnnos = typeAnnotationsOpt();
-        if (!typeAnnos.isEmpty())
-            ts.append(toP(F.at(typeAnnos.head.pos).AnnotatedType(typeAnnos, qualident(true))));
-        else
-            ts.append(qualident(true));
+        JCExpression qi = qualident(true);
+        if (!typeAnnos.isEmpty()) {
+            JCExpression at = insertAnnotationsToMostInner(qi, typeAnnos, false);
+            ts.append(at);
+        } else {
+            ts.append(qi);
+        }
         while (token.kind == COMMA) {
             nextToken();
 
             typeAnnos = typeAnnotationsOpt();
-            if (!typeAnnos.isEmpty())
-                ts.append(toP(F.at(typeAnnos.head.pos).AnnotatedType(typeAnnos, qualident(true))));
-            else
-                ts.append(qualident(true));
+            qi = qualident(true);
+            if (!typeAnnos.isEmpty()) {
+                JCExpression at = insertAnnotationsToMostInner(qi, typeAnnos, false);
+                ts.append(at);
+            } else {
+                ts.append(qi);
+            }
         }
         return ts.toList();
     }
@@ -3601,7 +3632,7 @@
         if (token.kind != RPAREN) {
             this.allowThisIdent = true;
             lastParam = formalParameter(lambdaParameters);
-            if (lastParam.name.contentEquals(TokenKind.THIS.name)) {
+            if (lastParam.nameexpr != null) {
                 this.receiverParam = lastParam;
             } else {
                 params.append(lastParam);
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Fri May 17 10:13:34 2013 -0700
@@ -76,6 +76,7 @@
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
 import com.sun.tools.javac.util.Options;
+import com.sun.tools.javac.util.ServiceLoader;
 import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING;
 import static com.sun.tools.javac.main.Option.*;
 import static com.sun.tools.javac.comp.CompileStates.CompileState;
@@ -166,6 +167,7 @@
 
     protected JavacProcessingEnvironment(Context context) {
         this.context = context;
+        context.put(JavacProcessingEnvironment.class, this);
         log = Log.instance(context);
         source = Source.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri May 17 10:13:34 2013 -0700
@@ -221,17 +221,19 @@
     bad intersection type target for lambda or method reference\n\
     {0}
 
-# 0: type
+# 0: symbol or type
 compiler.misc.not.an.intf.component=\
     component type {0} is not an interface
 
 # 0: symbol kind, 1: message segment
 compiler.err.invalid.mref=\
-    invalid {0} reference; {1}
+    invalid {0} reference\n\
+    {1}
 
 # 0: symbol kind, 1: message segment
 compiler.misc.invalid.mref=\
-    invalid {0} reference; {1}
+    invalid {0} reference\n\
+    {1}
 
 compiler.misc.static.mref.with.targs=\
     parameterized qualifier on static method reference
@@ -331,29 +333,29 @@
 
 # 0: type, 1: type
 compiler.err.duplicate.annotation.missing.container=\
-    duplicate annotation, the declaration of {0} does not have a valid {1} annotation
+    duplicate annotation: the declaration of {0} does not have a valid {1} annotation
 
 # 0: type
 compiler.err.invalid.repeatable.annotation=\
-    duplicate annotation, {0} is annotated with an invalid Repeatable annotation
-
-# 0: type
+    duplicate annotation: {0} is annotated with an invalid Repeatable annotation
+
+# 0: symbol or type
 compiler.err.invalid.repeatable.annotation.no.value=\
-    duplicate annotation, {0} is not a valid Repeatable, no value element method declared
+    duplicate annotation: {0} is not a valid Repeatable, no value element method declared
 
 # 0: type, 1: number
 compiler.err.invalid.repeatable.annotation.multiple.values=\
-    duplicate annotation, {0} is not a valid Repeatable, {1} value element methods declared
+    duplicate annotation: {0} is not a valid Repeatable, {1} value element methods declared
 
 # 0: type
 compiler.err.invalid.repeatable.annotation.invalid.value=\
-    duplicate annotation, {0} is not a valid Repeatable, invalid value element, need a method
-
-# 0: type, 1: type, 2: type
+    duplicate annotation: {0} is not a valid Repeatable: invalid value element
+
+# 0: symbol type, 1: type, 2: type
 compiler.err.invalid.repeatable.annotation.value.return=\
-    duplicate annotation, value element of containing annotation {0} should have type {2}, found {1}
-
-# 0: type, 1: symbol
+    duplicate annotation: value element of containing annotation {0} should have type {2}, found {1}
+
+# 0: symbol or type, 1: symbol
 compiler.err.invalid.repeatable.annotation.elem.nondefault=\
     containing annotation {0} does not have a default value for element {1}
 
@@ -592,6 +594,12 @@
 compiler.err.varargs.and.old.array.syntax=\
     legacy array notation not allowed on variable-arity parameter
 
+compiler.err.varargs.and.receiver =\
+    varargs notation not allowed on receiver parameter
+
+compiler.err.array.and.receiver =\
+    legacy array notation not allowed on receiver parameter
+
 compiler.err.variable.not.allowed=\
     variable declaration not allowed here
 
@@ -659,6 +667,7 @@
 compiler.err.missing.ret.stmt=\
     missing return statement
 
+# 0: unused
 compiler.misc.missing.ret.val=\
     missing return value
 
@@ -707,7 +716,8 @@
 
 # 0: message segment
 compiler.misc.incompatible.type.in.conditional=\
-    bad type in conditional expression; {0}
+    bad type in conditional expression\n\
+    {0}
 
 compiler.misc.conditional.target.cant.be.void=\
     target-type for conditional expression cannot be void
@@ -736,7 +746,7 @@
 compiler.misc.incompatible.arg.types.in.mref=\
     incompatible parameter types in method reference
 
-# 0: list of type
+# 0: list of type, 1: message segment
 compiler.misc.bad.arg.types.in.lambda=\
     cannot type-check lambda expression with inferred parameter types\n\
     inferred types: {0}
@@ -983,7 +993,7 @@
 compiler.misc.overridden.default=\
     method {0} is overridden in {1}
 
-# 0: symbol, 1: symbol
+# 0: symbol, 1: type or symbol
 compiler.misc.redundant.supertype=\
     redundant interface {0} is extended by {1}
 
@@ -1147,6 +1157,9 @@
 ## The following string will appear before all messages keyed as:
 ## "compiler.note".
 
+compiler.note.compressed.diags=\
+    Some messages have been simplified; recompile with -Xdiags:verbose to get full output
+
 compiler.note.potential.lambda.found=\
     This anonymous inner class creation can be turned into a lambda expression.
 
@@ -1735,6 +1748,10 @@
 compiler.err.prob.found.req=\
     incompatible types: {0}
 
+# 0: message segment
+compiler.misc.prob.found.req=\
+    incompatible types: {0}
+
 # 0: message segment, 1: type, 2: type
 compiler.warn.prob.found.req=\
     {0}\n\
@@ -1896,11 +1913,10 @@
 
 #####
 
-# 0: type, 1: file name
+# 0: symbol or type, 1: file name
 compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file=\
     auxiliary class {0} in {1} should not be accessed from outside its own source file
 
-
 ## The first argument ({0}) is a "kindname".
 # 0: symbol kind, 1: symbol, 2: symbol
 compiler.err.abstract.cant.be.accessed.directly=\
@@ -2185,15 +2201,42 @@
 compiler.err.this.as.identifier=\
     as of release 8, ''this'' is allowed as the parameter name for the receiver type only, which has to be the first parameter
 
+# 0: symbol
+compiler.err.receiver.parameter.not.applicable.constructor.toplevel.class=\
+    receiver parameter not applicable for constructor of top-level class
+
 # TODO 308: make a better error message
 compiler.err.cant.annotate.static.class=\
     enclosing static nested class cannot be annotated
+
 # TODO 308: make a better error message
+# 0: unused
 compiler.err.cant.annotate.nested.type=\
     nested type cannot be annotated
 
+# 0: type, 1: type
+compiler.err.incorrect.receiver.name=\
+    the receiver name does not match the enclosing class type\n\
+    required: {0}\n\
+    found: {1}
+
+# 0: type, 1: type
 compiler.err.incorrect.receiver.type=\
-    the receiver type does not match the enclosing class type
+    the receiver type does not match the enclosing class type\n\
+    required: {0}\n\
+    found: {1}
+
+# 0: type, 1: type
+compiler.err.incorrect.constructor.receiver.type=\
+    the receiver type does not match the enclosing outer class type\n\
+    required: {0}\n\
+    found: {1}
+
+# 0: type, 1: type
+compiler.err.incorrect.constructor.receiver.name=\
+    the receiver name does not match the enclosing outer class type\n\
+    required: {0}\n\
+    found: {1}
 
 compiler.err.no.annotations.on.dot.class=\
     no annotations are allowed in the type of a class literal
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties	Fri May 17 10:13:34 2013 -0700
@@ -168,6 +168,8 @@
     Specify which file to read when both a source file and class file are found for an implicitly compiled class
 javac.opt.AT=\
     Read options and filenames from file
+javac.opt.diags=\
+    Select a diagnostic mode
 
 ## errors
 
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Fri May 17 10:13:34 2013 -0700
@@ -42,7 +42,6 @@
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
-import static com.sun.tools.javac.code.BoundKind.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /**
@@ -807,12 +806,15 @@
         public JCModifiers mods;
         /** variable name */
         public Name name;
+        /** variable name expression */
+        public JCExpression nameexpr;
         /** type of the variable */
         public JCExpression vartype;
         /** variable's initial value */
         public JCExpression init;
         /** symbol */
         public VarSymbol sym;
+
         protected JCVariableDecl(JCModifiers mods,
                          Name name,
                          JCExpression vartype,
@@ -824,12 +826,27 @@
             this.init = init;
             this.sym = sym;
         }
+
+        protected JCVariableDecl(JCModifiers mods,
+                         JCExpression nameexpr,
+                         JCExpression vartype) {
+            this(mods, null, vartype, null, null);
+            this.nameexpr = nameexpr;
+            if (nameexpr.hasTag(Tag.IDENT)) {
+                this.name = ((JCIdent)nameexpr).name;
+            } else {
+                // Only other option is qualified name x.y.this;
+                this.name = ((JCFieldAccess)nameexpr).name;
+            }
+        }
+
         @Override
         public void accept(Visitor v) { v.visitVarDef(this); }
 
         public Kind getKind() { return Kind.VARIABLE; }
         public JCModifiers getModifiers() { return mods; }
         public Name getName() { return name; }
+        public JCExpression getNameExpression() { return nameexpr; }
         public JCTree getType() { return vartype; }
         public JCExpression getInitializer() {
             return init;
@@ -845,7 +862,7 @@
         }
     }
 
-      /**
+    /**
      * A no-op statement ";".
      */
     public static class JCSkip extends JCStatement implements EmptyStatementTree {
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Fri May 17 10:13:34 2013 -0700
@@ -261,8 +261,6 @@
     }
 
     public void printTypeAnnotations(List<JCAnnotation> trees) throws IOException {
-        if (trees.nonEmpty())
-            print(" ");
         for (List<JCAnnotation> l = trees; l.nonEmpty(); l = l.tail) {
             printExpr(l.head);
             print(" ");
@@ -564,8 +562,10 @@
                         vartype = ((JCAnnotatedType)vartype).underlyingType;
                     }
                     printExpr(((JCArrayTypeTree) vartype).elemtype);
-                    if (tas != null)
+                    if (tas != null) {
+                        print(' ');
                         printTypeAnnotations(tas);
+                    }
                     print("... " + tree.name);
                 } else {
                     printExpr(tree.vartype);
@@ -918,6 +918,9 @@
                 printExprs(tree.typeargs);
                 print(">");
             }
+            if (tree.def != null && tree.def.mods.annotations.nonEmpty()) {
+                printTypeAnnotations(tree.def.mods.annotations);
+            }
             printExpr(tree.clazz);
             print("(");
             printExprs(tree.args);
@@ -948,7 +951,8 @@
                 int i = 0;
                 List<List<JCAnnotation>> da = tree.dimAnnotations;
                 for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
-                    if (da.size() > i) {
+                    if (da.size() > i && !da.get(i).isEmpty()) {
+                        print(' ');
                         printTypeAnnotations(da.get(i));
                     }
                     print("[");
@@ -958,6 +962,7 @@
                 }
                 if (tree.elems != null) {
                     if (isElemAnnoType) {
+                        print(' ');
                         printTypeAnnotations(((JCAnnotatedType)tree.elemtype).annotations);
                     }
                     print("[]");
@@ -1264,6 +1269,7 @@
                 JCAnnotatedType atype = (JCAnnotatedType) elem;
                 elem = atype.underlyingType;
                 if (!elem.hasTag(TYPEARRAY)) break;
+                print(' ');
                 printTypeAnnotations(atype.annotations);
             }
             print("[]");
@@ -1301,6 +1307,9 @@
 
     public void visitTypeParameter(JCTypeParameter tree) {
         try {
+            if (tree.annotations.nonEmpty()) {
+                this.printTypeAnnotations(tree.annotations);
+            }
             print(tree.name);
             if (tree.bounds.nonEmpty()) {
                 print(" extends ");
@@ -1379,6 +1388,7 @@
             } else if (tree.underlyingType.getKind() == JCTree.Kind.ARRAY_TYPE) {
                 JCArrayTypeTree array = (JCArrayTypeTree) tree.underlyingType;
                 printBaseElementType(tree);
+                print(' ');
                 printTypeAnnotations(tree.annotations);
                 print("[]");
                 JCExpression elem = array.elemtype;
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Fri May 17 10:13:34 2013 -0700
@@ -422,8 +422,13 @@
         JCVariableDecl t = (JCVariableDecl) node;
         JCModifiers mods = copy(t.mods, p);
         JCExpression vartype = copy(t.vartype, p);
-        JCExpression init = copy(t.init, p);
-        return M.at(t.pos).VarDef(mods, t.name, vartype, init);
+        if (t.nameexpr == null) {
+            JCExpression init = copy(t.init, p);
+            return M.at(t.pos).VarDef(mods, t.name, vartype, init);
+        } else {
+            JCExpression nameexpr = copy(t.nameexpr, p);
+            return M.at(t.pos).ReceiverVarDef(mods, nameexpr, vartype);
+        }
     }
 
     public JCTree visitWhileLoop(WhileLoopTree node, P p) {
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Fri May 17 10:13:34 2013 -0700
@@ -763,14 +763,40 @@
     }
 
     public static Symbol symbolFor(JCTree node) {
+        Symbol sym = symbolForImpl(node);
+
+        return sym != null ? sym.baseSymbol() : null;
+    }
+
+    private static Symbol symbolForImpl(JCTree node) {
         node = skipParens(node);
         switch (node.getTag()) {
+        case TOPLEVEL:
+            return ((JCCompilationUnit) node).packge;
         case CLASSDEF:
             return ((JCClassDecl) node).sym;
         case METHODDEF:
             return ((JCMethodDecl) node).sym;
         case VARDEF:
             return ((JCVariableDecl) node).sym;
+        case IDENT:
+            return ((JCIdent) node).sym;
+        case SELECT:
+            return ((JCFieldAccess) node).sym;
+        case REFERENCE:
+            return ((JCMemberReference) node).sym;
+        case NEWCLASS:
+            return ((JCNewClass) node).constructor;
+        case APPLY:
+            return symbolFor(((JCMethodInvocation) node).meth);
+        case TYPEAPPLY:
+            return symbolFor(((JCTypeApply) node).clazz);
+        case ANNOTATION:
+        case TYPE_ANNOTATION:
+        case TYPEPARAMETER:
+            if (node.type != null)
+                return node.type.tsym;
+            return null;
         default:
             return null;
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Fri May 17 10:13:34 2013 -0700
@@ -204,6 +204,12 @@
         return tree;
     }
 
+    public JCVariableDecl ReceiverVarDef(JCModifiers mods, JCExpression name, JCExpression vartype) {
+        JCVariableDecl tree = new JCVariableDecl(mods, name, vartype);
+        tree.pos = pos;
+        return tree;
+    }
+
     public JCSkip Skip() {
         JCSkip tree = new JCSkip();
         tree.pos = pos;
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java	Fri May 17 10:13:34 2013 -0700
@@ -94,6 +94,7 @@
     public void visitVarDef(JCVariableDecl tree) {
         scan(tree.mods);
         scan(tree.vartype);
+        scan(tree.nameexpr);
         scan(tree.init);
     }
 
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java	Fri May 17 10:13:34 2013 -0700
@@ -148,6 +148,7 @@
 
     public void visitVarDef(JCVariableDecl tree) {
         tree.mods = translate(tree.mods);
+        tree.nameexpr = translate(tree.nameexpr);
         tree.vartype = translate(tree.vartype);
         tree.init = translate(tree.init);
         result = tree;
--- a/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Fri May 17 10:13:34 2013 -0700
@@ -349,6 +349,7 @@
         SYNTAX,
         RECOVERABLE,
         NON_DEFERRABLE,
+        COMPRESSED
     }
 
     private final DiagnosticType type;
--- a/langtools/src/share/classes/com/sun/tools/javac/util/List.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/List.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -37,7 +37,7 @@
 /** A class for generic linked lists. Links are supposed to be
  *  immutable, the only exception being the incremental construction of
  *  lists via ListBuffers.  List is the main container class in
- *  GJC. Most data structures and algorthms in GJC use lists rather
+ *  GJC. Most data structures and algorithms in GJC use lists rather
  *  than arrays.
  *
  *  <p>Lists are always trailed by a sentinel element, whose head and tail
@@ -154,11 +154,11 @@
     }
 
     public static <A> List<A> from(Iterable<? extends A> coll) {
-        List<A> xs = nil();
+        ListBuffer<A> xs = ListBuffer.lb();
         for (A a : coll) {
-            xs = new List<A>(a, xs);
+            xs.append(a);
         }
-        return xs;
+        return xs.toList();
     }
 
     /** Construct a list consisting of a given number of identical elements.
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java	Fri May 17 10:13:34 2013 -0700
@@ -214,6 +214,11 @@
     public Set<String> expectDiagKeys;
 
     /**
+     * Set to true if a compressed diagnostic is reported
+     */
+    public boolean compressedOutput;
+
+    /**
      * JavacMessages object used for localization.
      */
     private JavacMessages messages;
@@ -597,6 +602,9 @@
                 }
                 break;
             }
+            if (diagnostic.isFlagSet(JCDiagnostic.DiagnosticFlag.COMPRESSED)) {
+                compressedOutput = true;
+            }
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/ServiceLoader.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,437 @@
+/*
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.ServiceConfigurationError;
+
+
+/**
+ * This is a temporary, modified copy of java.util.ServiceLoader, for use by
+ * javac, to work around bug JDK-8004082.
+ *
+ * The bug describes problems in the interaction between ServiceLoader and
+ * URLClassLoader, such that references to a jar file passed to URLClassLoader
+ * may be retained after calling URLClassLoader.close(), preventing the jar
+ * file from being deleted on Windows.
+ *
+ *  <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.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+
+public final class ServiceLoader<S>
+    implements Iterable<S>
+{
+
+    private static final String PREFIX = "META-INF/services/";
+
+    // The class or interface representing the service being loaded
+    private Class<S> service;
+
+    // The class loader used to locate, load, and instantiate providers
+    private ClassLoader loader;
+
+    // Cached providers, in instantiation order
+    private LinkedHashMap<String,S> providers = new LinkedHashMap<>();
+
+    // The current lazy-lookup iterator
+    private LazyIterator lookupIterator;
+
+    /**
+     * Clear this loader's provider cache so that all providers will be
+     * reloaded.
+     *
+     * <p> After invoking this method, subsequent invocations of the {@link
+     * #iterator() iterator} method will lazily look up and instantiate
+     * providers from scratch, just as is done by a newly-created loader.
+     *
+     * <p> This method is intended for use in situations in which new providers
+     * can be installed into a running Java virtual machine.
+     */
+    public void reload() {
+        providers.clear();
+        lookupIterator = new LazyIterator(service, loader);
+    }
+
+    private ServiceLoader(Class<S> svc, ClassLoader cl) {
+        service = Objects.requireNonNull(svc, "Service interface cannot be null");
+        loader = (cl == null) ? ClassLoader.getSystemClassLoader() : cl;
+        reload();
+    }
+
+    private static void fail(Class<?> service, String msg, Throwable cause)
+        throws ServiceConfigurationError
+    {
+        throw new ServiceConfigurationError(service.getName() + ": " + msg,
+                                            cause);
+    }
+
+    private static void fail(Class<?> service, String msg)
+        throws ServiceConfigurationError
+    {
+        throw new ServiceConfigurationError(service.getName() + ": " + msg);
+    }
+
+    private static void fail(Class<?> service, URL u, int line, String msg)
+        throws ServiceConfigurationError
+    {
+        fail(service, u + ":" + line + ": " + msg);
+    }
+
+    // Parse a single line from the given configuration file, adding the name
+    // on the line to the names list.
+    //
+    private int parseLine(Class<?> service, URL u, BufferedReader r, int lc,
+                          List<String> names)
+        throws IOException, ServiceConfigurationError
+    {
+        String ln = r.readLine();
+        if (ln == null) {
+            return -1;
+        }
+        int ci = ln.indexOf('#');
+        if (ci >= 0) ln = ln.substring(0, ci);
+        ln = ln.trim();
+        int n = ln.length();
+        if (n != 0) {
+            if ((ln.indexOf(' ') >= 0) || (ln.indexOf('\t') >= 0))
+                fail(service, u, lc, "Illegal configuration-file syntax");
+            int cp = ln.codePointAt(0);
+            if (!Character.isJavaIdentifierStart(cp))
+                fail(service, u, lc, "Illegal provider-class name: " + ln);
+            for (int i = Character.charCount(cp); i < n; i += Character.charCount(cp)) {
+                cp = ln.codePointAt(i);
+                if (!Character.isJavaIdentifierPart(cp) && (cp != '.'))
+                    fail(service, u, lc, "Illegal provider-class name: " + ln);
+            }
+            if (!providers.containsKey(ln) && !names.contains(ln))
+                names.add(ln);
+        }
+        return lc + 1;
+    }
+
+    // Parse the content of the given URL as a provider-configuration file.
+    //
+    // @param  service
+    //         The service type for which providers are being sought;
+    //         used to construct error detail strings
+    //
+    // @param  u
+    //         The URL naming the configuration file to be parsed
+    //
+    // @return A (possibly empty) iterator that will yield the provider-class
+    //         names in the given configuration file that are not yet members
+    //         of the returned set
+    //
+    // @throws ServiceConfigurationError
+    //         If an I/O error occurs while reading from the given URL, or
+    //         if a configuration-file format error is detected
+    //
+    private Iterator<String> parse(Class<?> service, URL u)
+        throws ServiceConfigurationError
+    {
+        InputStream in = null;
+        BufferedReader r = null;
+        ArrayList<String> names = new ArrayList<>();
+        try {
+            // The problem is that by default, streams opened with
+            // u.openInputStream use a cached reference to a JarFile, which
+            // is separate from the reference used by URLClassLoader, and
+            // which is not closed by URLClassLoader.close().
+            // The workaround is to disable caching for this specific jar file,
+            // so that the reference to the jar file can be closed when the
+            // file has been read.
+            // Original code:
+            // in = u.openStream();
+            // Workaround ...
+            URLConnection uc = u.openConnection();
+            uc.setUseCaches(false);
+            in = uc.getInputStream();
+            // ... end of workaround.
+            r = new BufferedReader(new InputStreamReader(in, "utf-8"));
+            int lc = 1;
+            while ((lc = parseLine(service, u, r, lc, names)) >= 0);
+        } catch (IOException x) {
+            fail(service, "Error reading configuration file", x);
+        } finally {
+            try {
+                if (r != null) r.close();
+                if (in != null) in.close();
+            } catch (IOException y) {
+                fail(service, "Error closing configuration file", y);
+            }
+        }
+        return names.iterator();
+    }
+
+    // Private inner class implementing fully-lazy provider lookup
+    //
+    private class LazyIterator
+        implements Iterator<S>
+    {
+
+        Class<S> service;
+        ClassLoader loader;
+        Enumeration<URL> configs = null;
+        Iterator<String> pending = null;
+        String nextName = null;
+
+        private LazyIterator(Class<S> service, ClassLoader loader) {
+            this.service = service;
+            this.loader = loader;
+        }
+
+        public boolean hasNext() {
+            if (nextName != null) {
+                return true;
+            }
+            if (configs == null) {
+                try {
+                    String fullName = PREFIX + service.getName();
+                    if (loader == null)
+                        configs = ClassLoader.getSystemResources(fullName);
+                    else
+                        configs = loader.getResources(fullName);
+                } catch (IOException x) {
+                    fail(service, "Error locating configuration files", x);
+                }
+            }
+            while ((pending == null) || !pending.hasNext()) {
+                if (!configs.hasMoreElements()) {
+                    return false;
+                }
+                pending = parse(service, configs.nextElement());
+            }
+            nextName = pending.next();
+            return true;
+        }
+
+        public S next() {
+            if (!hasNext()) {
+                throw new NoSuchElementException();
+            }
+            String cn = nextName;
+            nextName = null;
+            Class<?> c = null;
+            try {
+                c = Class.forName(cn, false, loader);
+            } catch (ClassNotFoundException x) {
+                fail(service,
+                     "Provider " + cn + " not found");
+            }
+            if (!service.isAssignableFrom(c)) {
+                fail(service,
+                     "Provider " + cn  + " not a subtype");
+            }
+            try {
+                S p = service.cast(c.newInstance());
+                providers.put(cn, p);
+                return p;
+            } catch (Throwable x) {
+                fail(service,
+                     "Provider " + cn + " could not be instantiated: " + x,
+                     x);
+            }
+            throw new Error();          // This cannot happen
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    /**
+     * Lazily loads the available providers of this loader's service.
+     *
+     * <p> The iterator returned by this method first yields all of the
+     * elements of the provider cache, in instantiation order.  It then lazily
+     * loads and instantiates any remaining providers, adding each one to the
+     * cache in turn.
+     *
+     * <p> To achieve laziness the actual work of parsing the available
+     * provider-configuration files and instantiating providers must be done by
+     * the iterator itself.  Its {@link java.util.Iterator#hasNext hasNext} and
+     * {@link java.util.Iterator#next next} methods can therefore throw a
+     * {@link ServiceConfigurationError} if a provider-configuration file
+     * violates the specified format, or if it names a provider class that
+     * cannot be found and instantiated, or if the result of instantiating the
+     * class is not assignable to the service type, or if any other kind of
+     * exception or error is thrown as the next provider is located and
+     * instantiated.  To write robust code it is only necessary to catch {@link
+     * ServiceConfigurationError} when using a service iterator.
+     *
+     * <p> If such an error is thrown then subsequent invocations of the
+     * iterator will make a best effort to locate and instantiate the next
+     * available provider, but in general such recovery cannot be guaranteed.
+     *
+     * <blockquote style="font-size: smaller; line-height: 1.2"><span
+     * style="padding-right: 1em; font-weight: bold">Design Note</span>
+     * Throwing an error in these cases may seem extreme.  The rationale for
+     * this behavior is that a malformed provider-configuration file, like a
+     * malformed class file, indicates a serious problem with the way the Java
+     * virtual machine is configured or is being used.  As such it is
+     * preferable to throw an error rather than try to recover or, even worse,
+     * fail silently.</blockquote>
+     *
+     * <p> The iterator returned by this method does not support removal.
+     * Invoking its {@link java.util.Iterator#remove() remove} method will
+     * cause an {@link UnsupportedOperationException} to be thrown.
+     *
+     * @return  An iterator that lazily loads providers for this loader's
+     *          service
+     */
+    public Iterator<S> iterator() {
+        return new Iterator<S>() {
+
+            Iterator<Map.Entry<String,S>> knownProviders
+                = providers.entrySet().iterator();
+
+            public boolean hasNext() {
+                if (knownProviders.hasNext())
+                    return true;
+                return lookupIterator.hasNext();
+            }
+
+            public S next() {
+                if (knownProviders.hasNext())
+                    return knownProviders.next().getValue();
+                return lookupIterator.next();
+            }
+
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+
+        };
+    }
+
+    /**
+     * Creates a new service loader for the given service type and class
+     * loader.
+     *
+     * @param  service
+     *         The interface or abstract class representing the service
+     *
+     * @param  loader
+     *         The class loader to be used to load provider-configuration files
+     *         and provider classes, or <tt>null</tt> if the system class
+     *         loader (or, failing that, the bootstrap class loader) is to be
+     *         used
+     *
+     * @return A new service loader
+     */
+    public static <S> ServiceLoader<S> load(Class<S> service,
+                                            ClassLoader loader)
+    {
+        return new ServiceLoader<>(service, loader);
+    }
+
+    /**
+     * Creates a new service loader for the given service type, using the
+     * current thread's {@linkplain java.lang.Thread#getContextClassLoader
+     * context class loader}.
+     *
+     * <p> An invocation of this convenience method of the form
+     *
+     * <blockquote><pre>
+     * ServiceLoader.load(<i>service</i>)</pre></blockquote>
+     *
+     * is equivalent to
+     *
+     * <blockquote><pre>
+     * ServiceLoader.load(<i>service</i>,
+     *                    Thread.currentThread().getContextClassLoader())</pre></blockquote>
+     *
+     * @param  service
+     *         The interface or abstract class representing the service
+     *
+     * @return A new service loader
+     */
+    public static <S> ServiceLoader<S> load(Class<S> service) {
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        return ServiceLoader.load(service, cl);
+    }
+
+    /**
+     * Creates a new service loader for the given service type, using the
+     * extension class loader.
+     *
+     * <p> This convenience method simply locates the extension class loader,
+     * call it <tt><i>extClassLoader</i></tt>, and then returns
+     *
+     * <blockquote><pre>
+     * ServiceLoader.load(<i>service</i>, <i>extClassLoader</i>)</pre></blockquote>
+     *
+     * <p> If the extension class loader cannot be found then the system class
+     * loader is used; if there is no system class loader then the bootstrap
+     * class loader is used.
+     *
+     * <p> This method is intended for use when only installed providers are
+     * desired.  The resulting service will only find and load providers that
+     * have been installed into the current Java virtual machine; providers on
+     * the application's class path will be ignored.
+     *
+     * @param  service
+     *         The interface or abstract class representing the service
+     *
+     * @return A new service loader
+     */
+    public static <S> ServiceLoader<S> loadInstalled(Class<S> service) {
+        ClassLoader cl = ClassLoader.getSystemClassLoader();
+        ClassLoader prev = null;
+        while (cl != null) {
+            prev = cl;
+            cl = cl.getParent();
+        }
+        return ServiceLoader.load(service, prev);
+    }
+
+    /**
+     * Returns a string describing this service.
+     *
+     * @return  A descriptive string
+     */
+    public String toString() {
+        return "java.util.ServiceLoader[" + service.getName() + "]";
+    }
+
+}
--- a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -31,9 +31,7 @@
 import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Scope;
 import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.List;
-import com.sun.tools.javac.util.Names;
 
 /**
  * Represents an annotation type.
@@ -92,7 +90,6 @@
      * Elements are always public, so no need to filter them.
      */
     public AnnotationTypeElementDoc[] elements() {
-        Names names = tsym.name.table.names;
         List<AnnotationTypeElementDoc> elements = List.nil();
         for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
             if (e.sym != null && e.sym.kind == Kinds.MTH) {
--- a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
 
 import com.sun.source.util.TreePath;
 import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.tree.JCTree.*;
 
 /**
  * Represents an element of an annotation type.
--- a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -28,7 +28,6 @@
 import com.sun.javadoc.*;
 
 import com.sun.tools.javac.code.Attribute;
-import com.sun.tools.javac.code.Symbol.*;
 
 import static com.sun.tools.javac.code.TypeTag.BOOLEAN;
 
--- a/langtools/src/share/classes/com/sun/tools/javadoc/Comment.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/Comment.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, 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
@@ -25,6 +25,8 @@
 
 package com.sun.tools.javadoc;
 
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import com.sun.javadoc.*;
 import com.sun.tools.javac.util.ListBuffer;
 
@@ -296,6 +298,7 @@
     static Tag[] getInlineTags(DocImpl holder, String inlinetext) {
         ListBuffer<Tag> taglist = new ListBuffer<Tag>();
         int delimend = 0, textstart = 0, len = inlinetext.length();
+        boolean inPre = false;
         DocEnv docenv = holder.env;
 
         if (len == 0) {
@@ -309,6 +312,7 @@
                                            inlinetext.substring(textstart)));
                 break;
             } else {
+                inPre = scanForPre(inlinetext, textstart, linkstart, inPre);
                 int seetextstart = linkstart;
                 for (int i = linkstart; i < inlinetext.length(); i++) {
                     char c = inlinetext.charAt(i);
@@ -319,18 +323,20 @@
                      }
                 }
                 String linkName = inlinetext.substring(linkstart+2, seetextstart);
-                //Move past the white space after the inline tag name.
-                while (Character.isWhitespace(inlinetext.
-                                                  charAt(seetextstart))) {
-                    if (inlinetext.length() <= seetextstart) {
-                        taglist.append(new TagImpl(holder, "Text",
-                                                   inlinetext.substring(textstart, seetextstart)));
-                        docenv.warning(holder,
-                                       "tag.Improper_Use_Of_Link_Tag",
-                                       inlinetext);
-                        return taglist.toArray(new Tag[taglist.length()]);
-                    } else {
-                        seetextstart++;
+                if (!(inPre && (linkName.equals("code") || linkName.equals("literal")))) {
+                    //Move past the white space after the inline tag name.
+                    while (Character.isWhitespace(inlinetext.
+                                                      charAt(seetextstart))) {
+                        if (inlinetext.length() <= seetextstart) {
+                            taglist.append(new TagImpl(holder, "Text",
+                                                       inlinetext.substring(textstart, seetextstart)));
+                            docenv.warning(holder,
+                                           "tag.Improper_Use_Of_Link_Tag",
+                                           inlinetext);
+                            return taglist.toArray(new Tag[taglist.length()]);
+                        } else {
+                            seetextstart++;
+                        }
                     }
                 }
                 taglist.append(new TagImpl(holder, "Text",
@@ -366,6 +372,17 @@
         return taglist.toArray(new Tag[taglist.length()]);
     }
 
+    /** regex for case-insensitive match for {@literal <pre> } and  {@literal </pre> }. */
+    private static final Pattern prePat = Pattern.compile("(?i)<(/?)pre>");
+
+    private static boolean scanForPre(String inlinetext, int start, int end, boolean inPre) {
+        Matcher m = prePat.matcher(inlinetext).region(start, end);
+        while (m.find()) {
+            inPre = m.group(1).isEmpty();
+        }
+        return inPre;
+    }
+
     /**
      * Recursively find the index of the closing '}' character for an inline tag
      * and return it.  If it can't be found, return -1.
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -28,14 +28,10 @@
 import java.lang.reflect.Modifier;
 import java.text.CollationKey;
 
-import javax.lang.model.type.TypeKind;
-
 import com.sun.javadoc.*;
 
 import com.sun.source.util.TreePath;
-import com.sun.tools.javac.code.Attribute;
 import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.code.Attribute.Compound;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.util.List;
--- a/langtools/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -34,10 +34,6 @@
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symbol.VarSymbol;
 
-import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-
-import com.sun.tools.javac.util.Position;
-
 import static com.sun.tools.javac.code.TypeTag.BOOLEAN;
 
 /**
--- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, 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
@@ -25,10 +25,8 @@
 
 package com.sun.tools.javadoc;
 
-
 import javax.tools.JavaFileObject;
 
-import com.sun.source.util.TreePath;
 import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.comp.Enter;
--- a/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java	Fri May 17 10:13:34 2013 -0700
@@ -26,9 +26,7 @@
 package com.sun.tools.javadoc;
 
 import java.io.PrintWriter;
-import java.text.MessageFormat;
 import java.util.Locale;
-import java.util.ResourceBundle;
 
 import com.sun.javadoc.*;
 import com.sun.tools.javac.util.Context;
--- a/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java	Fri May 17 10:13:34 2013 -0700
@@ -25,8 +25,6 @@
 
 package com.sun.tools.javadoc;
 
-import javax.lang.model.type.TypeKind;
-
 import com.sun.javadoc.*;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
@@ -64,12 +62,9 @@
         if (env.legacyDoclet) {
             t = env.types.erasure(t);
         }
-        if (considerAnnotations
-                && t.isAnnotated()) {
-            return new AnnotatedTypeImpl(env, (com.sun.tools.javac.code.Type.AnnotatedType) t);
-        }
 
-        if (t.isAnnotated()) {
+        if (considerAnnotations &&
+                t.isAnnotated()) {
             Type.AnnotatedType at = (Type.AnnotatedType) t;
             return new AnnotatedTypeImpl(env, at);
         }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java	Fri May 17 10:13:34 2013 -0700
@@ -25,8 +25,6 @@
 
 package com.sun.tools.javadoc;
 
-import javax.lang.model.type.TypeKind;
-
 import com.sun.javadoc.*;
 
 import com.sun.tools.javac.code.Attribute;
--- a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -255,7 +255,8 @@
             }
             // Load visible sources
             Set<URI> visibleSources = new HashSet<URI>();
-            boolean fix_drive_letter_case = System.getProperty("os.name").toLowerCase().equals("windows");
+            boolean fix_drive_letter_case =
+                System.getProperty("os.name").toLowerCase().startsWith("windows");
             for (;;) {
                 String l = in.readLine();
                 if (l == null)
--- a/langtools/src/share/classes/javax/annotation/processing/SupportedAnnotationTypes.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/javax/annotation/processing/SupportedAnnotationTypes.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, 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
@@ -47,5 +47,9 @@
 @Target(TYPE)
 @Retention(RUNTIME)
 public @interface SupportedAnnotationTypes {
-  String [] value();
+    /**
+     * Returns the names of the supported annotation types.
+     * @return the names of the supported annotation types
+     */
+    String [] value();
 }
--- a/langtools/src/share/classes/javax/annotation/processing/SupportedOptions.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/javax/annotation/processing/SupportedOptions.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, 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
@@ -46,5 +46,9 @@
 @Target(TYPE)
 @Retention(RUNTIME)
 public @interface SupportedOptions {
-  String [] value();
+    /**
+     * Returns the supported options.
+     * @return the supported options
+     */
+    String [] value();
 }
--- a/langtools/src/share/classes/javax/annotation/processing/SupportedSourceVersion.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/javax/annotation/processing/SupportedSourceVersion.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, 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
@@ -47,5 +47,9 @@
 @Target(TYPE)
 @Retention(RUNTIME)
 public @interface SupportedSourceVersion {
+    /**
+     * Returns the latest supported source version.
+     * @return the latest supported source version
+     */
     SourceVersion value();
 }
--- a/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java	Fri May 17 10:13:34 2013 -0700
@@ -51,7 +51,7 @@
  * <li> for an invocation of {@code getAnnotation(Class<T>)} or
  * {@code getAnnotationMirrors()}, <i>E</i>'s annotations contain <i>A</i>.
  *
- * <li> for an invocation of getAnnotationsByType(Class<T>),
+ * <li> for an invocation of {@code getAnnotationsByType(Class<T>)},
  * <i>E</i>'s annotations either contain <i>A</i> or, if the type of
  * <i>A</i> is repeatable, contain exactly one annotation whose value
  * element contains <i>A</i> and whose type is the containing
--- a/langtools/src/share/classes/javax/lang/model/element/NestingKind.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/javax/lang/model/element/NestingKind.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, 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
@@ -82,9 +82,24 @@
  * @since 1.6
  */
 public enum NestingKind {
+    /**
+     * A top-level type, not contained within another type.
+     */
     TOP_LEVEL,
+
+    /**
+     * A type that is a named member of another type.
+     */
     MEMBER,
+
+    /**
+     * A named type declared within a construct other than a type.
+     */
     LOCAL,
+
+    /**
+     * A type without a name.
+     */
     ANONYMOUS;
 
     /**
@@ -92,6 +107,7 @@
      * A <i>nested</i> type element is any that is not top-level.
      * An <i>inner</i> type element is any nested type element that
      * is not {@linkplain Modifier#STATIC static}.
+     * @return whether or not the constant is nested
      */
     public boolean isNested() {
         return this != TOP_LEVEL;
--- a/langtools/src/share/classes/javax/lang/model/util/ElementScanner6.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/javax/lang/model/util/ElementScanner6.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, 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
@@ -135,6 +135,9 @@
     /**
      * Processes an element by calling {@code e.accept(this, p)};
      * this method may be overridden by subclasses.
+     *
+     * @param e the element to scan
+     * @param p a scanner-specified parameter
      * @return the result of visiting {@code e}.
      */
     public R scan(Element e, P p) {
@@ -143,6 +146,8 @@
 
     /**
      * Convenience method equivalent to {@code v.scan(e, null)}.
+     *
+     * @param e the element to scan
      * @return the result of scanning {@code e}.
      */
     public final R scan(Element e) {
--- a/langtools/src/share/classes/javax/lang/model/util/Elements.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/javax/lang/model/util/Elements.java	Fri May 17 10:13:34 2013 -0700
@@ -247,6 +247,7 @@
      * argument.
      *
      * @param cs the character sequence to return as a name
+     * @return a name with the same sequence of characters as the argument
      */
     Name getName(CharSequence cs);
 
--- a/langtools/src/share/classes/javax/lang/model/util/Types.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/src/share/classes/javax/lang/model/util/Types.java	Fri May 17 10:13:34 2013 -0700
@@ -52,6 +52,7 @@
      * Returns {@code null} if the type is not one with a
      * corresponding element.
      *
+     * @param t the type to map to an element
      * @return the element corresponding to the given type
      */
     Element asElement(TypeMirror t);
--- a/langtools/src/share/classes/javax/tools/annotation/GenerateNativeHeader.java	Thu May 16 12:16:07 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package javax.tools.annotation;
-
-import java.lang.annotation.*;
-import static java.lang.annotation.RetentionPolicy.*;
-import static java.lang.annotation.ElementType.*;
-
-/**
- * An annotation used to indicate that a native header file
- * should be generated for this class.
- *
- * Normally, the presence of native methods is a sufficient
- * indication of the need for a native header file.  However,
- * in some cases, a class may contain constants of interest to
- * native code, without containing any native methods.
- *
- * @since 1.8
- */
-@Documented
-@Target(TYPE)
-@Retention(SOURCE)
-public @interface GenerateNativeHeader {
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/sample/language/model/CoreReflectionFactory.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,3771 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.lang.annotation.Annotation;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.element.*;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.type.*;
+import javax.lang.model.util.*;
+import java.lang.reflect.*;
+import java.io.Writer;
+import java.util.*;
+
+import static javax.lang.model.SourceVersion.RELEASE_8;
+import static java.util.Objects.*;
+
+/**
+ * This class provides a proof-of-concept implementation of the {@code
+ * javax.lang.model.*} API backed by core reflection. That is, rather
+ * than having a source file or compile-time class file as the
+ * originator of the information about an element or type, as done
+ * during standard annotation processing, runtime core reflection
+ * objects serve that purpose instead.
+ *
+ * With this kind of implementation, the same logic can be used for
+ * both compile-time and runtime processing of annotations.
+ *
+ * The nested types in this class define a specialization of {@code
+ * javax.lang.model.*} to provide some additional functionality and
+ * type information. The original {@code javax.lang.model.*} API was
+ * designed to accommodate such a specialization by using wildcards in
+ * the return types of methods.
+ *
+ * It would be technically possible for further specializations of the
+ * API implemented in this class to define alternative semantics of
+ * annotation look-up. For example to allow one annotation to have the
+ * effect of macro-expanding into a set of other annotations.
+ *
+ * Some aspects of the implementation are left as "exercises for the
+ * reader" to complete if interested.
+ *
+ * When passed null pointers, the methods defined in this type will
+ * generally throw null pointer exceptions.
+ *
+ * To get started, first compile this file with a command line like:
+ *
+ * <pre>
+ * $JDK/bin/javac -parameters -Xdoclint:all/public -Xlint:all -d $OUTPUT_DIR CoreReflectionFactory.java
+ * </pre>
+ *
+ * and then run the main method of {@code CoreReflectionFactory},
+ * which will print out a representation of {@code
+ * CoreReflectionFactory}. To use the printing logic defined in {@code
+ * javac}, put {@code tools.jar} on the classpath as in:
+ *
+ * <pre>
+ * $JDK/bin/java -cp $OUTPUT_DIR:$JDK_ROOT/lib/tools.jar CoreReflectionFactory
+ * </pre>
+ *
+ * @author Joseph D. Darcy (darcy)
+ * @author Joel Borggren-Franck (jfranck)
+ */
+public class CoreReflectionFactory {
+    private CoreReflectionFactory() {
+        throw new AssertionError("No instances of CoreReflectionFactory for you!");
+    }
+
+    /**
+     * Returns a reflection type element mirroring a {@code Class} object.
+     * @return a reflection type element mirroring a {@code Class} object
+     * @param clazz the {@code Class} to mirror
+     */
+    public static ReflectionTypeElement createMirror(Class<?> clazz) {
+        return new CoreReflTypeElement(Objects.requireNonNull(clazz));
+    }
+
+    /**
+     * Returns a reflection package element mirroring a {@code Package} object.
+     * @return a reflection package element mirroring a {@code Package} object
+     * @param pkg the {@code Package} to mirror
+     */
+    public static ReflectionPackageElement createMirror(Package pkg) {
+        // Treat a null pkg to mean an unnamed package.
+        return new CoreReflPackageElement(pkg);
+    }
+
+    /**
+     * Returns a reflection variable element mirroring a {@code Field} object.
+     * @return a reflection variable element mirroring a {@code Field} object
+     * @param field the {@code Field} to mirror
+     */
+    public static ReflectionVariableElement createMirror(Field field) {
+        return new CoreReflFieldVariableElement(Objects.requireNonNull(field));
+    }
+
+    /**
+     * Returns a reflection executable element mirroring a {@code Method} object.
+     * @return a reflection executable element mirroring a {@code Method} object
+     * @param method the {@code Method} to mirror
+     */
+    public static ReflectionExecutableElement createMirror(Method method)  {
+        return new CoreReflMethodExecutableElement(Objects.requireNonNull(method));
+    }
+
+    /**
+     * Returns a reflection executable element mirroring a {@code Constructor} object.
+     * @return a reflection executable element mirroring a {@code Constructor} object
+     * @param constructor the {@code Constructor} to mirror
+     */
+    public static ReflectionExecutableElement createMirror(Constructor<?> constructor)  {
+        return new CoreReflConstructorExecutableElement(Objects.requireNonNull(constructor));
+    }
+
+    /**
+     * Returns a type parameter element mirroring a {@code TypeVariable} object.
+     * @return a type parameter element mirroring a {@code TypeVariable} object
+     * @param tv the {@code TypeVariable} to mirror
+     */
+    public static TypeParameterElement createMirror(java.lang.reflect.TypeVariable<?> tv) {
+        return new CoreReflTypeParameterElement(Objects.requireNonNull(tv));
+    }
+
+    /**
+     * Returns a variable element mirroring a {@code Parameter} object.
+     * @return a variable element mirroring a {@code Parameter} object
+     * @param p the {Parameter} to mirror
+     */
+    public static VariableElement createMirror(java.lang.reflect.Parameter p) {
+        return new CoreReflParameterVariableElement(Objects.requireNonNull(p));
+    }
+
+    /**
+     * Returns an annotation mirror mirroring an annotation object.
+     * @return an annotation mirror mirroring an annotation object
+     * @param annotation the annotation to mirror
+     */
+    public static AnnotationMirror createMirror(Annotation annotation)  {
+        return new CoreReflAnnotationMirror(Objects.requireNonNull(annotation));
+    }
+
+    /**
+     * Returns a {@code Types} utility object for type objects backed by core reflection.
+     * @return a {@code Types} utility object for type objects backed by core reflection
+     */
+    public static Types getTypes() {
+        return CoreReflTypes.instance();
+    }
+
+    /**
+     * Returns an {@code Elements} utility object for type objects backed by core reflection.
+     * @return an {@code Elements} utility object for type objects backed by core reflection
+     */
+    public static Elements getElements() {
+        return CoreReflElements.instance();
+    }
+
+    // Helper
+    private static TypeMirror createTypeMirror(Class<?> c) {
+        return TypeFactory.instance(Objects.requireNonNull(c));
+    }
+
+    /**
+     * Main method; prints out a representation of this class.
+     * @param args command-line arguments, currently ignored
+     */
+    public static void main(String... args) {
+        getElements().printElements(new java.io.PrintWriter(System.out),
+                                    createMirror(CoreReflectionFactory.class));
+    }
+
+    /**
+     * A specialization of {@code javax.lang.model.element.Element} that is
+     * backed by core reflection.
+     */
+    public static interface ReflectionElement
+        extends Element, AnnotatedElement {
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        ReflectionElement getEnclosingElement();
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        List<ReflectionElement> getEnclosedElements();
+
+        /**
+         * Applies a visitor to this element.
+         *
+         * @param v the visitor operating on this element
+         * @param p additional parameter to the visitor
+         * @param <R> the return type of the visitor's methods
+         * @param <P> the type of the additional parameter to the visitor's methods
+         * @return a visitor-specified result
+         */
+        <R,P> R accept(ReflectionElementVisitor<R,P> v, P p);
+
+        // Functionality specific to the specialization
+        /**
+         * Returns the underlying core reflection source object, if applicable.
+         * @return the underlying core reflection source object, if applicable
+         */
+        AnnotatedElement getSource();
+
+        // Functionality from javax.lang.model.util.Elements
+        /**
+         * Returns the package of an element. The package of a package
+         * is itself.
+         * @return the package of an element
+         */
+        ReflectionPackageElement getPackage();
+
+    }
+
+    /**
+     * A logical specialization of {@code
+     * javax.lang.model.element.ElementVisitor} being backed by core
+     * reflection.
+     *
+     * @param <R> the return type of this visitor's methods.
+     * @param <P> the type of the additional parameter to this visitor's
+     *            methods.
+     */
+    public static interface ReflectionElementVisitor<R, P> {
+        /**
+         * Visits an element.
+         * @param e  the element to visit
+         * @param p  a visitor-specified parameter
+         * @return a visitor-specified result
+         */
+        R visit(ReflectionElement e, P p);
+
+        /**
+         * A convenience method equivalent to {@code v.visit(e, null)}.
+         * @param e  the element to visit
+         * @return a visitor-specified result
+         */
+        R visit(ReflectionElement e);
+
+        /**
+         * Visits a package element.
+         * @param e  the element to visit
+         * @param p  a visitor-specified parameter
+         * @return a visitor-specified result
+         */
+        R visitPackage(ReflectionPackageElement e, P p);
+
+        /**
+         * Visits a type element.
+         * @param e  the element to visit
+         * @param p  a visitor-specified parameter
+         * @return a visitor-specified result
+         */
+        R visitType(ReflectionTypeElement e, P p);
+
+        /**
+         * Visits a variable element.
+         * @param e  the element to visit
+         * @param p  a visitor-specified parameter
+         * @return a visitor-specified result
+         */
+        R visitVariable(ReflectionVariableElement e, P p);
+
+        /**
+         * Visits an executable element.
+         * @param e  the element to visit
+         * @param p  a visitor-specified parameter
+         * @return a visitor-specified result
+         */
+        R visitExecutable(ReflectionExecutableElement e, P p);
+
+        /**
+         * Visits a type parameter element.
+         * @param e  the element to visit
+         * @param p  a visitor-specified parameter
+         * @return a visitor-specified result
+         */
+        R visitTypeParameter(ReflectionTypeParameterElement e, P p);
+
+        /**
+         * Visits an unknown kind of element.
+         * This can occur if the language evolves and new kinds
+         * of elements are added to the {@code Element} hierarchy.
+         *
+         * @param e  the element to visit
+         * @param p  a visitor-specified parameter
+         * @return a visitor-specified result
+         * @throws UnknownElementException
+         * a visitor implementation may optionally throw this exception
+         */
+        R visitUnknown(ReflectionElement e, P p);
+    }
+
+    /**
+     * A specialization of {@code javax.lang.model.element.ExecutableElement} that is
+     * backed by core reflection.
+     */
+    public static interface ReflectionExecutableElement
+        extends ReflectionElement, ExecutableElement, ReflectionParameterizable {
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        List<ReflectionTypeParameterElement> getTypeParameters();
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        List<ReflectionVariableElement> getParameters();
+
+        // Functionality specific to the specialization
+        /**
+         * Returns all parameters, including synthetic ones.
+         * @return all parameters, including synthetic ones
+         */
+        List<ReflectionVariableElement> getAllParameters();
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        Executable getSource();
+
+        /**
+         * Returns true if this executable is a synthetic construct; returns false otherwise.
+         * @return true if this executable is a synthetic construct; returns false otherwise
+         */
+        boolean isSynthetic();
+
+        /**
+         * Returns true if this executable is a bridge method; returns false otherwise.
+         * @return true if this executable is a bridge method; returns false otherwise
+         */
+        boolean isBridge();
+    }
+
+    /**
+     * A specialization of {@code javax.lang.model.element.PackageElement} being
+     * backed by core reflection.
+     */
+    public static interface ReflectionPackageElement
+        extends ReflectionElement, PackageElement {
+
+        // Functionality specific to the specialization
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        Package getSource();
+    }
+
+    /**
+     * A specialization of {@code javax.lang.model.element.TypeElement} that is
+     * backed by core reflection.
+     */
+    public static interface ReflectionTypeElement
+        extends ReflectionElement, TypeElement, ReflectionParameterizable {
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        List<ReflectionTypeParameterElement> getTypeParameters();
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        List<ReflectionElement> getEnclosedElements();
+
+        // Methods specific to the specialization, but functionality
+        // also present in javax.lang.model.util.Elements.
+        /**
+         * Returns all members of a type element, whether inherited or
+         * declared directly. For a class the result also includes its
+         * constructors, but not local or anonymous classes.
+         * @return all members of the type
+         */
+        List<ReflectionElement> getAllMembers();
+
+        /**
+         * Returns the binary name of a type element.
+         * @return the binary name of a type element
+         */
+        Name getBinaryName();
+
+        // Functionality specific to the specialization
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        Class<?> getSource();
+    }
+
+    /**
+     * A specialization of {@code javax.lang.model.element.TypeParameterElement} being
+     * backed by core reflection.
+     */
+    public static interface ReflectionTypeParameterElement
+        extends ReflectionElement, TypeParameterElement {
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        ReflectionElement getGenericElement();
+
+        // Functionality specific to the specialization
+
+        // Conceptually should have an override for getSource
+        // returning GenericDeclaration, but GenericDeclaration
+        // doesn't currently implement AnnotatedElement.
+//         /**
+//          * {@inheritDoc}
+//          */
+//         @Override
+//         java.lang.reflect.GenericDeclaration getSource();
+    }
+
+    /**
+     * A specialization of {@code javax.lang.model.element.VariableElement} that is
+     * backed by core reflection.
+     */
+    public static interface ReflectionVariableElement
+        extends ReflectionElement, VariableElement {
+
+        // Functionality specific to the specialization
+        /**
+         * Returns true if this variable is a synthetic construct; returns false otherwise.
+         * @return true if this variable is a synthetic construct; returns false otherwise
+         */
+        boolean isSynthetic();
+
+        /**
+         * Returns true if this variable is implicitly declared in source code; returns false otherwise.
+         * @return true if this variable is implicitly declared in source code; returns false otherwise
+         */
+        boolean isImplicit();
+
+        // The VariableElement concept covers fields, variables, and
+        // method and constructor parameters. Therefore, this
+        // interface cannot define a more precise override of
+        // getSource since those three concept have different core
+        // reflection types with no supertype more precise than
+        // AnnotatedElement.
+    }
+
+    /**
+     * A specialization of {@code javax.lang.model.element.Parameterizable} being
+     * backed by core reflection.
+     */
+    public static interface ReflectionParameterizable
+        extends ReflectionElement, Parameterizable {
+        @Override
+        List<ReflectionTypeParameterElement> getTypeParameters();
+    }
+
+    /**
+     * Base class for concrete visitors of elements backed by core reflection.
+     */
+    public static abstract class AbstractReflectionElementVisitor8<R, P>
+        extends AbstractElementVisitor8<R, P>
+        implements ReflectionElementVisitor<R, P> {
+        protected AbstractReflectionElementVisitor8() {
+            super();
+        }
+    }
+
+    /**
+     * Base class for simple visitors of elements that are backed by core reflection.
+     */
+    @SupportedSourceVersion(value=RELEASE_8)
+    public static abstract class SimpleReflectionElementVisitor8<R, P>
+        extends SimpleElementVisitor8<R, P>
+        implements ReflectionElementVisitor<R, P> {
+
+        protected SimpleReflectionElementVisitor8(){
+            super();
+        }
+
+        protected SimpleReflectionElementVisitor8(R defaultValue) {
+            super(defaultValue);
+        }
+
+        // Create manual "bridge methods" for now.
+
+        @Override
+        public final R visitPackage(PackageElement e, P p) {
+            return visitPackage((ReflectionPackageElement) e , p);
+        }
+
+        @Override
+        public final R visitType(TypeElement e, P p) {
+            return visitType((ReflectionTypeElement) e , p);
+        }
+
+        @Override
+        public final R visitVariable(VariableElement e, P p) {
+            return visitVariable((ReflectionVariableElement) e , p);
+        }
+
+        @Override
+        public final R visitExecutable(ExecutableElement e, P p) {
+            return visitExecutable((ReflectionExecutableElement) e , p);
+        }
+
+        @Override
+        public final R visitTypeParameter(TypeParameterElement e, P p) {
+            return visitTypeParameter((ReflectionTypeParameterElement) e , p);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public static interface ReflectionElements  extends Elements {
+        /**
+         * Returns the innermost enclosing {@link ReflectionTypeElement}
+         * of the {@link ReflectionElement} or {@code null} if the
+         * supplied ReflectionElement is toplevel or represents a
+         * Package.
+         *
+         * @param e the {@link ReflectionElement} whose innermost
+         * enclosing {@link ReflectionTypeElement} is sought
+         * @return the innermost enclosing {@link
+         * ReflectionTypeElement} or @{code null} if the parameter
+         * {@code e} is a toplevel element or a package
+         */
+        ReflectionTypeElement getEnclosingTypeElement(ReflectionElement e);
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        List<? extends ReflectionElement> getAllMembers(TypeElement type);
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        ReflectionPackageElement getPackageElement(CharSequence name);
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        ReflectionPackageElement getPackageOf(Element type);
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        ReflectionTypeElement getTypeElement(CharSequence name);
+    }
+
+    // ------------------------- Implementation classes ------------------------
+
+    // Exercise for the reader: review the CoreReflElement class
+    // hierarchy below with an eye toward exposing it as an extensible
+    // API that could be subclassed to provide customized behavior,
+    // such as alternate annotation lookup semantics.
+
+    private static abstract class CoreReflElement
+        implements ReflectionElement, AnnotatedElement {
+        public abstract AnnotatedElement getSource();
+
+        protected CoreReflElement() {
+            super();
+        }
+
+        // ReflectionElement methods
+        @Override
+        public ReflectionPackageElement getPackage() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public TypeMirror asType() {
+            throw new UnsupportedOperationException(getClass().toString());
+        }
+
+        @Override
+        public List<? extends AnnotationMirror> getAnnotationMirrors() {
+            Annotation[] annotations = getSource().getDeclaredAnnotations();
+            int len = annotations.length;
+
+            if (len > 0) {
+                List<AnnotationMirror> res = new ArrayList<>(len);
+                for (Annotation a : annotations) {
+                    res.add(createMirror(a));
+                }
+                return Collections.unmodifiableList(res);
+            } else {
+                return Collections.emptyList();
+            }
+        }
+
+        @Override
+        public Set<Modifier> getModifiers() {
+            return ModifierUtil.instance(0, false);
+        }
+
+        @Override
+        public abstract Name getSimpleName();
+
+        @Override
+        public abstract ReflectionElement getEnclosingElement();
+
+        @Override
+        public abstract List<ReflectionElement> getEnclosedElements();
+
+        //AnnotatedElement methods
+        @Override
+        public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
+            return getSource().getAnnotation(annotationClass);
+        }
+
+        @Override
+        public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
+            return getSource().getAnnotationsByType(annotationClass);
+        }
+
+        @Override
+        public Annotation[] getAnnotations() {
+            return getSource().getAnnotations();
+        }
+
+        @Override
+        public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) {
+            return getSource().getDeclaredAnnotation(annotationClass);
+        }
+
+        @Override
+        public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
+            return getSource().getDeclaredAnnotationsByType(annotationClass);
+        }
+
+        @Override
+        public Annotation[] getDeclaredAnnotations() {
+            return getSource().getDeclaredAnnotations();
+        }
+
+        // java.lang.Object methods
+        @Override
+        public boolean equals(Object obj) {
+            if (obj instanceof CoreReflElement) {
+                CoreReflElement other = (CoreReflElement)obj;
+                return Objects.equals(other.getSource(), this.getSource());
+            }
+            return false;
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hashCode(getSource());
+        }
+
+        @Override
+        public String toString() {
+            return getKind().toString() + " " + getSimpleName().toString();
+        }
+    }
+
+    // Type
+    private static class CoreReflTypeElement extends CoreReflElement
+        implements ReflectionTypeElement {
+        private final Class<?> source;
+
+        protected CoreReflTypeElement(Class<?> source) {
+            Objects.requireNonNull(source);
+            if (source.isPrimitive() ||
+                source.isArray()) {
+                throw new IllegalArgumentException("Cannot create a ReflectionTypeElement based on class: " + source);
+            }
+
+            this.source = source;
+        }
+
+        @Override
+        public TypeMirror asType() {
+            return createTypeMirror(source);
+        }
+
+        @Override
+        public Class<?> getSource() {
+            return source;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o instanceof CoreReflTypeElement) {
+                return source.equals(((CoreReflTypeElement)o).getSource());
+            } else {
+                return false;
+            }
+        }
+
+        @Override
+        public <R,P> R accept(ElementVisitor<R,P> v, P p) {
+            return v.visitType(this, p);
+        }
+
+        @Override
+        public <R,P> R accept(ReflectionElementVisitor<R,P> v, P p) {
+            return v.visitType(this, p);
+        }
+
+        @Override
+        public Set<Modifier> getModifiers() {
+            return ModifierUtil.instance(source.getModifiers() &
+                                         (source.isInterface() ?
+                                          java.lang.reflect.Modifier.interfaceModifiers() :
+                                          java.lang.reflect.Modifier.classModifiers()),
+                                         false);
+        }
+
+        @Override
+        public List<ReflectionElement> getEnclosedElements() {
+            List<ReflectionElement> enclosedElements = new ArrayList<>();
+
+            for (Class<?> declaredClass : source.getDeclaredClasses()) {
+                enclosedElements.add(createMirror(declaredClass));
+            }
+
+            // Add elements in the conventional ordering: fields, then
+            // constructors, then methods.
+            for (Field f : source.getDeclaredFields()) {
+                enclosedElements.add(createMirror(f));
+            }
+
+            for (Constructor<?> c : source.getDeclaredConstructors()) {
+                enclosedElements.add(createMirror(c));
+            }
+
+            for (Method m : source.getDeclaredMethods()) {
+                enclosedElements.add(createMirror(m));
+            }
+
+            return (enclosedElements.isEmpty() ?
+                    Collections.emptyList():
+                    Collections.unmodifiableList(enclosedElements));
+        }
+
+        // Review for default method handling.
+        @Override
+        public List<ReflectionElement> getAllMembers() {
+            List<ReflectionElement> allMembers = new ArrayList<>();
+
+            // If I only had a MultiMap ...
+            List<ReflectionElement> fields = new ArrayList<>();
+            List<ReflectionExecutableElement> methods = new ArrayList<>();
+            List<ReflectionElement> classes = new ArrayList<>();
+
+            // Add all fields for this class
+            for (Field f : source.getDeclaredFields()) {
+                fields.add(createMirror(f));
+            }
+
+            // Add all methods for this class
+            for (Method m : source.getDeclaredMethods()) {
+                methods.add(createMirror(m));
+            }
+
+            // Add all classes for this class, except anonymous/local as per Elements.getAllMembers doc
+            for (Class<?> c : source.getDeclaredClasses()) {
+                if (c.isLocalClass() || c.isAnonymousClass())
+                    continue;
+                classes.add(createMirror(c));
+            }
+
+            Class<?> cls = source;
+            if (cls.isInterface()) {
+                cls = null;
+            }
+            do {
+                // Walk up superclasses adding non-private elements.
+                // If source is an interface, just add Object's
+                // elements.
+
+                if (cls == null) {
+                    cls = java.lang.Object.class;
+                } else {
+                    cls = cls.getSuperclass();
+                }
+
+                addMembers(cls, fields, methods, classes);
+
+            } while (cls != java.lang.Object.class);
+
+            // add members on (super)interface(s)
+            Set<Class<?>> seenInterfaces = new HashSet<>();
+            Queue<Class<?>> interfaces = new LinkedList<>();
+            if (source.isInterface()) {
+                seenInterfaces.add(source);
+                interfaces.add(source);
+            } else {
+                Class<?>[] ifaces = source.getInterfaces();
+                for (Class<?> iface : ifaces) {
+                    seenInterfaces.add(iface);
+                    interfaces.add(iface);
+                }
+            }
+
+            while (interfaces.peek() != null) {
+                Class<?> head = interfaces.remove();
+                addMembers(head, fields, methods, classes);
+
+                Class<?>[] ifaces = head.getInterfaces();
+                for (Class<?> iface : ifaces) {
+                    if (!seenInterfaces.contains(iface)) {
+                        seenInterfaces.add(iface);
+                        interfaces.add(iface);
+                    }
+                }
+            }
+
+            // Add constructors
+            for (Constructor<?> c : source.getDeclaredConstructors()) {
+                allMembers.add(createMirror(c));
+            }
+
+            // Add all unique methods
+            allMembers.addAll(methods);
+
+            // Add all unique fields
+            allMembers.addAll(fields);
+
+            // Add all unique classes
+            allMembers.addAll(classes);
+
+            return Collections.unmodifiableList(allMembers);
+        }
+
+        private void addMembers(Class<?> cls,
+                                List<ReflectionElement> fields,
+                                List<ReflectionExecutableElement> methods,
+                                List<ReflectionElement> classes) {
+            Elements elements = getElements();
+
+            for (Field f : cls.getDeclaredFields()) {
+                if (java.lang.reflect.Modifier.isPrivate(f.getModifiers())) { continue; }
+                ReflectionElement tmp = createMirror(f);
+                boolean add = true;
+                for (ReflectionElement e : fields) {
+                    if (elements.hides(e, tmp)) {
+                        add = false;
+                        break;
+                    }
+                }
+                if (add) {
+                    fields.add(tmp);
+                }
+            }
+
+            for (Method m : cls.getDeclaredMethods()) {
+                if (java.lang.reflect.Modifier.isPrivate(m.getModifiers()))
+                    continue;
+
+                ReflectionExecutableElement tmp = createMirror(m);
+                boolean add = true;
+                for (ReflectionExecutableElement e : methods) {
+                    if (elements.hides(e, tmp)) {
+                        add = false;
+                        break;
+                    } else if (elements.overrides(e, tmp, this)) {
+                        add = false;
+                        break;
+                    }
+                }
+                if (add) {
+                    methods.add(tmp);
+                }
+            }
+
+            for (Class<?> c : cls.getDeclaredClasses()) {
+                if (java.lang.reflect.Modifier.isPrivate(c.getModifiers()) ||
+                    c.isLocalClass() ||
+                    c.isAnonymousClass())
+                    continue;
+
+                ReflectionElement tmp = createMirror(c);
+                boolean add = true;
+                for (ReflectionElement e : classes) {
+                    if (elements.hides(e, tmp)) {
+                        add = false;
+                        break;
+                    }
+                }
+                if (add) {
+                    classes.add(tmp);
+                }
+            }
+        }
+
+        @Override
+        public ElementKind getKind() {
+            if (source.isInterface()) {
+                if (source.isAnnotation())
+                    return ElementKind.ANNOTATION_TYPE;
+                else
+                    return ElementKind.INTERFACE;
+            } else if (source.isEnum()) {
+                return ElementKind.ENUM;
+            } else
+                return ElementKind.CLASS;
+        }
+
+        @Override
+        public NestingKind getNestingKind() {
+            if (source.isAnonymousClass())
+                return NestingKind.ANONYMOUS;
+            else if (source.isLocalClass())
+                return NestingKind.LOCAL;
+            else if (source.isMemberClass())
+                return NestingKind.MEMBER;
+            else return
+                NestingKind.TOP_LEVEL;
+        }
+
+        @Override
+        public Name getQualifiedName() {
+            String name = source.getCanonicalName(); // TODO, this should be a FQN for
+                                                     // the current element
+            if (name == null)
+                name = "";
+            return StringName.instance(name);
+        }
+
+        @Override
+        public Name getSimpleName() {
+            return StringName.instance(source.getSimpleName());
+        }
+
+        @Override
+        public TypeMirror getSuperclass() {
+            if (source.equals(java.lang.Object.class)) {
+                return NoType.getNoneInstance();
+            } else {
+                return createTypeMirror(source.getSuperclass());
+            }
+        }
+
+        @Override
+        public List<? extends TypeMirror> getInterfaces() {
+            Class[] interfaces = source.getInterfaces();
+            int len = interfaces.length;
+            List<TypeMirror> res = new ArrayList<>(len);
+
+            if (len > 0) {
+                for (Class<?> c : interfaces) {
+                    res.add(createTypeMirror(c));
+                }
+            } else {
+                return Collections.emptyList();
+            }
+            return Collections.unmodifiableList(res);
+        }
+
+        @Override
+        public List<ReflectionTypeParameterElement> getTypeParameters() {
+            return createTypeParameterList(source);
+        }
+
+        @Override
+        public ReflectionElement getEnclosingElement() {
+            // Returns the package of a top-level type and returns the
+            // immediately lexically enclosing element for a nested type.
+
+            switch(getNestingKind()) {
+            case TOP_LEVEL:
+                return createMirror(source.getPackage());
+            case MEMBER:
+                return createMirror(source.getEnclosingClass());
+            default:
+                if (source.getEnclosingConstructor() != null) {
+                    return createMirror(source.getEnclosingConstructor());
+                } else if (source.getEnclosingMethod() != null) {
+                    return createMirror(source.getEnclosingMethod());
+                } else {
+                    return createMirror(source.getEnclosingClass());
+                }
+            }
+        }
+
+        @Override
+        public Name getBinaryName() {
+            return StringName.instance(getSource().getName());
+        }
+    }
+
+    private static abstract class CoreReflExecutableElement extends CoreReflElement
+        implements ReflectionExecutableElement {
+
+        protected Executable source = null;
+        protected final List<CoreReflParameterVariableElement> parameters;
+
+        protected CoreReflExecutableElement(Executable source,
+                                            List<CoreReflParameterVariableElement> parameters) {
+            this.source = Objects.requireNonNull(source);
+            this.parameters = Objects.requireNonNull(parameters);
+        }
+
+        @Override
+        public <R,P> R accept(ElementVisitor<R,P> v, P p) {
+            return v.visitExecutable(this, p);
+        }
+
+        @Override
+        public <R,P> R accept(ReflectionElementVisitor<R,P> v, P p) {
+            return v.visitExecutable(this, p);
+        }
+
+        @Override
+        public abstract ExecutableType asType();
+
+        // Only Types and Packages enclose elements; see Element.getEnclosedElements()
+        @Override
+        public List<ReflectionElement> getEnclosedElements() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<ReflectionVariableElement> getParameters() {
+            List<ReflectionVariableElement> tmp = new ArrayList<>();
+            for (ReflectionVariableElement parameter : parameters) {
+                if (!parameter.isSynthetic())
+                    tmp.add(parameter);
+            }
+            return tmp;
+        }
+
+        @Override
+        public List<ReflectionVariableElement> getAllParameters() {
+            // Could "fix" this if the return type included wildcards
+            @SuppressWarnings("unchecked")
+            List<ReflectionVariableElement> tmp = (List<ReflectionVariableElement>)(List)parameters;
+            return tmp;
+        }
+
+        @Override
+        public List<? extends TypeMirror> getThrownTypes() {
+            Class<?>[] thrown = source.getExceptionTypes();
+            int len = thrown.length;
+            List<TypeMirror> res = new ArrayList<>(len);
+
+            if (len > 0) {
+                for (Class<?> c : thrown) {
+                    res.add(createTypeMirror(c));
+                }
+            } else {
+                return Collections.emptyList();
+            }
+            return Collections.unmodifiableList(res);
+        }
+
+        @Override
+        public boolean isVarArgs() {
+            return source.isVarArgs();
+        }
+
+        @Override
+        public boolean isSynthetic() {
+            return source.isSynthetic();
+        }
+
+        @Override
+        public boolean isBridge() {
+            return false;
+        }
+
+        @Override
+        public List<ReflectionTypeParameterElement> getTypeParameters() {
+            return createTypeParameterList(source);
+        }
+
+        public abstract AnnotationValue getDefaultValue();
+
+        @Override
+        public TypeMirror getReceiverType() {
+            // New in JDK 8
+            throw new UnsupportedOperationException(this.toString());
+        }
+    }
+
+    private static class CoreReflConstructorExecutableElement
+        extends CoreReflExecutableElement {
+
+        protected CoreReflConstructorExecutableElement(Constructor<?> source) {
+            super(Objects.requireNonNull(source),
+                  createParameterList(source));
+        }
+
+        @Override
+        public  Constructor<?> getSource() {
+            return (Constructor<?>)source;
+        }
+
+        @Override
+        public TypeMirror getReturnType() {
+            return NoType.getVoidInstance();
+        }
+
+        @Override
+        public ExecutableType asType() {
+            throw new UnsupportedOperationException(getClass().toString());
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o instanceof CoreReflConstructorExecutableElement) {
+                return source.equals(((CoreReflConstructorExecutableElement)o).getSource());
+            } else {
+                return false;
+            }
+        }
+
+        @Override
+        public ElementKind getKind() {
+            return ElementKind.CONSTRUCTOR;
+        }
+
+        @Override
+        public Set<Modifier> getModifiers() {
+            return ModifierUtil.instance(source.getModifiers() &
+                                         java.lang.reflect.Modifier.constructorModifiers(), false);
+        }
+
+        @Override
+        public ReflectionElement getEnclosingElement() {
+            return createMirror(source.getDeclaringClass());
+        }
+
+        @Override
+        public Name getSimpleName() {
+            return StringName.instance("<init>");
+        }
+
+        @Override
+        public AnnotationValue getDefaultValue() {
+            // a constructor is never an annotation element
+            return null;
+        }
+
+        @Override
+        public boolean isDefault() {
+            return false; // A constructor cannot be a default method
+        }
+    }
+
+    private static class CoreReflMethodExecutableElement
+        extends CoreReflExecutableElement {
+
+        protected CoreReflMethodExecutableElement(Method source) {
+            super(Objects.requireNonNull(source),
+                  createParameterList(source));
+            this.source = source;
+        }
+
+        @Override
+        public Method getSource() {
+            return (Method)source;
+        }
+
+        @Override
+        public TypeMirror getReturnType() {
+            return TypeFactory.instance(getSource().getReturnType());
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o instanceof CoreReflMethodExecutableElement) {
+                return source.equals( ((CoreReflMethodExecutableElement)o).getSource());
+            } else {
+                return false;
+            }
+        }
+
+        @Override
+        public ElementKind getKind() {
+            return ElementKind.METHOD;
+        }
+
+        @Override
+        public Set<Modifier> getModifiers() {
+            return ModifierUtil.instance(source.getModifiers() &
+                                         java.lang.reflect.Modifier.methodModifiers(),
+                                         isDefault());
+        }
+
+        @Override
+        public ReflectionElement getEnclosingElement() {
+            return createMirror(source.getDeclaringClass());
+        }
+
+        @Override
+        public Name getSimpleName() {
+            return StringName.instance(source.getName());
+        }
+
+        @Override
+        public AnnotationValue getDefaultValue() {
+            Object value = getSource().getDefaultValue();
+            if (null == value) {
+                return null;
+            } else {
+                return new CoreReflAnnotationValue(value);
+            }
+        }
+
+        @Override
+        public boolean isDefault() {
+            return getSource().isDefault();
+        }
+
+        @Override
+        public boolean isBridge() {
+            return getSource().isBridge();
+        }
+
+        @Override
+        public ExecutableType asType() {
+            return TypeFactory.instance(getSource());
+        }
+    }
+
+    private static List<CoreReflParameterVariableElement> createParameterList(Executable source) {
+        Parameter[] parameters = source.getParameters();
+        int length = parameters.length;
+        if (length == 0)
+            return Collections.emptyList();
+        else {
+            List<CoreReflParameterVariableElement> tmp = new ArrayList<>(length);
+            for (Parameter parameter : parameters) {
+                tmp.add(new CoreReflParameterVariableElement(parameter));
+            }
+            return Collections.unmodifiableList(tmp);
+        }
+    }
+
+    private static List<ReflectionTypeParameterElement> createTypeParameterList(GenericDeclaration source) {
+        java.lang.reflect.TypeVariable<?>[] typeParams = source.getTypeParameters();
+        int length = typeParams.length;
+        if (length == 0)
+            return Collections.emptyList();
+        else {
+            List<ReflectionTypeParameterElement> tmp = new ArrayList<>(length);
+            for (java.lang.reflect.TypeVariable<?> typeVar : typeParams)
+                tmp.add(new CoreReflTypeParameterElement(typeVar));
+            return Collections.unmodifiableList(tmp);
+        }
+    }
+
+    private static class CoreReflTypeParameterElement
+        extends CoreReflElement
+        implements ReflectionTypeParameterElement {
+
+        private final GenericDeclaration source;
+        private final java.lang.reflect.TypeVariable<?> sourceTypeVar;
+
+        protected CoreReflTypeParameterElement(java.lang.reflect.TypeVariable<?> sourceTypeVar) {
+            this.sourceTypeVar = Objects.requireNonNull(sourceTypeVar);
+            this.source = Objects.requireNonNull(sourceTypeVar.getGenericDeclaration());
+        }
+
+        @Override
+        public AnnotatedElement getSource() {
+            return (AnnotatedElement)source;
+        }
+
+        protected java.lang.reflect.TypeVariable<?> getSourceTypeVar() {
+            return sourceTypeVar;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o instanceof CoreReflTypeParameterElement) {
+                return sourceTypeVar.equals(((CoreReflTypeParameterElement)o).sourceTypeVar);
+            } else {
+                return false;
+            }
+        }
+
+        @Override
+        public <R,P> R accept(ElementVisitor<R,P> v, P p) {
+            return v.visitTypeParameter(this, p);
+        }
+
+        @Override
+        public <R,P> R accept(ReflectionElementVisitor<R,P> v, P p) {
+            return v.visitTypeParameter(this, p);
+        }
+
+        @Override
+        public List<ReflectionElement> getEnclosedElements() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public ReflectionElement getEnclosingElement() {
+            if (source instanceof Class)
+                return createMirror((Class<?>)source);
+            else if (source instanceof Method)
+                return createMirror((Method)source);
+            else if (source instanceof Constructor)
+                return createMirror((Constructor<?>)source);
+            else
+                throw new AssertionError("Unexpected enclosing element: " + source);
+        }
+
+        @Override
+        public ElementKind getKind() {
+            return ElementKind.TYPE_PARAMETER;
+        }
+
+        @Override
+        public Name getSimpleName() {
+            return StringName.instance(sourceTypeVar.getName());
+        }
+
+        // TypeParameterElement methods
+        @Override
+        public ReflectionElement getGenericElement() {
+            return getEnclosingElement(); // As per the doc,
+                                          // getEnclosingElement and
+                                          // getGenericElement return
+                                          // the same information.
+        }
+
+        @Override
+        public List<? extends TypeMirror> getBounds() {
+            Type[] types = getSourceTypeVar().getBounds();
+            int len = types.length;
+
+            if (len > 0) {
+                List<TypeMirror> res = new ArrayList<>(len);
+                for (Type t : types) {
+                    res.add(TypeFactory.instance(t));
+                }
+                return Collections.unmodifiableList(res);
+            } else {
+                return Collections.emptyList();
+            }
+        }
+    }
+
+    private abstract static class CoreReflVariableElement extends CoreReflElement
+        implements ReflectionVariableElement {
+
+        protected CoreReflVariableElement() {}
+
+        // Element visitor
+        @Override
+        public <R,P> R accept(ElementVisitor<R,P>v, P p) {
+            return v.visitVariable(this, p);
+        }
+
+        // ReflectElement visitor
+        @Override
+        public <R,P> R accept(ReflectionElementVisitor<R,P> v, P p) {
+            return v.visitVariable(this, p);
+        }
+
+        @Override
+        public List<ReflectionElement> getEnclosedElements() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public ReflectionElement getEnclosingElement() {
+            return null;
+        }
+
+        @Override
+        public boolean isSynthetic() {
+            return false;
+        }
+
+        @Override
+        public boolean isImplicit() {
+            return false;
+        }
+    }
+
+    private static class CoreReflFieldVariableElement extends CoreReflVariableElement {
+        private final Field source;
+
+        protected CoreReflFieldVariableElement(Field source) {
+            this.source = Objects.requireNonNull(source);
+        }
+
+        @Override
+        public Field getSource() {
+            return source;
+        }
+
+        @Override
+        public TypeMirror asType() {
+            return createTypeMirror(getSource().getType());
+        }
+
+        @Override
+        public ElementKind getKind() {
+            if (source.isEnumConstant())
+                return ElementKind.ENUM_CONSTANT;
+            else
+                return ElementKind.FIELD;
+        }
+
+        @Override
+        public Set<Modifier> getModifiers() {
+            return ModifierUtil.instance(source.getModifiers() &
+                                         java.lang.reflect.Modifier.fieldModifiers(), false);
+        }
+
+        @Override
+        public Name getSimpleName() {
+            return StringName.instance(source.getName());
+        }
+
+        @Override
+        public ReflectionElement getEnclosingElement() {
+            return createMirror(source.getDeclaringClass());
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o instanceof CoreReflFieldVariableElement) {
+                return Objects.equals(source,
+                                      ((CoreReflFieldVariableElement)o).getSource());
+            } else {
+                return false;
+            }
+        }
+
+        @Override
+        public Object getConstantValue() {
+            Field target = source;
+
+            // The api says only Strings and primitives may be compile time constants.
+            // Ensure field is that, and final.
+            //
+            // Also, we don't have an instance so restrict to static Fields
+            //
+            if (!(source.getType().equals(java.lang.String.class)
+                  || source.getType().isPrimitive())) {
+                return null;
+            }
+            final int modifiers = target.getModifiers();
+            if (!( java.lang.reflect.Modifier.isFinal(modifiers) &&
+                   java.lang.reflect.Modifier.isStatic(modifiers))) {
+                return null;
+            }
+
+            try {
+                return target.get(null);
+            } catch (IllegalAccessException e) {
+                try {
+                    target.setAccessible(true);
+                    return target.get(null);
+                } catch (IllegalAccessException i) {
+                    throw new SecurityException(i);
+                }
+            }
+        }
+    }
+
+    private static class CoreReflParameterVariableElement
+        extends CoreReflVariableElement {
+        private final Parameter source;
+
+        protected CoreReflParameterVariableElement(Parameter source) {
+            this.source = Objects.requireNonNull(source);
+        }
+
+        @Override
+        public Parameter getSource() {
+            return source;
+        }
+
+        @Override
+        public Set<Modifier> getModifiers() {
+            return ModifierUtil.instance(source.getModifiers() &
+                                         java.lang.reflect.Modifier.parameterModifiers(), false);
+        }
+
+        @Override
+        public TypeMirror asType() {
+            // TODO : switch to parameterized type
+            return createTypeMirror(source.getType());
+        }
+
+        @Override
+        public ElementKind getKind() {
+            return ElementKind.PARAMETER;
+        }
+
+        @Override
+        public Name getSimpleName() {
+            return StringName.instance(source.getName());
+        }
+
+        @Override
+        public ReflectionElement getEnclosingElement() {
+            Executable enclosing = source.getDeclaringExecutable();
+            if (enclosing instanceof Method)
+                return createMirror((Method)enclosing);
+            else if (enclosing instanceof Constructor)
+                return createMirror((Constructor<?>)enclosing);
+            else
+                throw new AssertionError("Bad enclosing value.");
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o instanceof CoreReflParameterVariableElement) {
+                return source.equals(((CoreReflParameterVariableElement) o).getSource());
+            } else
+                return false;
+        }
+
+        // VariableElement methods
+        @Override
+        public Object getConstantValue() {
+            return null;
+        }
+
+        @Override
+        public boolean isSynthetic() {
+            return source.isSynthetic();
+        }
+
+        @Override
+        public boolean isImplicit() {
+            return source.isImplicit();
+        }
+    }
+
+    private static class CoreReflPackageElement extends CoreReflElement
+        implements ReflectionPackageElement {
+
+        private final Package source;
+
+        protected CoreReflPackageElement(Package source) {
+            this.source = source;
+        }
+
+        @Override
+        public Package getSource() {
+            return source;
+        }
+
+        @Override
+        public <R,P> R accept(ElementVisitor<R,P> v, P p) {
+            return v.visitPackage(this, p);
+        }
+
+        @Override
+        public <R,P> R accept(ReflectionElementVisitor<R,P> v, P p) {
+            return v.visitPackage(this, p);
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o instanceof CoreReflPackageElement) {
+                return Objects.equals(source,
+                                      ((CoreReflPackageElement)o).getSource());
+            } else {
+                return false;
+            }
+        }
+
+        @Override
+        public ElementKind getKind() {
+            return ElementKind.PACKAGE;
+        }
+
+        @Override
+        public ReflectionElement getEnclosingElement() {
+            return null;
+        }
+
+        @Override
+        public List<ReflectionElement> getEnclosedElements() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public Name getQualifiedName() {
+            return StringName.instance((source != null) ?
+                                       source.getName() :
+                                       "" );
+        }
+
+        @Override
+        public Name getSimpleName() {
+            String n = ((source != null) ?
+                        source.getName() :
+                        "");
+            int index = n.lastIndexOf('.');
+            if (index > 0) {
+                return StringName.instance(n.substring(index + 1, n.length()));
+            } else {
+                return StringName.instance(n);
+            }
+        }
+
+        @Override
+        public boolean isUnnamed() {
+            if (source != null) {
+                String name = source.getName();
+                return(name == null || name.isEmpty());
+            } else
+                return true;
+        }
+    }
+
+    private static class CoreReflAnnotationMirror
+        implements javax.lang.model.element.AnnotationMirror {
+        private final Annotation annotation;
+
+        protected CoreReflAnnotationMirror(Annotation annotation) {
+            this.annotation = Objects.requireNonNull(annotation);
+        }
+
+        @Override
+        public DeclaredType getAnnotationType() {
+            return (DeclaredType)TypeFactory.instance(annotation.annotationType());
+        }
+
+        @Override
+        public Map<? extends ReflectionExecutableElement, ? extends AnnotationValue> getElementValues() {
+            // This differs from the javac implementation in that it returns default values
+
+            Method[] elems = annotation.annotationType().getDeclaredMethods();
+            int len = elems.length;
+
+            if (len > 0) {
+                Map<ReflectionExecutableElement, AnnotationValue> res = new HashMap<>();
+                for (Method m : elems) {
+                    AnnotationValue v;
+                    try {
+                        v = new CoreReflAnnotationValue(m.invoke(annotation));
+                    } catch (IllegalAccessException e) {
+                        try {
+                            m.setAccessible(true);
+                            v = new CoreReflAnnotationValue(m.invoke(annotation));
+                        } catch (IllegalAccessException i) {
+                            throw new SecurityException(i);
+                        } catch (InvocationTargetException ee) {
+                            throw new RuntimeException(ee);
+                        }
+                    } catch (InvocationTargetException ee) {
+                        throw new RuntimeException(ee);
+                    }
+                    ReflectionExecutableElement e = createMirror(m);
+                    res.put(e, v);
+                }
+
+                return Collections.unmodifiableMap(res);
+            } else {
+                return Collections.emptyMap();
+            }
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (other instanceof CoreReflAnnotationMirror) {
+                return annotation.equals(((CoreReflAnnotationMirror)other).annotation);
+            } else {
+                return false;
+            }
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hashCode(annotation);
+        }
+
+        @Override
+        public String toString() {
+            return annotation.toString();
+        }
+    }
+
+    private static class CoreReflAnnotationValue
+        implements javax.lang.model.element.AnnotationValue {
+        private Object value = null;
+
+        protected CoreReflAnnotationValue(Object value) {
+            // Is this constraint really necessary?
+            Objects.requireNonNull(value);
+            this.value = value;
+        }
+
+        @Override
+        public Object getValue() {
+            return value;
+        }
+
+        @Override
+        public String toString() {
+            return value.toString();
+        }
+
+        @Override
+        public <R,P> R accept(AnnotationValueVisitor<R,P> v, P p) {
+            return v.visit(this, p);
+        }
+    }
+
+    // Helper utility classes
+
+    private static class StringName implements Name {
+        private String name;
+
+        private StringName(String name) {
+            this.name = Objects.requireNonNull(name);
+        }
+
+        public static StringName instance(String name) {
+            return new StringName(name);
+        }
+
+        @Override
+        public int length() {
+            return name.length();
+        }
+
+        @Override
+        public char charAt(int index) {
+            return name.charAt(index);
+        }
+
+        @Override
+        public CharSequence subSequence(int start, int end) {
+            return name.subSequence(start, end);
+        }
+
+        @Override
+        public String toString() {
+            return name;
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (other instanceof StringName) {
+                return name.equals(((StringName) other).name);
+            } else {
+                return false;
+            }
+        }
+
+        @Override
+        public int hashCode() {
+            return name.hashCode();
+        }
+
+        @Override
+        public boolean contentEquals(CharSequence cs) {
+            return name.contentEquals(cs);
+        }
+    }
+
+    /*
+     * Given an {@code int} value of modifiers, return a proper immutable set
+     * of {@code Modifier}s as a result.
+     */
+    private static class ModifierUtil {
+        private ModifierUtil() {
+            throw new AssertionError("No instances for you.");
+        }
+
+        // Exercise for the reader: explore if caching of sets of
+        // Modifiers would be helpful.
+
+        public static Set<Modifier> instance(int modifiers, boolean isDefault) {
+            Set<Modifier> modSet = EnumSet.noneOf(Modifier.class);
+
+            if (java.lang.reflect.Modifier.isAbstract(modifiers))
+                modSet.add(Modifier.ABSTRACT);
+
+            if (java.lang.reflect.Modifier.isFinal(modifiers))
+                modSet.add(Modifier.FINAL);
+
+            if (java.lang.reflect.Modifier.isNative(modifiers))
+                modSet.add(Modifier.NATIVE);
+
+            if (java.lang.reflect.Modifier.isPrivate(modifiers))
+                modSet.add(Modifier.PRIVATE);
+
+            if (java.lang.reflect.Modifier.isProtected(modifiers))
+                modSet.add(Modifier.PROTECTED);
+
+            if (java.lang.reflect.Modifier.isPublic(modifiers))
+                modSet.add(Modifier.PUBLIC);
+
+            if (java.lang.reflect.Modifier.isStatic(modifiers))
+                modSet.add(Modifier.STATIC);
+
+            if (java.lang.reflect.Modifier.isStrict(modifiers))
+                modSet.add(Modifier.STRICTFP);
+
+            if (java.lang.reflect.Modifier.isSynchronized(modifiers))
+                modSet.add(Modifier.SYNCHRONIZED);
+
+            if (java.lang.reflect.Modifier.isTransient(modifiers))
+                modSet.add(Modifier.TRANSIENT);
+
+            if (java.lang.reflect.Modifier.isVolatile(modifiers))
+                modSet.add(Modifier.VOLATILE);
+
+            if (isDefault)
+                modSet.add(Modifier.DEFAULT);
+
+            return Collections.unmodifiableSet(modSet);
+        }
+    }
+
+    private abstract static class AbstractTypeMirror implements TypeMirror {
+        private final TypeKind kind;
+
+        protected AbstractTypeMirror(TypeKind kind) {
+            this.kind = Objects.requireNonNull(kind);
+        }
+
+        @Override
+        public TypeKind getKind() {
+            return kind;
+        }
+
+        @Override
+        public <R,P> R accept(TypeVisitor<R,P> v, P p) {
+            return v.visit(this, p);
+        }
+
+        //Types methods
+        abstract List<? extends TypeMirror> directSuperTypes();
+
+        TypeMirror capture() {
+            // Exercise for the reader: make this abstract and implement in subtypes
+            throw new UnsupportedOperationException();
+        }
+
+        TypeMirror erasure() {
+            // Exercise for the reader: make this abstract and implement in subtypes
+            throw new UnsupportedOperationException();
+        }
+
+        // Exercise for the reader: implement the AnnotatedConstruct methods
+        @Override
+        public List<? extends AnnotationMirror> getAnnotationMirrors() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    private static class CoreReflArrayType extends AbstractTypeMirror
+        implements javax.lang.model.type.ArrayType,
+                   Reifiable {
+        private Class<?> source = null;
+        private Class<?> component = null;
+        private TypeMirror eagerComponent = null;
+
+        protected CoreReflArrayType(Class<?> source) {
+            super(TypeKind.ARRAY);
+            this.source = source;
+            this.component = source.getComponentType();
+            this.eagerComponent = TypeFactory.instance(component);
+        }
+
+        public TypeMirror getComponentType() {
+            return eagerComponent;
+        }
+
+        @Override
+        public Class<?> getSource() {
+            return source;
+        }
+
+        @Override
+        List<? extends TypeMirror> directSuperTypes() {
+            final TypeMirror componentType = getComponentType();
+            final TypeMirror[] directSupers;
+
+            // JLS v4 4.10.3
+            if (componentType.getKind().isPrimitive() ||
+                component.equals(java.lang.Object.class)) {
+                directSupers = new TypeMirror[3];
+                directSupers[0] = TypeFactory.instance(java.lang.Object.class);
+                directSupers[1] = TypeFactory.instance(java.lang.Cloneable.class);
+                directSupers[2] = TypeFactory.instance(java.io.Serializable.class);
+            } else if (componentType.getKind() == TypeKind.ARRAY) {
+                List<? extends TypeMirror> componentDirectSupertypes = CoreReflTypes.instance().directSupertypes(componentType);
+                directSupers = new TypeMirror[componentDirectSupertypes.size()];
+                for (int i = 0; i < directSupers.length; i++) {
+                    directSupers[i] = new CoreReflArrayType(Array.newInstance(((Reifiable)componentDirectSupertypes.get(i)).getSource(), 0).getClass());
+                }
+            } else {
+                Class<?> superClass = component.getSuperclass();
+                Class<?>[] interfaces = component.getInterfaces();
+                directSupers = new TypeMirror[1 + interfaces.length];
+
+                directSupers[0] = TypeFactory.instance(Array.newInstance(superClass, 0).getClass());
+
+                for (int i = 0; i < interfaces.length; i++) {
+                    directSupers[i + 1] = TypeFactory.instance(Array.newInstance(interfaces[i],0).getClass());
+                }
+            }
+
+            return Collections.unmodifiableList(Arrays.asList(directSupers));
+        }
+
+        @Override
+        public String toString() {
+            return getKind() + " of " + getComponentType().toString();
+        }
+    }
+
+    private static class CaptureTypeVariable extends AbstractTypeMirror implements javax.lang.model.type.TypeVariable {
+        private TypeMirror source = null;
+        private TypeMirror upperBound = null;
+        private TypeMirror lowerBound = null;
+
+        CaptureTypeVariable(TypeMirror source,
+                            TypeMirror upperBound,
+                            TypeMirror lowerBound) {
+            super(TypeKind.TYPEVAR);
+
+            this.source = Objects.requireNonNull(source);
+            this.upperBound = (upperBound == null ? CoreReflTypes.instance().getNullType() : upperBound);
+            this.lowerBound = (lowerBound == null ? CoreReflTypes.instance().getNullType() : lowerBound);
+        }
+
+        protected Class<?> getSource() {
+            if (source instanceof CoreReflDeclaredType) {
+                return ((CoreReflDeclaredType)source).getSource();
+            } else {
+                return null;
+            }
+        }
+
+        @Override
+        public TypeMirror getUpperBound() {
+            return upperBound;
+        }
+
+        @Override
+        public TypeMirror getLowerBound() {
+            return lowerBound;
+        }
+
+        @Override
+        public Element asElement() {
+            if (null == getSource()) {
+                return null;
+            }
+            return CoreReflectionFactory.createMirror(getSource());
+        }
+
+        @Override
+        List<? extends TypeMirror> directSuperTypes() {
+            throw new UnsupportedOperationException();
+
+        }
+
+        @Override
+        public String toString() {
+            return getKind() + " CAPTURE of: " + source.toString();
+        }
+    }
+
+    private static class CoreReflElements implements ReflectionElements {
+        private CoreReflElements() {} // mostly one instance for you
+
+        private static CoreReflElements instance = new CoreReflElements();
+
+        static CoreReflElements instance() {
+            return instance;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public ReflectionPackageElement getPackageElement(CharSequence name) {
+            return createMirror(Package.getPackage(name.toString()));
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public ReflectionTypeElement getTypeElement(CharSequence name) {
+            // where name is a Canonical Name jls 6.7
+            // but this method will probably accept an equivalent FQN
+            // depending on Class.forName(String)
+
+            ReflectionTypeElement tmp = null;
+
+            // Filter out arrays
+            String n = name.toString();
+            if (n.contains("[")) return null;
+            if (n.equals("")) return null;
+
+            // The intention of this loop is to handle nested
+            // elements.  If finding the element using Class.forName
+            // fails, an attempt is made to find the element as an
+            // enclosed element by trying fo find a prefix of the name
+            // (dropping a trailing ".xyz") and looking for "xyz" as
+            // an enclosed element.
+
+            Deque<String> parts = new ArrayDeque<>();
+            boolean again;
+            do {
+                again = false;
+                try {
+                    tmp = createMirror(Class.forName(n));
+                } catch (ClassNotFoundException e) {
+                    tmp = null;
+                }
+
+                if (tmp != null) {
+                    if (parts.isEmpty()) {
+                        return tmp;
+                    }
+
+                    tmp = findInner(tmp, parts);
+                    if (tmp != null) {
+                        return tmp;
+                    }
+                }
+
+                int indx = n.lastIndexOf('.');
+                if (indx > -1) {
+                    parts.addFirst(n.substring(indx + 1));
+                    n = n.substring(0, indx);
+                    again = true;
+                }
+            } while (again);
+
+            return null;
+        }
+
+        // Recursively finds enclosed type elements named as part.top() popping part and repeating
+        private ReflectionTypeElement findInner(ReflectionTypeElement e, Deque<String> parts) {
+            if (parts.isEmpty()) {
+                return e;
+            }
+
+            String part = parts.removeFirst();
+            List<ReflectionElement> enclosed = e.getEnclosedElements();
+            for (ReflectionElement elm : enclosed) {
+                if ((elm.getKind() == ElementKind.CLASS ||
+                     elm.getKind() == ElementKind.INTERFACE ||
+                     elm.getKind() == ElementKind.ENUM ||
+                     elm.getKind() == ElementKind.ANNOTATION_TYPE)
+                    && elm.getSimpleName().toString().equals(part)) {
+                    ReflectionTypeElement t = findInner((ReflectionTypeElement)elm, parts);
+                    if (t != null) {
+                        return t;
+                    }
+                }
+            }
+            return null;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public Map<? extends ReflectionExecutableElement, ? extends AnnotationValue>
+            getElementValuesWithDefaults(AnnotationMirror a) {
+            if (a instanceof CoreReflAnnotationMirror) {
+                return ((CoreReflAnnotationMirror)a).getElementValues();
+            } else {
+                throw new IllegalArgumentException();
+            }
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public String getDocComment(Element e) {
+            checkElement(e);
+            return null; // As per the doc
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public boolean isDeprecated(Element e) {
+            checkElement(e);
+            return ((CoreReflElement)e).getSource().isAnnotationPresent(java.lang.Deprecated.class);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public Name getBinaryName(TypeElement type) {
+            checkElement(type);
+            return StringName.instance(((CoreReflTypeElement)type)
+                                       .getSource()
+                                       .getName());
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public ReflectionPackageElement getPackageOf(Element type) {
+            checkElement(type);
+            if (type instanceof ReflectionPackageElement) {
+                return (ReflectionPackageElement)type;
+            }
+
+            Package p;
+            if (type instanceof CoreReflTypeElement) {
+                p = ((CoreReflTypeElement)type).getSource().getPackage();
+            } else {
+                CoreReflTypeElement enclosingTypeElement = (CoreReflTypeElement)getEnclosingTypeElement((ReflectionElement)type);
+                p = enclosingTypeElement.getSource().getPackage();
+            }
+
+            return createMirror(p);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public List<? extends ReflectionElement> getAllMembers(TypeElement type) {
+            checkElement(type);
+            return getAllMembers((ReflectionTypeElement)type);
+        }
+
+        // Exercise for the reader: should this method, and similar
+        // ones that specialize on the more specific argument types,
+        // be addd to the public ReflectionElements API?
+        public List<? extends ReflectionElement> getAllMembers(ReflectionTypeElement type) {
+            return type.getAllMembers();
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public List<? extends AnnotationMirror> getAllAnnotationMirrors(Element e) {
+            checkElement(e);
+            AnnotatedElement ae = CoreReflElement.class.cast(e).getSource();
+            Annotation[] annotations = ae.getAnnotations();
+            int len = annotations.length;
+
+            if (len > 0) {
+                List<AnnotationMirror> res = new ArrayList<>(len);
+                for (Annotation a : annotations) {
+                    res.add(createMirror(a));
+                }
+                return Collections.unmodifiableList(res);
+            } else {
+                List<AnnotationMirror> ret = Collections.emptyList();
+                return ret;
+            }
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public boolean hides(Element hider, Element hidden) {
+            checkElement(hider);
+            checkElement(hidden);
+
+            // Names must be equal
+            if (!hider.getSimpleName().equals(hidden.getSimpleName())) {
+                return false;
+            }
+
+            // Hides isn't reflexive
+            if (hider.equals(hidden)) {
+                return false;
+            }
+
+            // Hider and hidden needs to be field, method or type
+            // and fields hide fields, types hide types, methods hide methods
+            // IE a Field doesn't hide a Methods etc
+            ElementKind hiderKind = hider.getKind();
+            ElementKind hiddenKind = hidden.getKind();
+            if (hiderKind.isField() && !hiddenKind.isField()) {
+                return false;
+            } else if (hiderKind.isClass() &&
+                       !(hiddenKind.isClass() || hiddenKind.isInterface())) {
+                return false;
+            } else if (hiderKind.isInterface() &&
+                       !(hiddenKind.isClass() || hiddenKind.isInterface())) {
+                return false;
+            } else if (hiderKind == ElementKind.METHOD && hiddenKind != ElementKind.METHOD) {
+                return false;
+            } else if (!(hiderKind.isClass() ||
+                         hiderKind.isInterface() ||
+                         hiderKind.isField() ||
+                         hiderKind == ElementKind.METHOD)) {
+                return false;
+            }
+
+            Set<Modifier> hm = hidden.getModifiers();
+            // jls 8.4.8.2 only static methods can hide methods
+            if (hider.getKind() == ElementKind.METHOD) {
+                if (!hider.getModifiers().contains(Modifier.STATIC)) {
+                    return false; // hider not static
+                } else if (!hm.contains(Modifier.STATIC)) { // we know it's a method
+                    return false; // hidden not static
+                }
+
+                // For methods we also need to check parameter types
+                Class<?>[] h1 = ((CoreReflMethodExecutableElement)hider).getSource().getParameterTypes();
+                Class<?>[] h2 = ((CoreReflMethodExecutableElement)hidden).getSource().getParameterTypes();
+                if (h1.length != h2.length) {
+                    return false;
+                }
+                for (int i = 0; i < h1.length; i++) {
+                    if (h1[i] != h2[i]) {
+                        return false;
+                    }
+                }
+            }
+
+            // You can only hide visible elements
+            if (hm.contains(Modifier.PRIVATE)) {
+                return false; // hidden private, can't be hidden
+            } else if ((!(hm.contains(Modifier.PUBLIC) || hm.contains(Modifier.PROTECTED))) && // not private, not (public or protected) IE package private
+                       (!getPackageOf(hider).equals(getPackageOf(hidden)))) {
+                return false; // hidden package private, and different packages, IE not visible
+            }
+
+            // Ok so now hider actually hides hidden if hider is
+            // declared on a subtype of hidden.
+            //
+            // TODO: should this be a proper subtype or is that taken
+            // care of by the reflexive check in the beginning?
+            //
+            TypeMirror hiderType = getEnclosingTypeElement((ReflectionElement)hider).asType();
+            TypeMirror hiddenType = getEnclosingTypeElement((ReflectionElement)hidden).asType();
+
+            return getTypes().isSubtype(hiderType, hiddenType);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public ReflectionTypeElement getEnclosingTypeElement(ReflectionElement e) {
+            if (e.getKind() == ElementKind.PACKAGE) {
+                return null;
+            }
+
+            if(e instanceof CoreReflTypeParameterElement) {
+                ReflectionElement encElem = ((CoreReflTypeParameterElement)e).getEnclosingElement();
+                if (encElem instanceof ReflectionTypeElement) {
+                    return (ReflectionTypeElement)encElem;
+                } else  {
+                    return getEnclosingTypeElement(encElem);
+                }
+            }
+
+            Class<?> encl = null;
+            if (e instanceof CoreReflTypeElement) {
+                encl = ((CoreReflTypeElement)e).getSource().getDeclaringClass();
+            } else if (e instanceof CoreReflExecutableElement) {
+                encl = (((CoreReflExecutableElement)e).getSource()).getDeclaringClass();
+            } else if (e instanceof CoreReflFieldVariableElement) {
+                encl = ((CoreReflFieldVariableElement)e).getSource().getDeclaringClass();
+            } else if (e instanceof CoreReflParameterVariableElement) {
+                encl = ((CoreReflParameterVariableElement)e).getSource().getDeclaringExecutable().getDeclaringClass();
+            }
+
+            return encl == null ? null : createMirror(encl);
+        }
+
+        /**
+         *{@inheritDoc}
+         *
+         * Note that this implementation does not handle the situation
+         * where A overrides B and B overrides C but A does not
+         * directly override C. In this case, this implementation will
+         * erroneously return false.
+         */
+        @Override
+        public boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
+                                 TypeElement type) {
+            checkElement(overrider);
+            checkElement(overridden);
+            checkElement(type);
+
+            // TODO handle transitive overrides
+            return overridesDirect(overrider, overridden, type);
+        }
+
+        private boolean overridesDirect(ExecutableElement overrider, ExecutableElement overridden,
+                                         TypeElement type) {
+            // Should we check that at least one of the types
+            // overrider has is in fact a supertype of the TypeElement
+            // 'type' supplied?
+
+            CoreReflExecutableElement rider = (CoreReflExecutableElement)overrider;
+            CoreReflExecutableElement ridden = (CoreReflExecutableElement)overridden;
+            CoreReflTypeElement riderType = (CoreReflTypeElement)type;
+
+            // Names must match, redundant - see subsignature below
+            if (!rider.getSimpleName().equals(ridden.getSimpleName())) {
+                return false;
+            }
+
+            // Constructors don't override
+            // TODO: verify this fact
+            if (rider.getKind() == ElementKind.CONSTRUCTOR ||
+                ridden.getKind() == ElementKind.CONSTRUCTOR) {
+                return false;
+            }
+
+            // Overridden must be visible to be overridden
+            // TODO Fix transitive visibility/override
+            Set<Modifier> rm = ridden.getModifiers();
+            if (rm.contains(Modifier.PRIVATE)) {
+                return false; // overridden private, can't be overridden
+            } else if ((!(rm.contains(Modifier.PUBLIC) || rm.contains(Modifier.PROTECTED))) && // not private, not (public or protected) IE package private
+                       (!getPackageOf(rider).equals(getPackageOf(ridden)))) {
+                return false; // ridden package private, and different packages, IE not visible
+            }
+
+            // Static methods doesn't override
+            if (rm.contains(Modifier.STATIC) ||
+                rider.getModifiers().contains(Modifier.STATIC)) {
+                return false;
+            }
+
+            // Declaring class of overrider must be a subclass of declaring class of overridden
+            // except we use the parameter type as declaring class of overrider
+            if (!getTypes().isSubtype(riderType.asType(), getEnclosingTypeElement(ridden).asType())) {
+                return false;
+            }
+
+            // Now overrider overrides overridden if the signature of rider is a subsignature of ridden
+            return getTypes().isSubsignature(rider.asType(), ridden.asType());
+        }
+
+        /**
+         *{@inheritDoc}
+         */
+        @Override
+        public String getConstantExpression(Object value) {
+            return Constants.format(value);
+        }
+
+        // If CoreReflectionFactory were a proper part of the JDK, the
+        // analogous functionality in javac could be reused.
+        private static class Constants {
+            /**
+             * Returns a string representation of a constant value (given in
+             * standard wrapped representation), quoted and formatted as in
+             * Java source.
+             */
+            public static String format(Object value) {
+                if (value instanceof Byte)      return formatByte((Byte) value);
+                if (value instanceof Short)     return formatShort((Short) value);
+                if (value instanceof Long)      return formatLong((Long) value);
+                if (value instanceof Float)     return formatFloat((Float) value);
+                if (value instanceof Double)    return formatDouble((Double) value);
+                if (value instanceof Character) return formatChar((Character) value);
+                if (value instanceof String)    return formatString((String) value);
+                if (value instanceof Integer ||
+                    value instanceof Boolean)   return value.toString();
+                else
+                    throw new IllegalArgumentException("Argument is not a primitive type or a string; it " +
+                                                       ((value == null) ?
+                                                        "is a null value." :
+                                                        "has class " +
+                                                        value.getClass().getName()) + "." );
+            }
+
+            private static String formatByte(byte b) {
+                return String.format("(byte)0x%02x", b);
+            }
+
+            private static String formatShort(short s) {
+                return String.format("(short)%d", s);
+            }
+
+            private static String formatLong(long lng) {
+                return lng + "L";
+            }
+
+            private static String formatFloat(float f) {
+                if (Float.isNaN(f))
+                    return "0.0f/0.0f";
+                else if (Float.isInfinite(f))
+                    return (f < 0) ? "-1.0f/0.0f" : "1.0f/0.0f";
+                else
+                    return f + "f";
+            }
+
+            private static String formatDouble(double d) {
+                if (Double.isNaN(d))
+                    return "0.0/0.0";
+                else if (Double.isInfinite(d))
+                    return (d < 0) ? "-1.0/0.0" : "1.0/0.0";
+                else
+                    return d + "";
+            }
+
+            private static String formatChar(char c) {
+                return '\'' + quote(c) + '\'';
+            }
+
+            private static String formatString(String s) {
+                return '"' + quote(s) + '"';
+            }
+
+            /**
+             * Escapes each character in a string that has an escape sequence or
+             * is non-printable ASCII.  Leaves non-ASCII characters alone.
+             */
+            private static String quote(String s) {
+                StringBuilder buf = new StringBuilder();
+                for (int i = 0; i < s.length(); i++) {
+                    buf.append(quote(s.charAt(i)));
+                }
+                return buf.toString();
+            }
+
+            /**
+             * Escapes a character if it has an escape sequence or is
+             * non-printable ASCII.  Leaves ASCII characters alone.
+             */
+            private static String quote(char ch) {
+                switch (ch) {
+                case '\b':  return "\\b";
+                case '\f':  return "\\f";
+                case '\n':  return "\\n";
+                case '\r':  return "\\r";
+                case '\t':  return "\\t";
+                case '\'':  return "\\'";
+                case '\"':  return "\\\"";
+                case '\\':  return "\\\\";
+                default:
+                    return (isPrintableAscii(ch))
+                        ? String.valueOf(ch)
+                        : String.format("\\u%04x", (int) ch);
+                }
+            }
+
+            /**
+             * Is a character printable ASCII?
+             */
+            private static boolean isPrintableAscii(char ch) {
+                return ch >= ' ' && ch <= '~';
+            }
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void printElements(Writer w, Element... elements) {
+            ElementVisitor<?, ?> printer = getPrinter(w);
+            try {
+                for (Element e : elements) {
+                    checkElement(e);
+                    printer.visit(e);
+                }
+            } finally {
+                try {
+                    w.flush();
+                } catch (java.io.IOException e) { /* Ignore */;}
+            }
+        }
+
+        private ElementVisitor<?, ?> getPrinter(Writer w) {
+            // First try a reflective call into javac and if that
+            // fails, fallback to a very simple toString-based
+            // scanner.
+            try {
+                //reflective form of
+                // return new com.sun.tools.javac.processing.PrintingProcessor.PrintingElementVisitor(w, getElements());
+                Class<?> printProcClass =
+                    ClassLoader.getSystemClassLoader().loadClass("com.sun.tools.javac.processing.PrintingProcessor$PrintingElementVisitor");
+                Constructor<?> printProcCtor = printProcClass.getConstructor(Writer.class, Elements.class);
+                return (ElementVisitor) printProcCtor.newInstance(w, getElements());
+            } catch (ReflectiveOperationException | SecurityException e) {
+                return new ElementScanner8<Writer, Void>(w){
+                    @Override
+                    public Writer scan(Element e, Void v) {
+                        try {
+                            DEFAULT_VALUE.append(e.toString());
+                            DEFAULT_VALUE.append("\n");
+                        } catch (java.io.IOException ioe) {
+                            throw new RuntimeException(ioe);
+                        }
+                        return DEFAULT_VALUE;
+                    }
+                };
+            }
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public Name getName(CharSequence cs) {
+            return StringName.instance(cs.toString());
+        }
+
+        private void checkElement(Element e) {
+            if(!(e instanceof CoreReflElement)) {
+                throw new IllegalArgumentException();
+            }
+        }
+
+        @Override
+        public boolean isFunctionalInterface(TypeElement e) {
+            throw new UnsupportedOperationException();
+            // Update once this functionality is in core reflection
+        }
+    }
+
+    private static class CoreReflTypes implements javax.lang.model.util.Types {
+        private static Types instance = new CoreReflTypes();
+
+        public static Types instance() {
+            return instance;
+        }
+
+        // Private to suppress instantiation
+        private CoreReflTypes() {}
+
+        // Types methods
+        @Override
+        public Element asElement(TypeMirror t) {
+            checkType(t);
+            if (t instanceof javax.lang.model.type.TypeVariable) {
+                ((javax.lang.model.type.TypeVariable)t).asElement();
+            } else if (t instanceof DeclaredType) {
+                return ((DeclaredType)t).asElement();
+            }
+            return null;
+        }
+
+        @Override
+        public boolean isSameType(TypeMirror t1, TypeMirror t2) {
+            if (t1.getKind() != t2.getKind()) {
+                return false;
+            }
+
+            if (t1.getKind() == TypeKind.WILDCARD ||
+                t2.getKind() == TypeKind.WILDCARD) {
+                // Wildcards are not equal to any type
+                return false;
+            }
+
+            if (t1 instanceof CoreReflDeclaredType &&
+                t2 instanceof CoreReflDeclaredType) {
+                return ((CoreReflDeclaredType)t1).isSameType((CoreReflDeclaredType)t2);
+            } else if (t1 instanceof PrimitiveType &&
+                       t2 instanceof PrimitiveType) {
+                return t1.getKind() == t2.getKind();
+            } else if (t1 instanceof NoType &&
+                       t2 instanceof NoType) {
+                return true;
+            } else if (t1 instanceof NullType &&
+                       t2 instanceof NullType) {
+                return true;
+            } else if (t1 instanceof ArrayType &&
+                       t2 instanceof ArrayType) {
+                return isSameType(((ArrayType)t1).getComponentType(), ((ArrayType)t2).getComponentType());
+            }
+
+            return false;
+        }
+
+        @Override
+        public boolean isSubtype(TypeMirror t1, TypeMirror t2) {
+            checkType(t1);
+            checkType(t2);
+
+            if (isSameType(t1, t2)) {
+                return true;
+            } else if(t1.getKind() == TypeKind.NULL) {
+                return true;
+            }
+
+            // This depth first traversal should terminate due to the ban on circular inheritance
+            List<? extends TypeMirror> directSupertypes = directSupertypes(t1);
+            if (directSupertypes.isEmpty()) {
+                return false;
+            }
+            for (TypeMirror ti : directSupertypes) {
+                if (isSameType(ti, t2) || isSubtype(ti, t2)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        @Override
+        public boolean isAssignable(TypeMirror t1, TypeMirror t2) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public boolean contains(TypeMirror t1, TypeMirror t2) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public boolean isSubsignature(ExecutableType m1, ExecutableType m2) {
+            checkType(m1);
+            checkType(m2);
+
+            ExecutableMethodType m0 = (ExecutableMethodType)m1;
+
+            return m0.sameSignature((ExecutableMethodType)m2) || m0.sameSignature((ExecutableMethodType)erasure(m2));
+        }
+
+        @Override
+        public List<? extends TypeMirror> directSupertypes(TypeMirror t) {
+            checkType(t);
+            if (t instanceof ExecutableType ||
+                t.getKind() == TypeKind.PACKAGE) {
+                throw new IllegalArgumentException("You can't ask for direct supertypes for type: " + t);
+            }
+            return ((AbstractTypeMirror)t).directSuperTypes();
+        }
+
+        @Override
+        public TypeMirror erasure(TypeMirror t) {
+            checkType(t);
+            return ((AbstractTypeMirror)t).erasure();
+        }
+
+        @Override
+        public TypeElement boxedClass(javax.lang.model.type.PrimitiveType p) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public PrimitiveType unboxedType(TypeMirror t) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public TypeMirror capture(TypeMirror t) {
+            checkType(t);
+            return ((AbstractTypeMirror)t).capture();
+        }
+
+        @Override
+        public PrimitiveType getPrimitiveType(TypeKind kind) {
+            return PrimitiveType.instance(kind);
+        }
+
+        @Override
+        public NullType getNullType() {
+            return CoreReflNullType.getInstance();
+        }
+
+        @Override
+        public javax.lang.model.type.NoType getNoType(TypeKind kind) {
+            if (kind == TypeKind.NONE) {
+                return NoType.getNoneInstance();
+            } else if (kind == TypeKind.VOID) {
+                return NoType.getVoidInstance();
+            } else {
+                throw new IllegalArgumentException("No NoType of kind: " + kind);
+            }
+        }
+
+        @Override
+        public ArrayType getArrayType(TypeMirror componentType) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public javax.lang.model.type.WildcardType getWildcardType(TypeMirror extendsBound,
+                                                                  TypeMirror superBound) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public javax.lang.model.type.DeclaredType getDeclaredType(javax.lang.model.type.DeclaredType containing,
+                                                                  TypeElement typeElem,
+                                                                  TypeMirror... typeArgs) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public TypeMirror asMemberOf(javax.lang.model.type.DeclaredType containing, Element element) {
+            throw new UnsupportedOperationException();
+        }
+
+        private void checkType(TypeMirror t) {
+            if (!(t instanceof AbstractTypeMirror)) {
+                throw new IllegalArgumentException("This Types implementation can only operate on CoreReflectionFactory type classes");
+            }
+        }
+    }
+
+    private abstract static class CoreReflDeclaredType extends AbstractTypeMirror
+        implements javax.lang.model.type.DeclaredType {
+        private Class<?> source = null;
+
+        private CoreReflDeclaredType(Class<?> source) {
+            super(TypeKind.DECLARED);
+            this.source = source;
+        }
+
+        static DeclaredType instance(Class<?> source, Type genericSource) {
+            if (genericSource instanceof ParameterizedType) {
+                return new ParameterizedDeclaredType(source, (ParameterizedType)genericSource);
+            } else if (genericSource instanceof Class) { // This happens when a field has a raw type
+                if (!source.equals(genericSource)) {
+                    throw new IllegalArgumentException("Don't know how to handle this");
+                }
+                return instance(source);
+            }
+            throw new IllegalArgumentException("Don't know how to create a declared type from: " +
+                                               source +
+                                               " and genericSource " +
+                                               genericSource);
+        }
+
+        static DeclaredType instance(Class<?> source) {
+            return new RawDeclaredType(source);
+        }
+
+        protected Class<?> getSource() {
+            return source;
+        }
+
+        @Override
+        public Element asElement() {
+            return CoreReflectionFactory.createMirror(getSource());
+        }
+
+        abstract boolean isSameType(DeclaredType other);
+
+        @Override
+        TypeMirror capture() {
+            return new CaptureDeclaredType(this);
+        }
+
+        private static class CaptureDeclaredType extends CoreReflDeclaredType {
+            CoreReflDeclaredType cap;
+            CaptureDeclaredType(CoreReflDeclaredType t) {
+                super(t.source);
+                this.cap = t;
+            }
+
+            @Override
+            public List<? extends TypeMirror> getTypeArguments() {
+                List<? extends TypeMirror> wrapped = cap.getTypeArguments();
+                ArrayList<TypeMirror> res = new ArrayList<>(wrapped.size());
+                res.ensureCapacity(wrapped.size());
+
+                for (int i = 0; i < wrapped.size(); i++) {
+                    TypeMirror t = wrapped.get(i);
+
+                    if (t instanceof javax.lang.model.type.WildcardType) {
+                        res.add(i, convert(t));
+                    } else {
+                        res.add(i, t);
+                    }
+                }
+                return Collections.unmodifiableList(res);
+            }
+
+            private TypeMirror convert(TypeMirror t) {
+                if (!(t instanceof javax.lang.model.type.WildcardType)) {
+                    throw new IllegalArgumentException();
+                } else {
+                    javax.lang.model.type.WildcardType w = (javax.lang.model.type.WildcardType)t;
+                    return TypeFactory.typeVariableInstance(w, w.getExtendsBound(), w.getSuperBound());
+                }
+            }
+
+            @Override
+            public TypeMirror getEnclosingType() {
+                return cap.getEnclosingType();
+            }
+
+            @Override
+            List<? extends TypeMirror> directSuperTypes() {
+                return cap.directSuperTypes();
+            }
+
+            @Override
+            boolean isSameType(DeclaredType other) {
+                return other == this;
+            }
+
+            @Override
+            public String toString() {
+                return " CAPTURE of: " + cap.toString();
+            }
+        }
+
+        private static class RawDeclaredType extends CoreReflDeclaredType
+            implements Reifiable {
+            private RawDeclaredType(Class<?> source) {
+                super(source);
+            }
+
+            @Override
+            public Class<?> getSource() {
+                return super.getSource();
+            }
+
+            @Override
+            public TypeMirror getEnclosingType() {
+                Class<?> enclosing = getSource().getEnclosingClass();
+                if (null == enclosing) {
+                    return NoType.getNoneInstance();
+                } else {
+                    return TypeFactory.instance(enclosing);
+                }
+            }
+
+            @Override
+            public List<? extends TypeMirror> getTypeArguments() {
+                return Collections.emptyList();
+            }
+
+            @Override
+            List<? extends TypeMirror> directSuperTypes() {
+                if (getSource().isEnum()) {
+                    return enumSuper();
+                }
+
+                if (getSource() == java.lang.Object.class) {
+                    return Collections.emptyList();
+                }
+                List<TypeMirror> res = new ArrayList<>();
+                Type[] superInterfaces = getSource().getInterfaces();
+                if (!getSource().isInterface()) {
+                    res.add(TypeFactory.instance(getSource().getSuperclass()));
+                } else if (superInterfaces.length == 0) {
+                    // Interfaces that don't extend another interface
+                    // have java.lang.Object as a direct supertype.
+                    return Collections.unmodifiableList(Arrays.asList(TypeFactory.instance(java.lang.Object.class)));
+                }
+
+                for (Type t : superInterfaces) {
+                    res.add(TypeFactory.instance(t));
+                }
+                return Collections.unmodifiableList(res);
+            }
+
+            private List<? extends TypeMirror> enumSuper() {
+                Class<?> rawSuper = getSource().getSuperclass();
+                Type[] actualArgs = ((ParameterizedTypeImpl)getSource().getGenericSuperclass()).getActualTypeArguments();
+
+                // Reconsider this : assume the problem is making
+                // Enum<MyEnum> rather than just a raw enum.
+                return Collections.unmodifiableList(Arrays.asList(TypeFactory.instance(ParameterizedTypeImpl.make(rawSuper,
+                                                                                                                  Arrays.copyOf(actualArgs,
+                                                                                                                                actualArgs.length),
+                                                                                                                  null))));
+            }
+
+            @Override
+            boolean isSameType(DeclaredType other) {
+                if (other instanceof RawDeclaredType) {
+                    return Objects.equals(getSource(), ((RawDeclaredType)other).getSource());
+                } else {
+                    return false;
+                }
+            }
+
+            @Override
+            public String toString() {
+                return getSource().toString();
+            }
+        }
+
+        private static class ParameterizedDeclaredType extends CoreReflDeclaredType {
+            private ParameterizedType genericSource = null;
+            private ParameterizedDeclaredType(Class<?> source, ParameterizedType genericSource) {
+                super(source);
+                this.genericSource = genericSource;
+            }
+
+            @Override
+            public TypeMirror getEnclosingType() {
+                Type me = genericSource;
+                Type owner = GenericTypes.getEnclosingType(me);
+                if (owner == null) {
+                    return NoType.getNoneInstance();
+                }
+                return TypeFactory.instance(owner);
+            }
+
+            @Override
+            public List<? extends TypeMirror> getTypeArguments() {
+                Type[] typeArgs = genericSource.getActualTypeArguments();
+
+                int length = typeArgs.length;
+                if (length == 0)
+                    return Collections.emptyList();
+                else {
+                    List<TypeMirror> tmp = new ArrayList<>(length);
+                    for (Type t : typeArgs) {
+                        tmp.add(TypeFactory.instance(t));
+                    }
+                    return Collections.unmodifiableList(tmp);
+                }
+            }
+
+            @Override
+            List<? extends TypeMirror> directSuperTypes() {
+                if (getSource() == java.lang.Object.class) {
+                    return Collections.emptyList();
+                }
+
+                List<TypeMirror> res = new ArrayList<>();
+                Type[] superInterfaces = getSource().getGenericInterfaces();
+                if (!getSource().isInterface()) {
+                    // Replace actual type arguments with our type arguments
+                    res.add(TypeFactory.instance(substituteTypeArgs(getSource().getGenericSuperclass())));
+                } else if (superInterfaces.length == 0) {
+                    // Interfaces that don't extend another interface
+                    // have java.lang.Object as a direct supertype, plus
+                    // possibly the interface's raw type
+                    res.add(TypeFactory.instance(java.lang.Object.class));
+                }
+
+                for (Type t : superInterfaces) {
+                    res.add(TypeFactory.instance(substituteTypeArgs(t)));
+                }
+
+                res.add(TypeFactory.instance(getSource())); // Add raw type
+                return Collections.unmodifiableList(res);
+            }
+
+            private Type substituteTypeArgs(Type type) {
+                if (!(type instanceof ParameterizedType)) {
+                    return type;
+                }
+
+                ParameterizedType target = (ParameterizedType)type;
+                // Cast to get a Class instead of a plain type.
+                Class<?> raw = ((ParameterizedTypeImpl)target).getRawType();
+                Type[] actualArgs = genericSource.getActualTypeArguments();
+
+                return  ParameterizedTypeImpl.make(raw, Arrays.copyOf(actualArgs, actualArgs.length), null);
+            }
+
+            @Override
+            boolean isSameType(DeclaredType other) {
+                if (other instanceof ParameterizedDeclaredType) {
+                    return GenericTypes.isSameGenericType(genericSource,
+                                                          ((ParameterizedDeclaredType)other).genericSource);
+                } else {
+                    return false;
+                }
+            }
+
+            @Override
+            public String toString() {
+                return getKind().toString() + " " + genericSource.toString();
+            }
+        }
+
+        /**
+         * Implementing class for ParameterizedType interface.
+         * Derived from sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
+         */
+
+        private static class ParameterizedTypeImpl implements ParameterizedType {
+            private Type[] actualTypeArguments;
+            private Class<?>  rawType;
+            private Type   ownerType;
+
+            private ParameterizedTypeImpl(Class<?> rawType,
+                                          Type[] actualTypeArguments,
+                                          Type ownerType) {
+                this.actualTypeArguments = actualTypeArguments;
+                this.rawType             = rawType;
+                if (ownerType != null) {
+                    this.ownerType = ownerType;
+                } else {
+                    this.ownerType = rawType.getDeclaringClass();
+                }
+                validateConstructorArguments();
+            }
+
+            private void validateConstructorArguments() {
+                java.lang.reflect.TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
+                // check correct arity of actual type args
+                if (formals.length != actualTypeArguments.length){
+                    throw new MalformedParameterizedTypeException();
+                }
+            }
+
+            /**
+             * Static factory. Given a (generic) class, actual type arguments
+             * and an owner type, creates a parameterized type.
+             * This class can be instantiated with a a raw type that does not
+             * represent a generic type, provided the list of actual type
+             * arguments is empty.
+             * If the ownerType argument is null, the declaring class of the
+             * raw type is used as the owner type.
+             * <p> This method throws a MalformedParameterizedTypeException
+             * under the following circumstances:
+             * If the number of actual type arguments (i.e., the size of the
+             * array {@code typeArgs}) does not correspond to the number of
+             * formal type arguments.
+             * If any of the actual type arguments is not an instance of the
+             * bounds on the corresponding formal.
+             * @param rawType the Class representing the generic type declaration being
+             * instantiated
+             * @param actualTypeArguments - a (possibly empty) array of types
+             * representing the actual type arguments to the parameterized type
+             * @param ownerType - the enclosing type, if known.
+             * @return An instance of {@code ParameterizedType}
+             * @throws MalformedParameterizedTypeException - if the instantiation
+             * is invalid
+             */
+            public static ParameterizedTypeImpl make(Class<?> rawType,
+                                                     Type[] actualTypeArguments,
+                                                     Type ownerType) {
+                return new ParameterizedTypeImpl(rawType, actualTypeArguments,
+                                                 ownerType);
+            }
+
+
+            /**
+             * Returns an array of {@code Type} objects representing the actual type
+             * arguments to this type.
+             *
+             * <p>Note that in some cases, the returned array be empty. This can occur
+             * if this type represents a non-parameterized type nested within
+             * a parameterized type.
+             *
+             * @return an array of {@code Type} objects representing the actual type
+             *     arguments to this type
+             * @throws {@code TypeNotPresentException} if any of the
+             *     actual type arguments refers to a non-existent type declaration
+             * @throws {@code MalformedParameterizedTypeException} if any of the
+             *     actual type parameters refer to a parameterized type that cannot
+             *     be instantiated for any reason
+             * @since 1.5
+             */
+            public Type[] getActualTypeArguments() {
+                return actualTypeArguments.clone();
+            }
+
+            /**
+             * Returns the {@code Type} object representing the class or interface
+             * that declared this type.
+             *
+             * @return the {@code Type} object representing the class or interface
+             *     that declared this type
+             */
+            public Class<?> getRawType() {
+                return rawType;
+            }
+
+
+            /**
+             * Returns a {@code Type} object representing the type that this type
+             * is a member of.  For example, if this type is {@code O<T>.I<S>},
+             * return a representation of {@code O<T>}.
+             *
+             * <p>If this type is a top-level type, {@code null} is returned.
+             *
+             * @return a {@code Type} object representing the type that
+             *     this type is a member of. If this type is a top-level type,
+             *     {@code null} is returned
+             */
+            public Type getOwnerType() {
+                return ownerType;
+            }
+
+            /*
+             * From the JavaDoc for java.lang.reflect.ParameterizedType
+             * "Instances of classes that implement this interface must
+             * implement an equals() method that equates any two instances
+             * that share the same generic type declaration and have equal
+             * type parameters."
+             */
+            @Override
+            public boolean equals(Object o) {
+                if (o instanceof ParameterizedType) {
+                    // Check that information is equivalent
+                    ParameterizedType that = (ParameterizedType) o;
+
+                    if (this == that)
+                        return true;
+
+                    Type thatOwner   = that.getOwnerType();
+                    Type thatRawType = that.getRawType();
+
+                    return Objects.equals(ownerType, thatOwner) &&
+                        Objects.equals(rawType, thatRawType) &&
+                        Arrays.equals(actualTypeArguments, // avoid clone
+                                      that.getActualTypeArguments());
+                } else
+                    return false;
+            }
+
+            @Override
+            public int hashCode() {
+                return
+                    Arrays.hashCode(actualTypeArguments) ^
+                    Objects.hashCode(ownerType) ^
+                    Objects.hashCode(rawType);
+            }
+
+            public String toString() {
+                StringBuilder sb = new StringBuilder();
+
+                if (ownerType != null) {
+                    if (ownerType instanceof Class)
+                        sb.append(((Class)ownerType).getName());
+                    else
+                        sb.append(ownerType.toString());
+
+                    sb.append(".");
+
+                    if (ownerType instanceof ParameterizedTypeImpl) {
+                        // Find simple name of nested type by removing the
+                        // shared prefix with owner.
+                        sb.append(rawType.getName().replace( ((ParameterizedTypeImpl)ownerType).rawType.getName() + "$",
+                                                             ""));
+                    } else
+                        sb.append(rawType.getName());
+                } else
+                    sb.append(rawType.getName());
+
+                if (actualTypeArguments != null &&
+                    actualTypeArguments.length > 0) {
+                    sb.append("<");
+                    boolean first = true;
+                    for (Type t: actualTypeArguments) {
+                        if (!first)
+                            sb.append(", ");
+                        if (t instanceof Class)
+                            sb.append(((Class)t).getName());
+                        else
+                            sb.append(t.toString());
+                        first = false;
+                    }
+                    sb.append(">");
+                }
+
+                return sb.toString();
+            }
+        }
+
+    }
+
+    private static class ErasedMethodType extends ExecutableMethodType implements javax.lang.model.type.ExecutableType {
+        private final Method m;
+
+        ErasedMethodType(Method m) {
+            super(m);
+            this.m = Objects.requireNonNull(m);
+        }
+
+        @Override
+        public List<javax.lang.model.type.TypeVariable> getTypeVariables() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<? extends TypeMirror> getThrownTypes() {
+            Class<?>[] exceptions = m.getExceptionTypes();
+            int len = exceptions.length;
+
+            if (len > 0) {
+                List<TypeMirror> res = new ArrayList<TypeMirror>(len);
+                for (Class<?> t : exceptions) {
+                    res.add(TypeFactory.instance(t));
+                }
+                return Collections.unmodifiableList(res);
+            } else {
+                List<TypeMirror> ret = Collections.emptyList();
+                return ret;
+            }
+        }
+
+        @Override
+        public List<? extends TypeMirror> getParameterTypes() {
+            Class<?>[] params = m.getParameterTypes();
+            int len = params.length;
+
+            if (len > 0) {
+                List<TypeMirror> res = new ArrayList<TypeMirror>(len);
+                for (Class<?> t : params) {
+                    res.add(TypeFactory.instance(t));
+                }
+                return Collections.unmodifiableList(res);
+            } else {
+                List<TypeMirror> ret = Collections.emptyList();
+                return ret;
+            }
+        }
+
+        @Override
+        public TypeMirror getReturnType() {
+            return TypeFactory.instance(m.getReturnType());
+        }
+
+        @Override
+        TypeMirror erasure() {
+            return this;
+        }
+    }
+
+    private static class ErrorType extends AbstractTypeMirror implements javax.lang.model.type.ErrorType {
+        private static ErrorType errorType = new ErrorType();
+
+        public static ErrorType getErrorInstance() {
+            return errorType;
+        }
+
+        private ErrorType() {
+            super(TypeKind.ERROR);
+        }
+
+        @Override
+        public List<? extends TypeMirror> getTypeArguments() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public TypeMirror getEnclosingType() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public Element asElement() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        List<? extends TypeMirror> directSuperTypes() {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    private static class ExecutableMethodType extends AbstractTypeMirror
+        implements javax.lang.model.type.ExecutableType {
+        private final Method m;
+
+        ExecutableMethodType(Method m) {
+            super(TypeKind.EXECUTABLE);
+            this.m = Objects.requireNonNull(m);
+        }
+
+        @Override
+        public List<? extends TypeMirror> getThrownTypes() {
+            Type[] exceptions = m.getGenericExceptionTypes();
+            int len = exceptions.length;
+
+            if (len > 0) {
+                List<TypeMirror> res = new ArrayList<TypeMirror>(len);
+                for (Type t : exceptions) {
+                    res.add(TypeFactory.instance(t));
+                }
+                return Collections.unmodifiableList(res);
+            } else {
+                List<TypeMirror> ret = Collections.emptyList();
+                return ret;
+            }
+        }
+
+        @Override
+        public List<javax.lang.model.type.TypeVariable> getTypeVariables() {
+            java.lang.reflect.TypeVariable[] variables = m.getTypeParameters();
+            int len = variables.length;
+
+            if (len > 0) {
+                List<javax.lang.model.type.TypeVariable> res = new ArrayList<>(len);
+                for (java.lang.reflect.TypeVariable<?> t : variables) {
+                    res.add(TypeFactory.typeVariableInstance(t));
+                }
+                return Collections.unmodifiableList(res);
+            } else {
+                return Collections.emptyList();
+            }
+        }
+
+        @Override
+        public TypeMirror getReturnType() {
+            return TypeFactory.instance(m.getGenericReturnType());
+        }
+
+        @Override
+        public List<? extends TypeMirror> getParameterTypes() {
+            Type[] params = m.getGenericParameterTypes();
+            int len = params.length;
+
+            if (len > 0) {
+                List<TypeMirror> res = new ArrayList<TypeMirror>(len);
+                for (Type t : params) {
+                    res.add(TypeFactory.instance(t));
+                }
+                return Collections.unmodifiableList(res);
+            } else {
+                return Collections.emptyList();
+            }
+        }
+
+        @Override
+        List<? extends TypeMirror> directSuperTypes() {
+            // Spec says we don't need this
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        TypeMirror erasure() {
+            return new ErasedMethodType(m);
+        }
+
+        @Override
+        public TypeMirror getReceiverType() {
+            throw new UnsupportedOperationException();
+        }
+
+        boolean sameSignature(ExecutableMethodType other){
+            if (!m.getName().equals(other.m.getName())) {
+                return false;
+            }
+
+            List<? extends TypeMirror> thisParams = getParameterTypes();
+            List<? extends TypeMirror> otherParams = other.getParameterTypes();
+            if (thisParams.size() != otherParams.size()) {
+                return false;
+            }
+            for (int i = 0; i < thisParams.size(); i++) {
+                if (!CoreReflTypes.instance().isSameType(thisParams.get(i), otherParams.get(i))) {
+                    return false;
+                }
+            }
+            return true;
+        }
+    }
+
+    private static class GenericTypes {
+        public static boolean isSameGenericType(Type t1, Type t2) {
+            if (t1 instanceof Class) {
+                return ((Class)t1).equals(t2);
+            } else if (t1 instanceof ParameterizedType) {
+                return ((ParameterizedType)t1).equals(t2);
+            }
+            throw new UnsupportedOperationException();
+        }
+
+        public static Type getEnclosingType(Type t1) {
+            if (t1 instanceof Class) {
+                return ((Class)t1).getEnclosingClass();
+            } else if (t1 instanceof ParameterizedType) {
+                return ((ParameterizedType)t1).getOwnerType();
+            }
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    private static class IntersectionDeclaredType extends AbstractTypeMirror
+        implements javax.lang.model.type.DeclaredType {
+        private Type[] sources = null;
+
+        IntersectionDeclaredType(Type[] sources) {
+            super(TypeKind.DECLARED);
+            this.sources = Arrays.copyOf(Objects.requireNonNull(sources),
+                                         sources.length);
+        }
+
+        @Override
+        public TypeMirror getEnclosingType() {
+            return NoType.getNoneInstance();
+        }
+
+        @Override
+        public  Element asElement() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public List<? extends TypeMirror> getTypeArguments() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        List<? extends TypeMirror> directSuperTypes() {
+            int len = sources.length;
+
+            if (len > 0) {
+                List<TypeMirror> res = new ArrayList<TypeMirror>(len);
+                for (Type c : sources) {
+                    res.add(TypeFactory.instance(c));
+                }
+                return Collections.unmodifiableList(res);
+            } else {
+                return Collections.emptyList();
+            }
+        }
+    }
+
+    private static class ModelWildcardType extends AbstractTypeMirror
+        implements javax.lang.model.type.WildcardType {
+        private java.lang.reflect.WildcardType genericSource;
+
+        ModelWildcardType(java.lang.reflect.WildcardType genericSource) {
+            super(TypeKind.WILDCARD);
+            this.genericSource = Objects.requireNonNull(genericSource);
+        }
+
+        @Override
+        List<? extends TypeMirror> directSuperTypes() {
+            // TODO Add support for this operation
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public TypeMirror getExtendsBound() {
+            Type[] t = genericSource.getUpperBounds();
+
+            if (t.length == 1) {
+                if (t[0].equals(Object.class) && getSuperBound() != null) { // can't have both lower and upper explicit
+                    return null;
+                }
+                return TypeFactory.instance(t[0]);
+            }
+            throw new UnsupportedOperationException(); // TODO: intersection type?
+        }
+
+        @Override
+        public TypeMirror getSuperBound() {
+            Type[] t = genericSource.getLowerBounds();
+
+            if (t.length == 0) { // bound is null
+                return null;
+            } else if (t.length == 1) {
+                return TypeFactory.instance(t[0]);
+            }
+            throw new UnsupportedOperationException(); // TODO: intersection type?
+        }
+
+        @Override
+        public String toString() {
+            return getKind() + " " + genericSource.toString();
+        }
+    }
+
+    private static class NoType extends AbstractTypeMirror
+        implements javax.lang.model.type.NoType {
+        private static NoType noneType = new NoType(TypeKind.NONE, "none");
+        private static NoType packageType = new NoType(TypeKind.PACKAGE, "package");
+        private static NoType voidType = new NoType(TypeKind.VOID, "void");
+
+        private String str;
+
+        public static NoType getNoneInstance() {
+            return noneType;
+        }
+
+        public static NoType getPackageInstance() {
+            return packageType;
+        }
+
+        public static NoType getVoidInstance() {
+            return voidType;
+        }
+
+        private NoType(TypeKind k, String str) {
+            super(k);
+            this.str = str;
+        }
+
+        @Override
+        List<? extends TypeMirror> directSuperTypes() {
+            // TODO We don't need this for the Package instance, how about the others?
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public String toString() {
+            return str;
+        }
+    }
+
+    private static class CoreReflNullType extends AbstractTypeMirror
+        implements javax.lang.model.type.NullType {
+        private static CoreReflNullType nullType = new CoreReflNullType();
+
+        public static NullType getInstance() {
+            return nullType;
+        }
+
+        private CoreReflNullType() {
+            super(TypeKind.NULL);
+        }
+
+        @Override
+        List<? extends TypeMirror> directSuperTypes() {
+            // JLS 4.10.2 says:
+            // "The direct supertypes of the null type are all reference types other than the null type itself."
+            // TODO return null? an empty list? the error type? anyhow fix this
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    private static interface Reifiable {
+        Class<?> getSource();
+    }
+
+    private static class PrimitiveType extends AbstractTypeMirror
+        implements javax.lang.model.type.PrimitiveType,
+                   Reifiable {
+        private Class<?> source;
+
+        private static PrimitiveType booleanInstance = new PrimitiveType(TypeKind.BOOLEAN, boolean.class);
+        private static PrimitiveType byteInstance =    new PrimitiveType(TypeKind.BYTE, byte.class);
+        private static PrimitiveType charInstance =    new PrimitiveType(TypeKind.CHAR, char.class);
+        private static PrimitiveType shortInstance =   new PrimitiveType(TypeKind.SHORT, short.class);
+        private static PrimitiveType intInstance =     new PrimitiveType(TypeKind.INT, int.class);
+        private static PrimitiveType longInstance =    new PrimitiveType(TypeKind.LONG, long.class);
+        private static PrimitiveType floatInstance =   new PrimitiveType(TypeKind.FLOAT, float.class);
+        private static PrimitiveType doubleInstance =  new PrimitiveType(TypeKind.DOUBLE, double.class);
+
+        private PrimitiveType(TypeKind kind, Class<?> source) {
+            super(kind);
+            this.source = source;
+        }
+
+        @Override
+        public Class<?> getSource() {
+            return source;
+        }
+
+        static PrimitiveType instance(Class<?> c) {
+            switch(c.getName()) {
+            case "boolean":
+                return booleanInstance;
+            case "byte":
+                return byteInstance;
+            case "char":
+                return charInstance;
+            case "short":
+                return shortInstance;
+            case "int":
+                return intInstance;
+            case "long":
+                return longInstance;
+            case "float":
+                return floatInstance;
+            case "double":
+                return doubleInstance;
+            default:
+                throw new IllegalArgumentException();
+            }
+        }
+
+        static PrimitiveType instance(TypeKind k) {
+            switch(k) {
+            case BOOLEAN:
+                return booleanInstance;
+            case BYTE:
+                return byteInstance;
+            case CHAR:
+                return charInstance;
+            case SHORT:
+                return shortInstance;
+            case INT:
+                return intInstance;
+            case LONG:
+                return longInstance;
+            case FLOAT:
+                return floatInstance;
+            case DOUBLE:
+                return doubleInstance;
+            default:
+                throw new IllegalArgumentException();
+            }
+        }
+
+        @Override
+        public String toString() {
+            return source.getName();
+        }
+
+        //Types methods
+        @Override
+        List<? extends TypeMirror> directSuperTypes() {
+            switch (getKind()) {
+            case DOUBLE:
+                return Collections.emptyList();
+            case FLOAT:
+                return Arrays.asList(doubleInstance);
+            case LONG:
+                return Arrays.asList(floatInstance);
+            case INT:
+                return Arrays.asList(longInstance);
+            case CHAR:
+                return Arrays.asList(intInstance);
+            case SHORT:
+                return Arrays.asList(intInstance);
+            case BYTE:
+                return Arrays.asList(shortInstance);
+            default:
+                return Collections.emptyList();
+            }
+        }
+    }
+
+    private static class TypeFactory {
+        private TypeFactory() { }// no instances for you
+
+        public static TypeMirror instance(Class<?> c) {
+            if (c.isPrimitive()) {
+                if (c.getName().equals("void")) {
+                    return NoType.getVoidInstance();
+                } else {
+                    return PrimitiveType.instance(c);
+                }
+            } else if (c.isArray()) {
+                return new CoreReflArrayType(c);
+            } else if (c.isAnonymousClass() ||
+                       c.isLocalClass() ||
+                       c.isMemberClass() ||
+                       c.isInterface() || // covers annotations
+                       c.isEnum()) {
+                return CoreReflDeclaredType.instance(c);
+            } else { // plain old class ??
+                return CoreReflDeclaredType.instance(c);
+            }
+        }
+
+        public static TypeMirror instance(Type t) {
+            if (t instanceof Class) {
+                return instance((Class)t);
+            } else if (t instanceof ParameterizedType) {
+                ParameterizedType tmp = (ParameterizedType)t;
+                Type raw = tmp.getRawType();
+                if (!(raw instanceof Class)) {
+                    throw new IllegalArgumentException(t + " " + raw );
+                }
+                return CoreReflDeclaredType.instance((Class)raw, tmp);
+            } else if (t instanceof java.lang.reflect.WildcardType) {
+                return new ModelWildcardType((java.lang.reflect.WildcardType)t);
+            } else if (t instanceof java.lang.reflect.TypeVariable) {
+            return new CoreReflTypeVariable((java.lang.reflect.TypeVariable)t);
+            }
+            throw new IllegalArgumentException("Don't know how to make instance from: " + t.getClass());
+        }
+
+        public static TypeMirror instance(Field f) {
+            return CoreReflDeclaredType.instance(f.getType(), f.getGenericType());
+        }
+
+        public static ExecutableType instance(Method m) {
+            return new ExecutableMethodType(m);
+        }
+
+        public static javax.lang.model.type.TypeVariable typeVariableInstance(java.lang.reflect.TypeVariable<?> v) {
+            return new CoreReflTypeVariable(v);
+        }
+
+        public static javax.lang.model.type.TypeVariable typeVariableInstance(TypeMirror source,
+                                                        TypeMirror upperBound,
+                                                        TypeMirror lowerBound) {
+            return new CaptureTypeVariable(source, upperBound, lowerBound);
+        }
+    }
+
+    private static class CoreReflTypeVariable extends AbstractTypeMirror
+        implements javax.lang.model.type.TypeVariable {
+        private final java.lang.reflect.TypeVariable<?> source;
+        private boolean isCapture = false;
+
+        protected CoreReflTypeVariable(java.lang.reflect.TypeVariable<?> source) {
+            super(TypeKind.TYPEVAR);
+            Objects.requireNonNull(source);
+            this.source = source;
+        }
+
+        @Override
+        public TypeMirror getUpperBound() {
+            return new IntersectionDeclaredType(source.getBounds());
+        }
+
+        @Override
+        public TypeMirror getLowerBound() {
+            return CoreReflTypes.instance().getNullType();
+        }
+
+        @Override
+        public Element asElement() {
+            return CoreReflectionFactory.createMirror(source);
+        }
+
+        @Override
+        List<? extends TypeMirror> directSuperTypes() {
+            return ((AbstractTypeMirror)getUpperBound()).directSuperTypes();
+        }
+
+        @Override
+        public int hashCode() {
+            return source.hashCode();
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (other instanceof CoreReflTypeVariable) {
+                return this.source.equals(((CoreReflTypeVariable)other).source);
+            } else {
+                return false;
+            }
+        }
+    }
+}
--- a/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, 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
@@ -86,12 +86,12 @@
 
              // Test single @since tag:
 
-            { "<dt><span class=\"strong\">Since:</span></dt>"+NL+"  <dd>JDK 1.0</dd>",
+            { "<dt><span class=\"strong\">Since:</span></dt>"+NL+"<dd>JDK 1.0</dd>",
                                   BUGID + FS + "p1" + FS + "C1.html" },
 
             // Test multiple @author tags:
 
-            { "<dt><span class=\"strong\">Author:</span></dt>"+NL+"  <dd>Doug Kramer, Jamie, Neal</dd>",
+            { "<dt><span class=\"strong\">Author:</span></dt>"+NL+"<dd>Doug Kramer, Jamie, Neal</dd>",
                                   BUGID + FS + "p1" + FS + "C1.html" },
 
         };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/InheritDocForUserTags/DocTest.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,261 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug 8008768
+ * @summary Using {@inheritDoc} in simple tag defined via -tag fails
+ * @author Mike Duigou
+ * @run main DocTest
+ */
+
+import java.io.*;
+
+/**
+ * DocTest documentation.
+ *
+ * @apiNote DocTest API note.
+ * @implSpec DocTest implementation spec.
+ * @implNote DocTest implementation note.
+ */
+public class DocTest {
+    public static void main(String... args) throws Exception {
+        String[] javadoc_args = {
+            "-verbose",
+            "-d", "DocTest",
+            "-tag", "apiNote:optcm:<em>API Note</em>",
+            "-tag", "implSpec:optcm:<em>Implementation Requirements</em>:",
+            "-tag", "implNote:optcm:<em>Implementation Note</em>:",
+            "-package",
+            new File(System.getProperty("test.src"), "DocTest.java").getPath()
+        };
+
+        // javadoc does not report an exit code for an internal exception (!)
+        // so monitor stderr for stack dumps.
+        PrintStream prevErr = System.err;
+        ByteArrayOutputStream err_baos = new ByteArrayOutputStream();
+        PrintStream err_ps = new PrintStream(err_baos);
+        System.setErr(err_ps);
+
+        int rc;
+        try {
+            rc = com.sun.tools.javadoc.Main.execute(javadoc_args);
+        } finally {
+            err_ps.close();
+            System.setErr(prevErr);
+        }
+
+        String err = err_baos.toString();
+        System.err.println(err);
+
+        if (rc != 0)
+            throw new Exception("javadoc exited with rc=" + rc);
+
+        if (err.contains("at com.sun."))
+            throw new Exception("javadoc output contains stack trace");
+    }
+
+    /**
+     * DocTest() documentation.
+     *
+     * @apiNote DocTest() API note.
+     * @implSpec DocTest() implementation spec.
+     * @implNote DocTest() implementation note.
+     */
+    public DocTest() {
+    }
+
+    /**
+     * DocTest.testMethod() documentation.
+     *
+     * @apiNote DocTest.testMethod() API note.
+     * @implSpec DocTest.testMethod() implementation spec.
+     * @implNote DocTest.testMethod() implementation note.
+     */
+    public void testMethod() {
+    }
+}
+
+/**
+ * DocTestWithTags documentation.
+ *
+ * @apiNote DocTestWithTags API note.
+ * <pre>
+ *    DocTestWithTags API note code sample.
+ * </pre>
+ * @implSpec DocTestWithTags implementation spec.
+ * <pre>
+ *    DocTestWithTags implementation spec code sample.
+ * </pre>
+ * @implNote DocTestWithTags implementation note.
+ * <pre>
+ *    DocTestWithTags implementation note code sample.
+ * </pre>
+ */
+class DocTestWithTags {
+
+    /**
+     * DocTestWithTags() documentation.
+     *
+     * @apiNote DocTestWithTags() API note.
+     * <pre>
+     *    DocTestWithTags() API note code sample.
+     * </pre>
+     * @implSpec DocTestWithTags() implementation spec.
+     * <pre>
+     *    DocTestWithTags() implementation spec code sample.
+     * </pre>
+     * @implNote DocTest() implementation note.
+     * <pre>
+     *    DocTest() implementation note code sample.
+     * </pre>
+     */
+    public DocTestWithTags() {
+    }
+
+    /**
+     * DocTest.testMethod() documentation.
+     *
+     * @apiNote DocTestWithTags.testMethod() API note.
+     * <pre>
+     *    DocTestWithTags.testMethod() API note code sample.
+     * </pre>
+     * @implSpec DocTestWithTags.testMethod() implementation spec.
+     * <pre>
+     *    DocTestWithTags.testMethod() API implementation spec code sample.
+     * </pre>
+     * @implNote DocTest.testMethod() implementation note.
+     * <pre>
+     *    DocTest.testMethod() API implementation code sample.
+     * </pre>
+     */
+    public void testMethod() {
+    }
+}
+
+class MinimallyExtendsDocTest extends DocTest {
+}
+
+/**
+ * SimpleExtendsDocTest documentation.
+ */
+class SimpleExtendsDocTest extends DocTest {
+
+    /**
+     * SimpleExtendsDocTest() documentation.
+     */
+    public SimpleExtendsDocTest() {
+
+    }
+
+    /**
+     * SimpleExtendsDocTest.testMethod() documenation.
+     */
+    @java.lang.Override
+    public void testMethod() {
+    }
+}
+
+/**
+ * {@inheritDoc}
+ */
+class SimpleInheritDocDocTest extends DocTest {
+
+    /**
+     * {@inheritDoc}
+     */
+    public SimpleInheritDocDocTest() {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @java.lang.Override
+    public void testMethod() {
+    }
+}
+
+/**
+ * {@inheritDoc}
+ *
+ * @apiNote {@inheritDoc}
+ * @implSpec {@inheritDoc}
+ * @implNote {@inheritDoc}
+ */
+class FullInheritDocDocTest extends DocTest {
+
+    /**
+     * {@inheritDoc}
+     *
+     * @apiNote {@inheritDoc}
+     * @implSpec {@inheritDoc}
+     * @implNote {@inheritDoc}
+     */
+    public FullInheritDocDocTest() {
+
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @apiNote {@inheritDoc}
+     * @implSpec {@inheritDoc}
+     * @implNote {@inheritDoc}
+     */
+    @java.lang.Override
+    public void testMethod() {
+    }
+}
+
+/**
+ * {@inheritDoc} and FullInheritDocPlusDocTest documentation.
+ *
+ * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest API note.
+ * @implNote {@inheritDoc} and FullInheritDocPlusDocTest implementation specification.
+ * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest implementation note.
+ */
+class FullInheritDocPlusDocTest extends DocTest {
+
+    /**
+     * {@inheritDoc} and FullInheritDocPlusDocTest() documentation.
+     *
+     * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest() API note.
+     * @implNote {@inheritDoc} and FullInheritDocPlusDocTest() implementation specification.
+     * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest() implementation note.
+     */
+    public FullInheritDocPlusDocTest() {
+
+    }
+
+    /**
+     * {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() documentation.
+     *
+     * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() API note.
+     * @implNote {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() implementation specification.
+     * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() implementation note.
+     */
+    @java.lang.Override
+    public void testMethod() {
+    }
+}
+
--- a/langtools/test/com/sun/javadoc/_template/Template.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/_template/Template.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, 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
@@ -22,15 +22,13 @@
  */
 
 /*
- * test
- * @bug      0000000
- * @summary  <DESC>
- * @author   jamieh
- * @library  ../lib/
- * @ignore   This is a template for regression tests.
- * @build    JavadocTester
- * @build    <CLASS NAME>
- * @run main <CLASS NAME>
+ * @ test
+ * @ bug      <BUG-ID>
+ * @ summary  <BUG-SYNOPSIS>
+ * @ author   <AUTHOR> or delete
+ * @ library  ../lib/
+ * @ build    JavadocTester <CLASS NAME>
+ * @ run main <CLASS NAME>
  */
 
 public class Template extends JavadocTester {
--- a/langtools/test/com/sun/javadoc/_template/TemplateComplete.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/_template/TemplateComplete.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, 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
@@ -22,15 +22,13 @@
  */
 
 /*
- * test
- * @bug      0000000
- * @summary  <DESC>
- * @author   jamieh
- * @library  ../lib/
- * @ignore   This is a template for regression tests.
- * @build    JavadocTester
- * @build    <CLASS NAME>
- * @run main <CLASS NAME>
+ * @ test
+ * @ bug      <BUG-ID>
+ * @ summary  <BUG-SYNOPSIS>
+ * @ author   <AUTHOR> or delete
+ * @ library  ../lib/
+ * @ build    JavadocTester <CLASS NAME>
+ * @ run main <CLASS NAME>
  */
 
 public class TemplateComplete extends JavadocTester {
--- a/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -47,8 +47,8 @@
     private static final String[][] TEST = {
         {BUG_ID + FS + "C.html", "<div class=\"block\">" +
                  "This is just a simple constructor.</div>" + NL +
-                 "<dl><dt><span class=\"strong\">Parameters:</span></dt><dd>" +
-                 "<code>i</code> - a param.</dd></dl>"
+                 "<dl>" + NL + "<dt><span class=\"strong\">Parameters:</span></dt>" + NL +
+                 "<dd><code>i</code> - a param.</dd>" + NL +"</dl>"
         }
     };
     private static final String[][] NEGATED_TEST = NO_TEST;
--- a/langtools/test/com/sun/javadoc/testHref/TestHref.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testHref/TestHref.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -70,7 +70,7 @@
         },
         //@see test.
         {BUG_ID + FS + "pkg" + FS + "C2.html",
-            "See Also:</span></dt><dd><a href=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
+            "See Also:</span></dt>" + NL + "<dd><a href=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
         },
 
         //Header does not link to the page itself.
--- a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java	Fri May 17 10:13:34 2013 -0700
@@ -53,64 +53,64 @@
     // serialized form should have properly nested definition list tags
     // enclosing comments, tags and deprecated information.
     private static final String[][] TEST_CMNT_DEPR = {
-        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl>" +
+        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl>" + NL +
                  "<dt><span class=\"strong\">Since:</span></dt>" + NL +
-                 "  <dd>JDK1.0</dd></dl>"},
-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
-                 "  <dd>JDK1.0</dd>" + NL + "<dt><span class=\"strong\">See Also:</span></dt>" +
+                 "<dd>JDK1.0</dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL +
+                 "<dd>JDK1.0</dd>" + NL + "<dt><span class=\"strong\">See Also:</span></dt>" + NL +
                  "<dd><a href=\"../pkg1/C2.html\" title=\"class in pkg1\"><code>" +
                  "C2</code></a>, " + NL + "<a href=\"../serialized-form.html#pkg1.C1\">" +
-                 "Serialized Form</a></dd></dl>"},
-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
-                 "  <dd>1.4</dd>" + NL +
-                 "<dt><span class=\"strong\">See Also:</span></dt><dd>" +
+                 "Serialized Form</a></dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL +
+                 "<dd>1.4</dd>" + NL +
+                 "<dt><span class=\"strong\">See Also:</span></dt>" + NL + "<dd>" +
                  "<a href=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
-                 "<code>setUndecorated(boolean)</code></a></dd></dl>"},
-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Parameters:</span></dt><dd><code>title" +
-                 "</code> - the title</dd><dd><code>test</code> - boolean value" +
+                 "<code>setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>"+ NL + "<dt><span class=\"strong\">Parameters:</span></dt>" + NL + "<dd><code>title" +
+                 "</code> - the title</dd>" + NL + "<dd><code>test</code> - boolean value" +
                  "</dd>" + NL + "<dt><span class=\"strong\">Throws:</span></dt>" + NL +
                  "<dd><code>java.lang.IllegalArgumentException</code> - if the " +
                  "<code>owner</code>'s" + NL +
                  "     <code>GraphicsConfiguration</code> is not from a screen " +
-                 "device</dd>" + NL + "<dd><code>HeadlessException</code></dd></dl>"},
-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Parameters:</span></dt><dd><code>undecorated" +
+                 "device</dd>" + NL + "<dd><code>HeadlessException</code></dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Parameters:</span></dt>" + NL + "<dd><code>undecorated" +
                  "</code> - <code>true</code> if no decorations are" + NL +
                  "         to be enabled;" + NL + "         <code>false</code> " +
-                 "if decorations are to be enabled.</dd><dt><span class=\"strong\">Since:" +
-                 "</span></dt>" + NL + "  <dd>1.4</dd>" + NL +
-                 "<dt><span class=\"strong\">See Also:</span></dt><dd>" +
+                 "if decorations are to be enabled.</dd>" + NL + "<dt><span class=\"strong\">Since:" +
+                 "</span></dt>" + NL + "<dd>1.4</dd>" + NL +
+                 "<dt><span class=\"strong\">See Also:</span></dt>" + NL + "<dd>" +
                  "<a href=\"../pkg1/C1.html#readObject()\"><code>readObject()" +
-                 "</code></a></dd></dl>"},
-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Throws:</span></dt>" + NL +
-                 "<dd><code>java.io.IOException</code></dd><dt><span class=\"strong\">See Also:" +
-                 "</span></dt><dd><a href=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
-                 "<code>setUndecorated(boolean)</code></a></dd></dl>"},
-        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<dl><dt><span class=\"strong\">Parameters:" +
-                 "</span></dt><dd><code>set</code> - boolean</dd><dt><span class=\"strong\">" +
-                 "Since:</span></dt>" + NL + "  <dd>1.4</dd></dl>"},
-        {BUG_ID + FS + "serialized-form.html", "<dl><dt><span class=\"strong\">Throws:</span>" +
+                 "</code></a></dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Throws:</span></dt>" + NL +
+                 "<dd><code>java.io.IOException</code></dd>" + NL + "<dt><span class=\"strong\">See Also:" +
+                 "</span></dt>" + NL + "<dd><a href=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
+                 "<code>setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<dl>" + NL + "<dt><span class=\"strong\">Parameters:" +
+                 "</span></dt>" + NL + "<dd><code>set</code> - boolean</dd>" + NL + "<dt><span class=\"strong\">" +
+                 "Since:</span></dt>" + NL + "<dd>1.4</dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "serialized-form.html", "<dl>" + NL + "<dt><span class=\"strong\">Throws:</span>" +
                  "</dt>" + NL + "<dd><code>" +
-                 "java.io.IOException</code></dd><dt><span class=\"strong\">See Also:</span>" +
-                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
-                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
+                 "java.io.IOException</code></dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
+                 "</dt>" + NL + "<dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+                 "<code>C1.setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
                  "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
                  "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
                  "<div class=\"block\">This field indicates whether the C1 is " +
-                 "undecorated.</div>" + NL + "&nbsp;" + NL + "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
-                 "  <dd>1.4</dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
-                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
-                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
+                 "undecorated.</div>" + NL + "&nbsp;" + NL + "<dl>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL +
+                 "<dd>1.4</dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
+                 "</dt>" + NL + "<dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+                 "<code>C1.setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
                  "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
                  "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
                  "<div class=\"block\">Reads the object stream.</div>" + NL +
-                 "<dl><dt><span class=\"strong\">Throws:" +
+                 "<dl>" + NL + "<dt><span class=\"strong\">Throws:" +
                  "</span></dt>" + NL + "<dd><code><code>" +
                  "IOException</code></code></dd>" + NL +
-                 "<dd><code>java.io.IOException</code></dd></dl>"},
+                 "<dd><code>java.io.IOException</code></dd>" + NL + "</dl>"},
         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
                  "&nbsp;</div>" + NL +
                  "<div class=\"block\">The name for this class.</div>"}};
@@ -121,55 +121,55 @@
     // should display properly nested definition list tags for comments, tags
     // and deprecated information.
     private static final String[][] TEST_NODEPR = {
-        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl>" +
+        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl>" + NL +
                  "<dt><span class=\"strong\">Since:</span></dt>" + NL +
-                 "  <dd>JDK1.0</dd></dl>"},
-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Since:</span>" +
-                 "</dt>" + NL + "  <dd>JDK1.0</dd>" + NL + "<dt><span class=\"strong\">See Also:" +
-                 "</span></dt><dd><a href=\"../pkg1/C2.html\" title=\"class in pkg1\">" +
+                 "<dd>JDK1.0</dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Since:</span>" +
+                 "</dt>" + NL + "<dd>JDK1.0</dd>" + NL + "<dt><span class=\"strong\">See Also:" +
+                 "</span></dt>" + NL + "<dd><a href=\"../pkg1/C2.html\" title=\"class in pkg1\">" +
                  "<code>C2</code></a>, " + NL + "<a href=\"../serialized-form.html#pkg1.C1\">" +
-                 "Serialized Form</a></dd></dl>"},
-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Parameters:" +
-                 "</span></dt><dd><code>title</code> - the title</dd><dd><code>" +
+                 "Serialized Form</a></dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Parameters:" +
+                 "</span></dt>" + NL + "<dd><code>title</code> - the title</dd>" + NL + "<dd><code>" +
                  "test</code> - boolean value</dd>" + NL + "<dt><span class=\"strong\">Throws:" +
                  "</span></dt>" + NL + "<dd><code>java.lang.IllegalArgumentException" +
                  "</code> - if the <code>owner</code>'s" + NL + "     <code>GraphicsConfiguration" +
                  "</code> is not from a screen device</dd>" + NL + "<dd><code>" +
-                 "HeadlessException</code></dd></dl>"},
-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Parameters:" +
-                 "</span></dt><dd><code>undecorated</code> - <code>true</code>" +
+                 "HeadlessException</code></dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Parameters:" +
+                 "</span></dt>" + NL + "<dd><code>undecorated</code> - <code>true</code>" +
                  " if no decorations are" + NL + "         to be enabled;" + NL +
                  "         <code>false</code> if decorations are to be enabled." +
-                 "</dd><dt><span class=\"strong\">Since:</span></dt>" + NL + "  <dd>1.4</dd>" + NL +
-                 "<dt><span class=\"strong\">See Also:</span></dt><dd><a href=\"../pkg1/C1.html#readObject()\">" +
-                 "<code>readObject()</code></a></dd></dl>"},
-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Throws:</span>" +
-                 "</dt>" + NL + "<dd><code>java.io.IOException</code></dd><dt>" +
-                 "<span class=\"strong\">See Also:</span></dt><dd><a href=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
-                 "<code>setUndecorated(boolean)</code></a></dd></dl>"},
-        {BUG_ID + FS + "serialized-form.html", "<dl><dt><span class=\"strong\">Throws:</span>" +
+                 "</dd>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL + "<dd>1.4</dd>" + NL +
+                 "<dt><span class=\"strong\">See Also:</span></dt>" + NL + "<dd><a href=\"../pkg1/C1.html#readObject()\">" +
+                 "<code>readObject()</code></a></dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Throws:</span>" +
+                 "</dt>" + NL + "<dd><code>java.io.IOException</code></dd>" + NL + "<dt>" +
+                 "<span class=\"strong\">See Also:</span></dt>" + NL + "<dd><a href=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
+                 "<code>setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
+        {BUG_ID + FS + "serialized-form.html", "<dl>" + NL + "<dt><span class=\"strong\">Throws:</span>" +
                  "</dt>" + NL + "<dd><code>" +
-                 "java.io.IOException</code></dd><dt><span class=\"strong\">See Also:</span>" +
-                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
-                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
+                 "java.io.IOException</code></dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
+                 "</dt>" + NL + "<dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+                 "<code>C1.setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
                  "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
                  "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
                  "<div class=\"block\">This field indicates whether the C1 is " +
-                 "undecorated.</div>" + NL + "&nbsp;" + NL + "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
-                 "  <dd>1.4</dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
-                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
-                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
+                 "undecorated.</div>" + NL + "&nbsp;" + NL + "<dl>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL +
+                 "<dd>1.4</dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
+                 "</dt>" + NL + "<dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+                 "<code>C1.setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
                  "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
                  "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
                  "<div class=\"block\">Reads the object stream.</div>" + NL +
-                 "<dl><dt><span class=\"strong\">Throws:" +
+                 "<dl>" + NL + "<dt><span class=\"strong\">Throws:" +
                  "</span></dt>" + NL + "<dd><code><code>" +
                  "IOException</code></code></dd>" + NL +
-                 "<dd><code>java.io.IOException</code></dd></dl>"},
+                 "<dd><code>java.io.IOException</code></dd>" + NL + "</dl>"},
         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
                  "&nbsp;</div>" + NL + "<div class=\"block\">" +
                  "The name for this class.</div>"}};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testIndentation/TestIndentation.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug      8011288
+ * @summary  Erratic/inconsistent indentation of signatures
+ * @library  ../lib/
+ * @build    JavadocTester
+ * @run main TestIndentation
+ */
+
+public class TestIndentation extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8011288";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "p"
+    };
+
+    //Input for string search tests.
+    private static final String[][] TEST = {
+        { BUG_ID + FS + "p" + FS + "Indent.html",
+          "<pre>public&nbsp;&lt;T&gt;&nbsp;void&nbsp;m(T&nbsp;t1," },
+        { BUG_ID + FS + "p" + FS + "Indent.html",
+          NL + "                  T&nbsp;t2)" },
+        { BUG_ID + FS + "p" + FS + "Indent.html",
+          NL + "           throws java.lang.Exception" }
+    };
+    private static final String[][] NEGATED_TEST = NO_TEST;
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestIndentation tester = new TestIndentation();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testIndentation/p/Indent.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013, 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 p;
+
+public class Indent {
+    public <T> void m(T t1, T t2) throws Exception { }
+}
--- a/langtools/test/com/sun/javadoc/testJavaFX/TestJavaFX.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testJavaFX/TestJavaFX.java	Fri May 17 10:13:34 2013 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7112427
+ * @bug 7112427 8012295
  * @summary Test of the JavaFX doclet features.
  * @author jvalenta
  * @library ../lib/
@@ -38,27 +38,26 @@
     private static final String[][] TEST =
         new String[][] {
             {"./" + BUG_ID + "/C.html",
-                "<dt><span class=\"strong\">See Also:</span></dt><dd><a href=\"C.html#getRate()\"><code>getRate()</code></a>, " + NL +
+                "<dt><span class=\"strong\">See Also:</span></dt>" + NL + "<dd><a href=\"C.html#getRate()\"><code>getRate()</code></a>, " + NL +
                 "<a href=\"C.html#setRate(double)\"><code>setRate(double)</code></a></dd>"},
             {"./" + BUG_ID + "/C.html",
                 "<pre>public final&nbsp;void&nbsp;setRate(double&nbsp;value)</pre>" + NL +
                 "<div class=\"block\">Sets the value of the property rate.</div>" + NL +
-                "<dl><dt><span class=\"strong\">Property description:</span></dt>" },
+                "<dl>" + NL + "<dt><span class=\"strong\">Property description:</span></dt>" },
             {"./" + BUG_ID + "/C.html",
                 "<pre>public final&nbsp;double&nbsp;getRate()</pre>" + NL +
                 "<div class=\"block\">Gets the value of the property rate.</div>" + NL +
-                "<dl><dt><span class=\"strong\">Property description:</span></dt>" },
+                "<dl>" + NL + "<dt><span class=\"strong\">Property description:</span></dt>" },
             {"./" + BUG_ID + "/C.html",
                 "<td class=\"colLast\"><code><strong><a href=\"C.html#rateProperty\">rate</a></strong></code>" + NL +
                 "<div class=\"block\">Defines the direction/speed at which the <code>Timeline</code> is expected to"},
-            {"./" + BUG_ID + "/C.html",
-                "<sub id=\"expert\">Expert tag text</sub>"},
+
             {"./" + BUG_ID + "/C.html",
                 "<span class=\"strong\">Default value:</span>"},
             {"./" + BUG_ID + "/C.html",
-                "<P>Sets the value of the property <CODE>Property</CODE>"},
+                "<p>Sets the value of the property <code>Property</code>"},
             {"./" + BUG_ID + "/C.html",
-                "<P>Gets the value of the property <CODE>Property</CODE>"},
+                "<p>Gets the value of the property <code>Property</code>"},
             {"./" + BUG_ID + "/C.html",
                 "<span class=\"strong\">Property description:</span>"},
             {"./" + BUG_ID + "/C.html",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testLiteralCodeInPre/TestLiteralCodeInPre.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2002, 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug      8002387
+ * @summary  Improve rendered HTML formatting for {@code}
+ * @library  ../lib/
+ * @build    JavadocTester TestLiteralCodeInPre
+ * @run main TestLiteralCodeInPre
+ */
+
+public class TestLiteralCodeInPre extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8002387";
+    private static final String OUTPUT_DIR = BUG_ID;
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-Xdoclint:none", "pkg"
+    };
+
+    //Input for string search tests.
+    private static final String[][] TEST = {
+        { BUG_ID + FS + "pkg" + FS + "Test.html",
+            "no_pre()</pre>" + NL +
+            "<div class=\"block\">abc<code>def</code>ghi</div>" },
+        { BUG_ID + FS + "pkg" + FS + "Test.html",
+            "no_pre_extra_whitespace()</pre>" + NL +
+            "<div class=\"block\">abc<code>def  </code>ghi</div>" },
+        { BUG_ID + FS + "pkg" + FS + "Test.html",
+            "in_pre()</pre>" + NL +
+            "<div class=\"block\"><pre> abc<code>  def  </code>ghi</pre></div>" },
+        { BUG_ID + FS + "pkg" + FS + "Test.html",
+            "pre_after_text()</pre>" + NL +
+            "<div class=\"block\">xyz <pre> abc<code>  def  </code>ghi</pre></div>" },
+        { BUG_ID + FS + "pkg" + FS + "Test.html",
+            "after_pre()</pre>" + NL +
+            "<div class=\"block\">xyz <pre> pqr </pre> abc<code>def  </code>ghi</div>" },
+        { BUG_ID + FS + "pkg" + FS + "Test.html",
+            "back_in_pre()</pre>" + NL +
+            "<div class=\"block\">xyz <pre> pqr </pre> mno <pre> abc<code>  def  </code>ghi</pre></div>" },
+        { BUG_ID + FS + "pkg" + FS + "Test.html",
+            "typical_usage_code()</pre>" + NL +
+            "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit." + NL +
+            " Example:  <pre><code>" + NL +
+            "   line 1 &lt;T&gt; void m(T t) {" + NL +
+            "   line 2     // do something with T" + NL +
+            "   line 3 }" + NL +
+            " </code></pre>" + NL +
+            " and so it goes.</div>" },
+        { BUG_ID + FS + "pkg" + FS + "Test.html",
+            "typical_usage_literal()</pre>" + NL +
+            "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit." + NL +
+            " Example:  <pre>" + NL +
+            "   line 1 &lt;T&gt; void m(T t) {" + NL +
+            "   line 2     // do something with T" + NL +
+            "   line 3 }" + NL +
+            " </pre>" + NL +
+            " and so it goes.</div>" },
+        { BUG_ID + FS + "pkg" + FS + "Test.html",
+            "recommended_usage_literal()</pre>" + NL +
+            "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit." + NL +
+            " Example:  <pre>" + NL +
+            "   line 1 &lt;T&gt; void m(T t) {" + NL +
+            "   line 2     // do something with T" + NL +
+            "   line 3 } </pre>" + NL +
+            " and so it goes.</div>" }
+    };
+
+    private static final String[][] NEGATED_TEST = NO_TEST;
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestLiteralCodeInPre tester = new TestLiteralCodeInPre();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testLiteralCodeInPre/pkg/Test.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013, 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 pkg;
+
+/** */
+public class Test {
+    /**
+     * abc{@code def}ghi
+     */
+    public void no_pre() { }
+
+    /**
+     * abc{@code  def  }ghi
+     */
+    public void no_pre_extra_whitespace() { }
+
+    /**
+     * <pre> abc{@code  def  }ghi</pre>
+     */
+    public void in_pre() { }
+
+    /**
+     * xyz <pre> abc{@code  def  }ghi</pre>
+     */
+    public void pre_after_text() { }
+
+    /**
+     * xyz <pre> pqr </pre> abc{@code  def  }ghi
+     */
+    public void after_pre() { }
+
+    /**
+     * xyz <pre> pqr </pre> mno <pre> abc{@code  def  }ghi</pre>
+     */
+    public void back_in_pre() { }
+
+    /**
+     * Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+     * Example:  <pre>{@code
+     *   line 1 <T> void m(T t) {
+     *   line 2     // do something with T
+     *   line 3 }
+     * }</pre>
+     * and so it goes.
+     */
+    public void typical_usage_code() { }
+
+    /**
+     * Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+     * Example:  <pre>{@literal
+     *   line 1 <T> void m(T t) {
+     *   line 2     // do something with T
+     *   line 3 }
+     * }</pre>
+     * and so it goes.
+     */
+    public void typical_usage_literal() { }
+
+    /**
+     * Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+     * Example:  <pre>{@literal
+     *   line 1 <T> void m(T t) {
+     *   line 2     // do something with T
+     *   line 3 } }</pre>
+     * and so it goes.
+     */
+    public void recommended_usage_literal() { }
+
+    /**
+     * abc {@code
+     */
+    public void bad_code_no_content() { }
+
+    /**
+     * abc {@code abc
+     */
+    public void bad_code_content() { }
+}
--- a/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/BoldTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/BoldTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, 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
@@ -55,7 +55,7 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
+    public Content getTagletOutput(Tag tag, TagletWriter writer) {
         ArrayList inlineTags = new ArrayList();
         inlineTags.add(new TextTag(tag.holder(), "<b>"));
         inlineTags.addAll(Arrays.asList(tag.inlineTags()));
--- a/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/GreenTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/GreenTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, 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
@@ -57,7 +57,7 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
+    public Content getTagletOutput(Tag tag, TagletWriter writer) {
         ArrayList inlineTags = new ArrayList();
         inlineTags.add(new TextTag(tag.holder(), "<font color=\"green\">"));
         inlineTags.addAll(Arrays.asList(tag.inlineTags()));
--- a/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/UnderlineTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testNestedInlineTag/testtaglets/UnderlineTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, 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
@@ -57,7 +57,7 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
+    public Content getTagletOutput(Tag tag, TagletWriter writer) {
         ArrayList inlineTags = new ArrayList();
         inlineTags.add(new TextTag(tag.holder(), "<u>"));
         inlineTags.addAll(Arrays.asList(tag.inlineTags()));
--- a/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java	Fri May 17 10:13:34 2013 -0700
@@ -80,21 +80,21 @@
                 "Class TypeParameters&lt;E&gt;</h2>"},
             //Check class type parameters section.
             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
-                "<dt><span class=\"strong\">Type Parameters:</span></dt><dd><code>E</code> - " +
+                "<dt><span class=\"strong\">Type Parameters:</span></dt>" + NL + "<dd><code>E</code> - " +
                 "the type parameter for this class."},
             //Type parameters in @see/@link
             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
-                "<dl><dt><span class=\"strong\">See Also:</span></dt><dd>" +
+                "<dl>" + NL + "<dt><span class=\"strong\">See Also:</span></dt>" + NL + "<dd>" +
                 "<a href=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
-                "<code>TypeParameters</code></a></dd></dl>"},
+                "<code>TypeParameters</code></a></dd>" + NL + "</dl>"},
             //Method that uses class type parameter.
             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
                 "(<a href=\"../pkg/TypeParameters.html\" title=\"type " +
                     "parameter in TypeParameters\">E</a>&nbsp;param)"},
             //Method type parameter section.
             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
-                "<span class=\"strong\">Type Parameters:</span></dt><dd><code>T</code> - This is the first " +
-                    "type parameter.</dd><dd><code>V</code> - This is the second type " +
+                "<span class=\"strong\">Type Parameters:</span></dt>" + NL + "<dd><code>T</code> - This is the first " +
+                    "type parameter.</dd>" + NL + "<dd><code>V</code> - This is the second type " +
                     "parameter."},
             //Signature of method with type parameters
             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
@@ -235,8 +235,8 @@
                 "@AnnotationType</a>(<a href=\"../pkg/AnnotationType.html#optional()\">" +
                 "optional</a>=\"Parameter Annotation\",<a " +
                 "href=\"../pkg/AnnotationType.html#required()\">required</a>=1994)" + NL +
-                "                    int&nbsp;documented," + NL +
-                "                    int&nbsp;undocmented)</pre>"},
+                "                             int&nbsp;documented," + NL +
+                "                             int&nbsp;undocmented)</pre>"},
 
             //CONSTRUCTOR PARAMS
             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
@@ -245,8 +245,8 @@
                 "@AnnotationType</a>(<a href=\"../pkg/AnnotationType.html#optional()\">" +
                 "optional</a>=\"Constructor Param Annotation\",<a " +
                 "href=\"../pkg/AnnotationType.html#required()\">required</a>=1994)" + NL +
-                "                   int&nbsp;documented," + NL +
-                "                   int&nbsp;undocmented)</pre>"},
+                "                           int&nbsp;documented," + NL +
+                "                           int&nbsp;undocmented)</pre>"},
 
             //=================================
             // ANNOTATION TYPE USAGE TESTING (All Different Types).
@@ -306,7 +306,7 @@
             // Handle multiple bounds.
             //==============================================================
             {BUG_ID + FS + "pkg" + FS + "MultiTypeParameters.html",
-                "public&nbsp;&lt;T extends java.lang.Number & java.lang.Runnable&gt;&nbsp;T&nbsp;foo(T&nbsp;t)"},
+                "public&nbsp;&lt;T extends java.lang.Number &amp; java.lang.Runnable&gt;&nbsp;T&nbsp;foo(T&nbsp;t)"},
 
             //==============================================================
             // Test Class-Use Documenation for Type Parameters.
@@ -323,7 +323,7 @@
                      "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest1.html\" " +
                      "title=\"class in pkg2\">ClassUseTest1</a>&lt;T extends " +
                      "<a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo" +
-                     "</a> & <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
+                     "</a> &amp; <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
                      "Foo2</a>&gt;</strong></code>&nbsp;</td>"
             },
             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
@@ -375,7 +375,7 @@
                     "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest1.html\" " +
                      "title=\"class in pkg2\">ClassUseTest1</a>&lt;T extends " +
                      "<a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo" +
-                     "</a> & <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
+                     "</a> &amp; <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
                      "Foo2</a>&gt;</strong></code>&nbsp;</td>"
            },
            {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
@@ -443,7 +443,7 @@
                      "<td class=\"colFirst\"><code>&lt;T extends <a href=\"../" +
                      "../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest" +
                      "</a>&lt;<a href=\"../../pkg2/Foo3.html\" title=\"class in " +
-                     "pkg2\">Foo3</a>&gt;&gt;&nbsp;<br><a href=\"../../pkg2/" +
+                     "pkg2\">Foo3</a>&gt;&gt;<br><a href=\"../../pkg2/" +
                      "ParamTest.html\" title=\"class in pkg2\">ParamTest</a>" +
                      "&lt;<a href=\"../../pkg2/Foo3.html\" title=\"class in " +
                      "pkg2\">Foo3</a>&gt;</code></td>"
@@ -486,7 +486,7 @@
                      "<td class=\"colFirst\"><code>&lt;T extends <a href=\"../../" +
                      "pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</a>&lt;" +
                      "<a href=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3" +
-                     "</a>&gt;&gt;&nbsp;<br><a href=\"../../pkg2/ParamTest.html\" " +
+                     "</a>&gt;&gt;<br><a href=\"../../pkg2/ParamTest.html\" " +
                      "title=\"class in pkg2\">ParamTest</a>&lt;<a href=\"../../pkg2/" +
                      "Foo3.html\" title=\"class in pkg2\">Foo3</a>&gt;</code></td>"
             },
@@ -524,7 +524,7 @@
                      "../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
                      "ParamTest2</a>&lt;java.util.List&lt;? extends <a href=\".." +
                      "/../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</a>&gt;" +
-                     "&gt;&gt;&nbsp;<br><a href=\"../../pkg2/ParamTest2.html\" " +
+                     "&gt;&gt;<br><a href=\"../../pkg2/ParamTest2.html\" " +
                      "title=\"class in pkg2\">ParamTest2</a>&lt;java.util.List" +
                      "&lt;? extends <a href=\"../../pkg2/Foo4.html\" title=\"" +
                      "class in pkg2\">Foo4</a>&gt;&gt;</code></td>"
@@ -569,7 +569,7 @@
                      "../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
                      "ParamTest2</a>&lt;java.util.List&lt;? extends <a href=\".." +
                      "/../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</a>&gt;" +
-                     "&gt;&gt;&nbsp;<br><a href=\"../../pkg2/ParamTest2.html\" " +
+                     "&gt;&gt;<br><a href=\"../../pkg2/ParamTest2.html\" " +
                      "title=\"class in pkg2\">ParamTest2</a>&lt;java.util.List" +
                      "&lt;? extends <a href=\"../../pkg2/Foo4.html\" title=\"" +
                      "class in pkg2\">Foo4</a>&gt;&gt;</code></td>"
--- a/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -48,13 +48,13 @@
     private static final String[][] TEST = {
         //Regular param tags.
         {BUG_ID + FS + "pkg" + FS + "C.html",
-            "<span class=\"strong\">Parameters:</span></dt><dd><code>param1</code> - testing 1 2 3.</dd>" +
-                "<dd><code>param2</code> - testing 1 2 3."
+            "<span class=\"strong\">Parameters:</span></dt>" + NL + "<dd><code>param1</code> - testing 1 2 3.</dd>" +
+                NL + "<dd><code>param2</code> - testing 1 2 3."
         },
         //Param tags that don't match with any real parameters.
         {BUG_ID + FS + "pkg" + FS + "C.html",
-            "<span class=\"strong\">Parameters:</span></dt><dd><code><I>p1</I></code> - testing 1 2 3.</dd>" +
-                "<dd><code><I>p2</I></code> - testing 1 2 3."
+            "<span class=\"strong\">Parameters:</span></dt>" + NL + "<dd><code><I>p1</I></code> - testing 1 2 3.</dd>" +
+                NL + "<dd><code><I>p2</I></code> - testing 1 2 3."
         },
         //{@inherit} doc misuse does not cause doclet to throw exception.
         // Param is printed with nothing inherited.
--- a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, 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
@@ -41,29 +41,29 @@
     // Test for normal run of javadoc. The serialized-form.html should
     // display the inline comments, tags and deprecation information if any.
     private static final String[][] TEST_CMNT_DEPR = {
-        {BUG_ID + FS + "serialized-form.html", "<dl>" +
+        {BUG_ID + FS + "serialized-form.html", "<dl>" + NL +
                  "<dt><span class=\"strong\">Throws:</span></dt>" + NL + "<dd><code>" +
-                 "java.io.IOException</code></dd><dt><span class=\"strong\">See Also:</span>" +
-                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
-                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
+                 "java.io.IOException</code></dd>"+ NL + "<dt><span class=\"strong\">See Also:</span>" +
+                 "</dt>" + NL + "<dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+                 "<code>C1.setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
                  "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
                  "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
                  "<div class=\"block\">This field indicates whether the C1 " +
                  "is undecorated.</div>" + NL + "&nbsp;" + NL +
-                 "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
-                 "  <dd>1.4</dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
-                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
-                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
+                 "<dl>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL +
+                 "<dd>1.4</dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
+                 "</dt>" + NL + "<dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+                 "<code>C1.setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
                  "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
                  "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
                  "<div class=\"block\">Reads the object stream.</div>" + NL +
-                 "<dl><dt><span class=\"strong\">Throws:</span></dt>" + NL + "<dd><code><code>" +
+                 "<dl>" + NL + "<dt><span class=\"strong\">Throws:</span></dt>" + NL + "<dd><code><code>" +
                  "IOException</code></code></dd>" + NL +
-                 "<dd><code>java.io.IOException</code></dd></dl>"},
+                 "<dd><code>java.io.IOException</code></dd>" + NL + "</dl>"},
         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
                  "&nbsp;</div>" + NL + "<div class=\"block\">" +
                  "The name for this class.</div>"}};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug      8008768
+ * @summary  Using {@inheritDoc} in simple tag defined via -tag fails
+ * @library  ../lib/
+ * @build    JavadocTester TestSimpleTagInherit
+ * @run main TestSimpleTagInherit
+ */
+
+public class TestSimpleTagInherit extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8008768";
+    private static final String OUTPUT_DIR = BUG_ID;
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR,
+        "-tag", "custom:optcm:<em>Custom:</em>",
+        "p"
+    };
+
+    //Input for string search tests.
+    private static final String[][] TEST = {
+        { BUG_ID + FS + "p" + FS + "TestClass.html",
+          "<dt><span class=\"strong\"><em>Custom:</em></span></dt>" + NL +
+          "<dd>doc for BaseClass class</dd>" },
+        { BUG_ID + FS + "p" + FS + "TestClass.html",
+          "<dt><span class=\"strong\"><em>Custom:</em></span></dt>" + NL +
+          "<dd>doc for BaseClass method</dd>" }
+    };
+    private static final String[][] NEGATED_TEST = NO_TEST;
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestSimpleTagInherit tester = new TestSimpleTagInherit();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testSimpleTagInherit/p/BaseClass.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013, 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 p;
+
+/**
+ * @custom doc for BaseClass class
+ */
+public class BaseClass {
+    /**
+     * @custom doc for BaseClass method
+     */
+    public void m() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testSimpleTagInherit/p/TestClass.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013, 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 p;
+
+/**
+ * @custom {@inheritDoc}
+ */
+public class TestClass extends BaseClass {
+    /**
+     * @custom {@inheritDoc}
+     */
+    public void m() { }
+}
--- a/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -48,12 +48,12 @@
     //Input for string search tests.
     private static final String[][] TEST = {
         {BUG_ID + FS + "pkg1" + FS + "C1.html",
-            "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
-            "  <dd>JDK1.0</dd>"
+            "<dl>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL +
+            "<dd>JDK1.0</dd>"
         },
         {BUG_ID + FS + "serialized-form.html",
-            "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
-            "  <dd>1.4</dd>"
+            "<dl>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL +
+            "<dd>1.4</dd>"
         }
     };
 
--- a/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -48,7 +48,7 @@
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
+    public Content getTagletOutput(Tag tag, TagletWriter writer) {
         ArrayList inlineTags = new ArrayList();
         inlineTags.add(new TextTag(tag.holder(), "<dt><span class=\"strong\">Foo:</span></dt><dd>"));
         inlineTags.addAll(Arrays.asList(tag.inlineTags()));
--- a/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java	Fri May 17 10:13:34 2013 -0700
@@ -45,7 +45,6 @@
     private static final String[][] NEGATED_TEST = NO_TEST;
     private static final String[][] TEST = {
         // Test for type annotations on Class Extends (ClassExtends.java).
-        /* @ignore 8012173
         {BUG_ID + FS + "typeannos" + FS + "MyClass.html",
             "extends <a href=\"../typeannos/ClassExtA.html\" title=\"annotation " +
             "in typeannos\">@ClassExtA</a> <a href=\"../typeannos/ParameterizedClass.html\" " +
@@ -53,8 +52,6 @@
             "../typeannos/ClassExtB.html\" title=\"annotation in typeannos\">" +
             "@ClassExtB</a> java.lang.String&gt;"
         },
-        */
-        /* @ignore 8012173
         {BUG_ID + FS + "typeannos" + FS + "MyClass.html",
             "implements <a href=\"../typeannos/ClassExtB.html\" title=\"" +
             "annotation in typeannos\">@ClassExtB</a> java.lang.CharSequence, " +
@@ -64,8 +61,6 @@
             "<a href=\"../typeannos/ClassExtB.html\" title=\"annotation in " +
             "typeannos\">@ClassExtB</a> java.lang.String&gt;</pre>"
         },
-        */
-        /* @ignore 8012173
         {BUG_ID + FS + "typeannos" + FS + "MyInterface.html",
             "extends <a href=\"../typeannos/ClassExtA.html\" title=\"annotation " +
             "in typeannos\">@ClassExtA</a> <a href=\"../typeannos/" +
@@ -75,7 +70,6 @@
             "<a href=\"../typeannos/ClassExtB.html\" title=\"annotation in " +
             "typeannos\">@ClassExtB</a> java.lang.CharSequence</pre>"
         },
-        */
 
         // Test for type annotations on Class Parameters (ClassParameters.java).
         {BUG_ID + FS + "typeannos" + FS + "ExtendsBound.html",
@@ -83,7 +77,6 @@
             "href=\"../typeannos/ClassParamA.html\" title=\"annotation in " +
             "typeannos\">@ClassParamA</a> java.lang.String&gt;</span>"
         },
-        /* @ignore 8012173
         {BUG_ID + FS + "typeannos" + FS + "ExtendsGeneric.html",
             "<pre> class <span class=\"strong\">ExtendsGeneric&lt;K extends " +
             "<a href=\"../typeannos/ClassParamA.html\" title=\"annotation in " +
@@ -92,7 +85,6 @@
             "../typeannos/ClassParamB.html\" title=\"annotation in typeannos\">" +
             "@ClassParamB</a> java.lang.String&gt;&gt;</span>"
         },
-        */
         {BUG_ID + FS + "typeannos" + FS + "TwoBounds.html",
             "<pre> class <span class=\"strong\">TwoBounds&lt;K extends <a href=\"" +
             "../typeannos/ClassParamA.html\" title=\"annotation in typeannos\">" +
@@ -103,23 +95,22 @@
         {BUG_ID + FS + "typeannos" + FS + "Complex1.html",
             "class <span class=\"strong\">Complex1&lt;K extends <a href=\"../" +
             "typeannos/ClassParamA.html\" title=\"annotation in typeannos\">" +
-            "@ClassParamA</a> java.lang.String & java.lang.Runnable&gt;</span>"
+            "@ClassParamA</a> java.lang.String &amp; java.lang.Runnable&gt;</span>"
         },
         {BUG_ID + FS + "typeannos" + FS + "Complex2.html",
             "class <span class=\"strong\">Complex2&lt;K extends java.lang." +
-            "String & <a href=\"../typeannos/ClassParamB.html\" title=\"" +
+            "String &amp; <a href=\"../typeannos/ClassParamB.html\" title=\"" +
             "annotation in typeannos\">@ClassParamB</a> java.lang.Runnable&gt;</span>"
         },
         {BUG_ID + FS + "typeannos" + FS + "ComplexBoth.html",
             "class <span class=\"strong\">ComplexBoth&lt;K extends <a href=\"" +
             "../typeannos/ClassParamA.html\" title=\"annotation in typeannos\"" +
-            ">@ClassParamA</a> java.lang.String & <a href=\"../typeannos/" +
+            ">@ClassParamA</a> java.lang.String &amp; <a href=\"../typeannos/" +
             "ClassParamA.html\" title=\"annotation in typeannos\">@ClassParamA" +
             "</a> java.lang.Runnable&gt;</span>"
         },
 
         // Test for type annotations on fields (Fields.java).
-        /* @ignore 8012173
         {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html",
             "<pre><a href=\"../typeannos/Parameterized.html\" title=\"class in " +
             "typeannos\">Parameterized</a>&lt;<a href=\"../typeannos/FldA.html\" " +
@@ -127,7 +118,6 @@
             "href=\"../typeannos/FldB.html\" title=\"annotation in typeannos\">" +
             "@FldB</a> java.lang.String&gt; bothTypeArgs</pre>"
         },
-        */
         {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html",
             "<pre><a href=\"../typeannos/FldA.html\" title=\"annotation in " +
             "typeannos\">@FldA</a> java.lang.String <a href=\"../typeannos/" +
@@ -147,7 +137,6 @@
             "typeannos\">@FldC</a> <a href=\"../typeannos/FldB.html\" title=\"" +
             "annotation in typeannos\">@FldB</a> [] array2Deep</pre>"
         },
-        /* @ignore 8012173
         {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html",
             "<pre>public final&nbsp;<a href=\"../typeannos/Parameterized.html\" " +
             "title=\"class in typeannos\">Parameterized</a>&lt;<a href=\"../" +
@@ -160,7 +149,6 @@
             "title=\"annotation in typeannos\">@FldB</a> java.lang.String&gt; " +
             "nestedParameterized</pre>"
         },
-        */
         {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html",
             "<pre>public final&nbsp;<a href=\"../typeannos/FldA.html\" " +
             "title=\"annotation in typeannos\">@FldA</a> java.lang.String[][] " +
@@ -184,7 +172,6 @@
             "<pre><a href=\"../typeannos/MRtnA.html\" title=\"annotation in " +
             "typeannos\">@MRtnA</a> java.lang.String[][]&nbsp;array2()</pre>"
         },
-        /* @ignore 8012173
         {BUG_ID + FS + "typeannos" + FS + "MtdModifiedScoped.html",
             "<pre>public final&nbsp;<a href=\"../typeannos/MtdParameterized.html\" " +
             "title=\"class in typeannos\">MtdParameterized</a>&lt;<a href=\"../" +
@@ -197,7 +184,6 @@
             "MRtnB.html\" title=\"annotation in typeannos\">@MRtnB</a> java." +
             "lang.String&gt;&nbsp;nestedMtdParameterized()</pre>"
         },
-        */
 
         // Test for type annotations on method type parameters (MethodTypeParameters.java).
         {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html",
@@ -205,7 +191,6 @@
             "annotation in typeannos\">@MTyParamA</a> java.lang.String&gt;" +
             "&nbsp;void&nbsp;methodExtends()</pre>"
         },
-        /* @ignore 8012173
         {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html",
             "<pre>&lt;K extends <a href=\"../typeannos/MTyParamA.html\" title=\"" +
             "annotation in typeannos\">@MTyParamA</a> <a href=\"../typeannos/" +
@@ -214,13 +199,11 @@
             "title=\"annotation in typeannos\">@MTyParamB</a> java.lang.String" +
             "&gt;&gt;&nbsp;void&nbsp;nestedExtends()</pre>"
         },
-        */
         {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html",
             "<pre>public final&nbsp;&lt;K extends <a href=\"../typeannos/" +
             "MTyParamA.html\" title=\"annotation in typeannos\">@MTyParamA</a> " +
             "java.lang.String&gt;&nbsp;void&nbsp;methodExtends()</pre>"
         },
-        /* @ignore 8012173
         {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html",
             "<pre>public final&nbsp;&lt;K extends <a href=\"../typeannos/" +
             "MTyParamA.html\" title=\"annotation in typeannos\">@MTyParamA</a> " +
@@ -231,7 +214,6 @@
             "title=\"annotation in typeannos\">@MTyParamB</a> java.lang.String" +
             "&gt;&gt;&nbsp;void&nbsp;dual()</pre>"
         },
-        */
 
         // Test for type annotations on parameters (Parameters.java).
         {BUG_ID + FS + "typeannos" + FS + "Parameters.html",
@@ -240,7 +222,6 @@
             "ParaParameterized</a>&lt;java.lang.String,java.lang.String&gt;" +
             "&nbsp;a)</pre>"
         },
-        /* @ignore 8012173
         {BUG_ID + FS + "typeannos" + FS + "Parameters.html",
             "<pre>void&nbsp;nestedParaParameterized(<a href=\"../typeannos/" +
             "ParaParameterized.html\" title=\"class in typeannos\">" +
@@ -254,7 +235,6 @@
             "typeannos/ParamB.html\" title=\"annotation in typeannos\">@ParamB" +
             "</a> java.lang.String&gt;&nbsp;a)</pre>"
         },
-        */
         {BUG_ID + FS + "typeannos" + FS + "Parameters.html",
             "<pre>void&nbsp;array2Deep(<a href=\"../typeannos/ParamA.html\" " +
             "title=\"annotation in typeannos\">@ParamA</a> java.lang.String " +
@@ -266,14 +246,14 @@
         // Test for type annotations on throws (Throws.java).
         {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html",
             "<pre>void&nbsp;oneException()" + NL +
-            "            throws <a href=\"../typeannos/ThrA.html\" title=\"" +
+            "           throws <a href=\"../typeannos/ThrA.html\" title=\"" +
             "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
         },
         {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html",
             "<pre>void&nbsp;twoExceptions()" + NL +
-            "             throws <a href=\"../typeannos/ThrA.html\" title=\"" +
+            "            throws <a href=\"../typeannos/ThrA.html\" title=\"" +
             "annotation in typeannos\">@ThrA</a> java.lang.RuntimeException," + NL +
-            "                    <a href=\"../typeannos/ThrA.html\" title=\"" +
+            "                   <a href=\"../typeannos/ThrA.html\" title=\"" +
             "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
         },
         {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html",
@@ -290,16 +270,16 @@
         },
         {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html",
             "<pre>void&nbsp;oneException()" + NL +
-            "            throws <a href=\"../typeannos/ThrB.html\" title=\"" +
+            "           throws <a href=\"../typeannos/ThrB.html\" title=\"" +
             "annotation in typeannos\">@ThrB</a>(<a href=\"../typeannos/" +
             "ThrB.html#value()\">value</a>=\"m\") java.lang.Exception</pre>"
         },
         {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html",
             "<pre>void&nbsp;twoExceptions()" + NL +
-            "             throws <a href=\"../typeannos/ThrB.html\" title=\"" +
+            "            throws <a href=\"../typeannos/ThrB.html\" title=\"" +
             "annotation in typeannos\">@ThrB</a>(<a href=\"../typeannos/" +
             "ThrB.html#value()\">value</a>=\"m\") java.lang.RuntimeException," + NL +
-            "                    <a href=\"../typeannos/ThrA.html\" title=\"" +
+            "                   <a href=\"../typeannos/ThrA.html\" title=\"" +
             "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
         },
 
@@ -342,7 +322,7 @@
         {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html",
             "<pre>void&nbsp;withException(<a href=\"../typeannos/RcvrA.html\" " +
             "title=\"annotation in typeannos\">@RcvrA</a>&nbsp;" +
-            "DefaultUnmodified&nbsp;this)" + NL + "             throws java." +
+            "DefaultUnmodified&nbsp;this)" + NL + "            throws java." +
             "lang.Exception</pre>"
         },
         {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html",
@@ -356,8 +336,8 @@
             "<pre>&lt;T extends java.lang.Runnable&gt;&nbsp;void&nbsp;accept(" +
             "<a href=\"../typeannos/RcvrA.html\" title=\"annotation in " +
             "typeannos\">@RcvrA</a>&nbsp;DefaultUnmodified&nbsp;this," + NL +
-            "                                         T&nbsp;r)" + NL +
-            "      throws java.lang.Exception</pre>"
+            "                                           T&nbsp;r)" + NL +
+            "                                    throws java.lang.Exception</pre>"
         },
         {BUG_ID + FS + "typeannos" + FS + "PublicModified.html",
             "<pre>public final&nbsp;java.lang.String&nbsp;nonVoid(<a href=\"" +
@@ -368,16 +348,16 @@
             "<pre>public final&nbsp;&lt;T extends java.lang.Runnable&gt;&nbsp;" +
             "void&nbsp;accept(<a href=\"../typeannos/RcvrA.html\" title=\"" +
             "annotation in typeannos\">@RcvrA</a>&nbsp;PublicModified&nbsp;this," + NL +
-            "                                         T&nbsp;r)" + NL +
-            "                  throws java.lang.Exception</pre>"
+            "                                                        T&nbsp;r)" + NL +
+            "                                                 throws java.lang.Exception</pre>"
         },
         {BUG_ID + FS + "typeannos" + FS + "WithValue.html",
             "<pre>&lt;T extends java.lang.Runnable&gt;&nbsp;void&nbsp;accept(" +
             "<a href=\"../typeannos/RcvrB.html\" title=\"annotation in " +
             "typeannos\">@RcvrB</a>(<a href=\"../typeannos/RcvrB.html#value()\">" +
             "value</a>=\"m\")&nbsp;WithValue&nbsp;this," + NL +
-            "                                         T&nbsp;r)" + NL +
-            "      throws java.lang.Exception</pre>"
+            "                                           T&nbsp;r)" + NL +
+            "                                    throws java.lang.Exception</pre>"
         },
         {BUG_ID + FS + "typeannos" + FS + "WithFinal.html",
             "<pre>java.lang.String&nbsp;nonVoid(<a href=\"../typeannos/RcvrB." +
--- a/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -54,7 +54,7 @@
     private static final String[][] TEST1 = {
         {BUG_ID + FS + "pkg" + FS + "C.html",
             "<td class=\"colFirst\"><code>&lt;W extends java.lang.String,V extends " +
-            "java.util.List&gt;&nbsp;<br>java.lang.Object</code></td>"
+            "java.util.List&gt;<br>java.lang.Object</code></td>"
         },
         {BUG_ID + FS + "pkg" + FS + "C.html",
             "<code>&lt;T&gt;&nbsp;java.lang.Object</code>"
--- a/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java	Fri May 17 10:13:34 2013 -0700
@@ -90,7 +90,7 @@
         //Test @value tag used with custom tag.
         {BUG_ID + FS + "pkg1" + FS + "CustomTagUsage.html",
             "<dt><span class=\"strong\">Todo:</span></dt>" + NL +
-                "  <dd>the value of this constant is 55.</dd>"},
+                "<dd>the value of this constant is 55.</dd>"},
         //Test @value warning printed when used with non-constant.
         {WARNING_OUTPUT,"warning - @value tag (which references nonConstant) " +
             "can only be used in constants."
--- a/langtools/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,7 @@
 /*
  * @test
  * @bug 8006735
- * @ignore
- * @summary  Smoke test for ensuring that annotations are emited to javadoc
+ * @summary  Smoke test for ensuring that annotations are emitted to javadoc
  *
  * @author   Mahmood Ali <mali>
  * @library  ../../lib/
@@ -37,7 +36,7 @@
 public class TestSmoke extends JavadocTester {
 
     //Test information.
-    private static final String BUG_ID = "NOT_SPECIFIED_YET";
+    private static final String BUG_ID = "8006735";
 
     //Javadoc arguments.
     private static final String[] ARGS = new String[] {
@@ -52,8 +51,24 @@
         {BUG_ID + FS + "pkg" + FS + "T0x06.html", "@DA"},
         {BUG_ID + FS + "pkg" + FS + "T0x0B.html", "@DA"},
         {BUG_ID + FS + "pkg" + FS + "T0x0F.html", "@DA"},
+        /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java
         {BUG_ID + FS + "pkg" + FS + "T0x20.html", "@DA"},
+        */
+        /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java
+        {BUG_ID + FS + "pkg" + FS + "T0x20A.html", "@DTPA"},
+        */
+        /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java
+        {BUG_ID + FS + "pkg" + FS + "T0x20B.html", "@DA"},
+        */
+        /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java
         {BUG_ID + FS + "pkg" + FS + "T0x22.html", "@DA"},
+        */
+        /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java
+        {BUG_ID + FS + "pkg" + FS + "T0x22A.html", "@DTPA"},
+        */
+        /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java
+        {BUG_ID + FS + "pkg" + FS + "T0x22B.html", "@DA"},
+        */
         {BUG_ID + FS + "pkg" + FS + "T0x10.html", "@DA"},
         {BUG_ID + FS + "pkg" + FS + "T0x10A.html", "@DA"},
         {BUG_ID + FS + "pkg" + FS + "T0x12.html", "@DA"},
@@ -77,7 +92,11 @@
         {BUG_ID + FS + "pkg" + FS + "T0x0B.html", "@A"},
         {BUG_ID + FS + "pkg" + FS + "T0x0F.html", "@A"},
         {BUG_ID + FS + "pkg" + FS + "T0x20.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x20A.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x20B.html", "@A"},
         {BUG_ID + FS + "pkg" + FS + "T0x22.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x22A.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x22B.html", "@A"},
         {BUG_ID + FS + "pkg" + FS + "T0x10.html", "@A"},
         {BUG_ID + FS + "pkg" + FS + "T0x10A.html", "@A"},
         {BUG_ID + FS + "pkg" + FS + "T0x12.html", "@A"},
--- a/langtools/test/com/sun/javadoc/typeAnnotations/smoke/pkg/TargetTypes.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/com/sun/javadoc/typeAnnotations/smoke/pkg/TargetTypes.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -36,24 +36,19 @@
  * @author Yuri Gaevsky
  */
 
-@Target({TYPE_USE})
+@Target(TYPE_USE)
 @Retention(RetentionPolicy.RUNTIME)
 @interface A {}
 
-@Target({TYPE_USE})
+@Target(TYPE_USE)
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
 @interface DA {}
 
-/** wildcard bound */
-class T0x1C {
-    void m0x1C(List<? extends @A @DA String> lst) {}
-}
-
-/** wildcard bound generic/array */
-class T0x1D<T> {
-    void m0x1D(List<? extends @A @DA List<int[]>> lst) {}
-}
+@Target(TYPE_PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@interface DTPA {}
 
 /** typecast */
 class T0x00 {
@@ -76,6 +71,13 @@
     }
 }
 
+/** type test (instanceof) generic/array */
+class T0x03<T> {
+    void m0x03(T typeObj, Object obj) {
+        boolean ok = obj instanceof String @A @DA [];
+    }
+}
+
 /** object creation (new) */
 class T0x04 {
     void m0x04() {
@@ -83,80 +85,22 @@
     }
 }
 
-/** local variable */
-class T0x08 {
-    void m0x08() {
-      @A @DA String s = null;
+/** object creation (new) generic/array */
+class T0x05<T> {
+    void m0x05() {
+        new ArrayList<@A @DA T>();
     }
 }
 
-/** method parameter generic/array */
-class T0x0D {
-    void m0x0D(HashMap<@A @DA Object, List<@A @DA List<@A @DA Class>>> s1) {}
-}
-
 /** method receiver */
 class T0x06 {
     void m0x06(@A @DA T0x06 this) {}
 }
 
-/** method return type generic/array */
-class T0x0B {
-    Class<@A @DA Object> m0x0B() { return null; }
-}
-
-/** field generic/array */
-class T0x0F {
-    HashMap<@A @DA Object, @A @DA Object> c1;
-}
-
-/** method type parameter */
-class T0x20<T, U> {
-    <@A @DA T, @A @DA U> void m0x20() {}
-}
-
-/** class type parameter */
-class T0x22<@A @DA T, @A @DA U> {
-}
-
-/** class type parameter bound */
-class T0x10<T extends @A @DA Cloneable> {
-}
-
-class T0x10A<T extends @A @DA Object> {
-}
-
-/** method type parameter bound */
-class T0x12<T> {
-    <T extends @A @DA Cloneable> void m0x12() {}
-}
-
-/** class type parameter bound generic/array */
-class T0x11<T extends List<@A @DA T>> {
-}
-
-/** method type parameter bound generic/array */
-class T0x13 {
-    static <T extends Comparable<@A @DA T>> T m0x13() {
-        return null;
-    }
-}
-
-/** class extends/implements generic/array */
-class T0x15<T> extends ArrayList<@A @DA T> {
-}
-
-/** type test (instanceof) generic/array */
-class T0x03<T> {
-    void m0x03(T typeObj, Object obj) {
-        boolean ok = obj instanceof String @A @DA [];
-    }
-}
-
-/** object creation (new) generic/array */
-class T0x05<T> {
-    void m0x05() {
-        new ArrayList<@A @DA T>();
+/** local variable */
+class T0x08 {
+    void m0x08() {
+      @A @DA String s = null;
     }
 }
 
@@ -171,20 +115,55 @@
     }
 }
 
-/** type argument in constructor call generic/array */
-class T0x19 {
-    <T> T0x19() {}
+/** method return type generic/array */
+class T0x0B {
+    Class<@A @DA Object> m0x0B() { return null; }
+}
+
+/** method parameter generic/array */
+class T0x0D {
+    void m0x0D(HashMap<@A @DA Object, List<@A @DA List<@A @DA Class>>> s1) {}
+}
+
+/** field generic/array */
+class T0x0F {
+    HashMap<@A @DA Object, @A @DA Object> c1;
+}
 
-    void g() {
-       new <List<@A @DA String>> T0x19();
+/** class type parameter bound */
+class T0x10<T extends @A @DA Cloneable> {
+}
+
+class T0x10A<T extends @A @DA Object> {
+}
+
+/** class type parameter bound generic/array */
+class T0x11<T extends List<@A @DA T>> {
+}
+
+/** method type parameter bound */
+class T0x12<T> {
+    <T extends @A @DA Cloneable> void m0x12() {}
+}
+
+/** method type parameter bound generic/array */
+class T0x13 {
+    static <T extends Comparable<@A @DA T>> T m0x13() {
+        return null;
     }
 }
 
-/** type argument in method call generic/array */
-class T0x1B<T> {
-    void m0x1B() {
-        Collections.<T @A @DA []>emptyList();
-    }
+/** class extends/implements */
+class T0x14 extends @A @DA Thread implements @A @DA Serializable, @A @DA Cloneable {
+}
+
+/** class extends/implements generic/array */
+class T0x15<T> extends ArrayList<@A @DA T> {
+}
+
+/** exception type in throws */
+class T0x16 {
+    void m0x16() throws @A @DA Exception {}
 }
 
 /** type argument in constructor call */
@@ -196,6 +175,15 @@
     }
 }
 
+/** type argument in constructor call generic/array */
+class T0x19 {
+    <T> T0x19() {}
+
+    void g() {
+       new <List<@A @DA String>> T0x19();
+    }
+}
+
 /** type argument in method call */
 class T0x1A<T,U> {
     public static <T, U> T m() { return null; }
@@ -204,11 +192,43 @@
     }
 }
 
-/** class extends/implements */
-class T0x14 extends @A @DA Thread implements @A @DA Serializable, @A @DA Cloneable {
+/** type argument in method call generic/array */
+class T0x1B<T> {
+    void m0x1B() {
+        Collections.<T @A @DA []>emptyList();
+    }
+}
+
+/** wildcard bound */
+class T0x1C {
+    void m0x1C(List<? extends @A @DA String> lst) {}
+}
+
+/** wildcard bound generic/array */
+class T0x1D<T> {
+    void m0x1D(List<? extends @A @DA List<int[]>> lst) {}
 }
 
-/** exception type in throws */
-class T0x16 {
-    void m0x16() throws @A @DA Exception {}
+/** method type parameter */
+class T0x20 {
+    <@A @DA T> void m0x20() {}
+}
+
+class T0x20A {
+    <@A @DTPA T> void m0x20A() {}
+}
+
+class T0x20B {
+    <T> void m0x20B(@A @DA T p) {}
 }
+
+/** class type parameter */
+class T0x22<@A @DA T> {
+}
+
+class T0x22A<@A @DTPA T> {
+}
+
+class T0x22B<T> {
+    @A @DA T f;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/Diagnostics/compressed/T8012003a.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,24 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug     8012003
+ * @summary Method diagnostics resolution need to be simplified in some cases
+ *          test general overload resolution simplifications
+ * @compile/fail/ref=T8012003a.out -XDrawDiagnostics -Xdiags:compact T8012003a.java
+ */
+
+class T8012003a {
+    void m1(Integer i) { }
+
+    void m2(Integer i) { }
+    void m2(Integer i, Object o) { }
+
+    void m3(Integer i) { }
+    void m3(String s) { }
+
+    void test() {
+        m1("");
+        m1(false ? "" : "");
+        m2("");
+        m3('x');
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/Diagnostics/compressed/T8012003a.out	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,6 @@
+T8012003a.java:19:12: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer)
+T8012003a.java:20:20: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+T8012003a.java:21:12: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer)
+T8012003a.java:22:9: compiler.err.cant.apply.symbols: kindname.method, m3, char,{(compiler.misc.inapplicable.method: kindname.method, T8012003a, m3(java.lang.Integer), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: char, java.lang.Integer))),(compiler.misc.inapplicable.method: kindname.method, T8012003a, m3(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: char, java.lang.String)))}
+- compiler.note.compressed.diags
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/Diagnostics/compressed/T8012003b.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,37 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug     8012003
+ * @summary Method diagnostics resolution need to be simplified in some cases
+ *          test lambda-related overload resolution simplifications
+ * @compile/fail/ref=T8012003b.out -XDrawDiagnostics -Xdiags:compact T8012003b.java
+ */
+
+class T8012003b {
+
+    interface Consumer_V<X> {
+        void m(X x);
+    }
+
+    interface Consumer_NV<X> {
+        Integer m(X x);
+    }
+
+    void m1(Runnable r) { }
+    void m1(Runnable r, String s) { }
+
+    void m2(Consumer_V<Integer> ci) { }
+
+    void m3(Consumer_NV<String> ci) { }
+
+    void g(String arg) { }
+    String g2(String arg) { return arg; }
+
+    void test() {
+        m1(this::g);
+        m1(()->1);
+        m1(()->false ? "" : "");
+        m2(this::g);
+        m3(this::g2);
+        m3(this::k);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/Diagnostics/compressed/T8012003b.out	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,8 @@
+T8012003b.java:30:12: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, g, java.lang.String, compiler.misc.no.args, kindname.class, T8012003b, (compiler.misc.arg.length.mismatch)))
+T8012003b.java:31:16: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
+T8012003b.java:32:22: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.conditional.target.cant.be.void))
+T8012003b.java:33:12: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String)))
+T8012003b.java:34:12: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+T8012003b.java:35:12: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, k, , , (compiler.misc.location: kindname.class, T8012003b, null))
+- compiler.note.compressed.diags
+6 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/Diagnostics/compressed/T8012003c.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,24 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug     8012003
+ * @summary Method diagnostics resolution need to be simplified in some cases
+ *          test simplification of lambda type-checking error leading to resolution failure
+ * @compile/fail/ref=T8012003c.out -XDrawDiagnostics -Xdiags:compact T8012003c.java
+ */
+
+class T8012003c {
+
+    interface I {
+        void m(P p);
+    }
+
+    void m(I i) { }
+
+    void test() {
+        m(p->p.m());
+    }
+}
+
+class P {
+    private void m() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/Diagnostics/compressed/T8012003c.out	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,3 @@
+T8012003c.java:18:15: compiler.err.report.access: m(), private, P
+- compiler.note.compressed.diags
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/clinit/AnnoWithClinit1.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug 8013485
+ * @summary Annotations that gets a clinit can't be verified for correct elements in a second compilation unit
+ * @compile AnnoWithClinit1.java
+ */
+
+public @interface AnnoWithClinit1 {
+    Foo f = new Foo();
+
+    @AnnoWithClinit1
+    static class C {} // this is in the same CU so there wont be a
+                      // <clinit> when the this anno instance is checked
+
+    class Foo {}
+}
+
+
+@AnnoWithClinit1
+class BarAnnoClinit1 {}
+
+@interface AAnnoClinit1 {
+    Runnable r2 = new Runnable() { public void run() { }};
+    String str1();
+    String str2withdefault() default "bar";
+}
+
+@AAnnoClinit1(str1="value")
+class TestAnnoClinit1 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/clinit/AnnoWithClinitFail.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug 8013485
+ * @summary Annotations that gets a clinit can't be verified for correct elements in a second compilation unit
+ * @compile/fail/ref=AnnoWithClinitFail.out -XDrawDiagnostics AnnoWithClinitFail.java
+ */
+
+public @interface AnnoWithClinitFail {
+    Foo f = new Foo();
+
+    String foo();
+    String bar() default "bar";
+
+    @AnnoWithClinitFail
+    static class C {} // this is in the same CU so there wont be a
+                      // <clinit> when the this anno instance is checked
+
+    class Foo {}
+}
+
+@AnnoWithClinitFail
+class TestAnnoWithClinitFail { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/clinit/AnnoWithClinitFail.out	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,3 @@
+AnnoWithClinitFail.java:37:5: compiler.err.annotation.missing.default.value: AnnoWithClinitFail, foo
+AnnoWithClinitFail.java:44:1: compiler.err.annotation.missing.default.value: AnnoWithClinitFail, foo
+2 errors
--- a/langtools/test/tools/javac/annotations/typeAnnotations/attribution/Scopes.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/attribution/Scopes.java	Fri May 17 10:13:34 2013 -0700
@@ -28,11 +28,17 @@
  * @author Mahmood Ali
  * @compile Scopes.java
  */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
 class Scopes {
 
   void test(@A(VALUE) Scopes this) { }
   void test1(@A(value=VALUE) Scopes this) { }
 
   private static final int VALUE = 1;
+
+  @Target(ElementType.TYPE_USE)
   @interface A { int value(); }
 }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/classfile/ClassfileTestHelper.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/ClassfileTestHelper.java	Fri May 17 10:13:34 2013 -0700
@@ -66,12 +66,12 @@
     }
 
     ClassFile getClassFile(URL url) throws IOException, ConstantPoolException {
-            InputStream in = url.openStream();
-            try {
-                return ClassFile.read(in);
-            } finally {
-                in.close();
-            }
+        InputStream in = url.openStream();
+        try {
+            return ClassFile.read(in);
+        } finally {
+            in.close();
+        }
     }
 
     /************ Helper annotations counting methods ******************/
@@ -83,20 +83,43 @@
         test("CLASS",cf, null, null, Attribute.RuntimeInvisibleAnnotations, false);
     }
 
-    void test(ClassFile cf, Method m) {
-        test("METHOD",cf, null, m, Attribute.RuntimeVisibleTypeAnnotations, true);
-        test("METHOD",cf, null, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
-        test("METHOD",cf, null, m, Attribute.RuntimeVisibleAnnotations, true);
-        test("METHOD",cf, null, m, Attribute.RuntimeInvisibleAnnotations, false);
+    void test(ClassFile cf, Field f, Boolean local) {
+        if (!local) {
+            test("FIELD",cf, f, null, Attribute.RuntimeVisibleTypeAnnotations, true);
+            test("FIELD",cf, f, null, Attribute.RuntimeInvisibleTypeAnnotations, false);
+            test("FIELD",cf, f, null, Attribute.RuntimeVisibleAnnotations, true);
+            test("FIELD",cf, f, null, Attribute.RuntimeInvisibleAnnotations, false);
+        } else {
+            test("CODE",cf, f, null, Attribute.RuntimeVisibleTypeAnnotations, true);
+            test("CODE",cf, f, null, Attribute.RuntimeInvisibleTypeAnnotations, false);
+            test("CODE",cf, f, null, Attribute.RuntimeVisibleAnnotations, true);
+            test("CODE",cf, f, null, Attribute.RuntimeInvisibleAnnotations, false);
+        }
     }
 
     void test(ClassFile cf, Field f) {
-        test("FIELD",cf, f, null, Attribute.RuntimeVisibleTypeAnnotations, true);
-        test("FIELD",cf, f, null, Attribute.RuntimeInvisibleTypeAnnotations, false);
-        test("FIELD",cf, f, null, Attribute.RuntimeVisibleAnnotations, true);
-        test("FIELD",cf, f, null, Attribute.RuntimeInvisibleAnnotations, false);
+        test(cf, f, false);
     }
 
+    // 'local' determines whether to look for annotations in code attribute or not.
+    void test(ClassFile cf, Method m, Boolean local) {
+        if (!local) {
+            test("METHOD",cf, null, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+            test("METHOD",cf, null, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+            test("METHOD",cf, null, m, Attribute.RuntimeVisibleAnnotations, true);
+            test("METHOD",cf, null, m, Attribute.RuntimeInvisibleAnnotations, false);
+        } else  {
+            test("MCODE",cf, null, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+            test("MCODE",cf, null, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+            test("MCODE",cf, null, m, Attribute.RuntimeVisibleAnnotations, true);
+            test("MCODE",cf, null, m, Attribute.RuntimeInvisibleAnnotations, false);
+        }
+    }
+
+    // default to not looking in code attribute
+    void test(ClassFile cf, Method m ) {
+        test(cf, m, false);
+    }
 
     // Test the result of Attributes.getIndex according to expectations
     // encoded in the class/field/method name; increment annotations counts.
@@ -105,18 +128,47 @@
         String name = null;
         int index = -1;
         Attribute attr = null;
+        Code_attribute cAttr = null;
         boolean isTAattr = annName.contains("TypeAnnotations");
         try {
             switch(testtype) {
                 case "FIELD":
                     name = f.getName(cf.constant_pool);
                     index = f.attributes.getIndex(cf.constant_pool, annName);
-                    if(index!= -1) attr = f.attributes.get(index);
+                    if(index!= -1)
+                        attr = f.attributes.get(index);
+                    break;
+                case "CODE":
+                    name = f.getName(cf.constant_pool);
+                    //fetch index of and code attribute and annotations from code attribute.
+                    index = cf.attributes.getIndex(cf.constant_pool, Attribute.Code);
+                    if(index!= -1) {
+                        attr = cf.attributes.get(index);
+                        assert attr instanceof Code_attribute;
+                        cAttr = (Code_attribute)attr;
+                        index = cAttr.attributes.getIndex(cf.constant_pool, annName);
+                        if(index!= -1)
+                            attr = cAttr.attributes.get(index);
+                    }
                     break;
                 case "METHOD":
                     name = m.getName(cf.constant_pool);
                     index = m.attributes.getIndex(cf.constant_pool, annName);
-                    if(index!= -1) attr = m.attributes.get(index);
+                    if(index!= -1)
+                        attr = m.attributes.get(index);
+                    break;
+                case "MCODE":
+                    name = m.getName(cf.constant_pool);
+                    //fetch index of and code attribute and annotations from code attribute.
+                    index = m.attributes.getIndex(cf.constant_pool, Attribute.Code);
+                    if(index!= -1) {
+                        attr = m.attributes.get(index);
+                        assert attr instanceof Code_attribute;
+                        cAttr = (Code_attribute)attr;
+                        index = cAttr.attributes.getIndex(cf.constant_pool, annName);
+                        if(index!= -1)
+                            attr = cAttr.attributes.get(index);
+                    }
                     break;
                 default:
                     name = cf.getName();
@@ -126,7 +178,6 @@
         } catch(ConstantPoolException cpe) { cpe.printStackTrace(); }
 
         if (index != -1) {
-            assert attr instanceof RuntimeTypeAnnotations_attribute;
             if(isTAattr) { //count RuntimeTypeAnnotations
                 RuntimeTypeAnnotations_attribute tAttr =
                         (RuntimeTypeAnnotations_attribute)attr;
--- a/langtools/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest1.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest1.java	Fri May 17 10:13:34 2013 -0700
@@ -24,7 +24,6 @@
 /*
  * @test
  * @bug 8005085 8005877 8004829 8005681 8006734 8006775
- * @ignore
  * @summary Combinations of Target ElementTypes on (repeated)type annotations.
  */
 
@@ -32,10 +31,25 @@
 import java.io.File;
 
 public class CombinationsTargetTest1 extends ClassfileTestHelper {
-    // Helps identify test case in event of failure.
+
+    // Test count helps identify test case in event of failure.
     int testcount = 0;
-    int src1 = 1, src2 = 2, src4 = 4,
-        src5 = 5, src6 = 6, src7 = 7;
+
+    // Base test case template descriptions
+    enum srce  {
+        src1("(repeating) type annotations at class level"),
+        src2("(repeating) type annotations on method"),
+        src3("(repeating) type annotations on wildcard, type arguments in anonymous class"),
+        src4("(repeating) type annotations on type parameters, bounds and  type arguments on class decl"),
+        src5("(repeating) type annotations on type parameters, bounds and  type arguments on method"),
+        src6("(repeating) type annotations on type parameters, bounds and  type arguments in method");
+
+        String description;
+
+        srce(String desc) {
+            this.description = this + ": " +desc;
+        }
+    }
 
     String[] ETypes={"TYPE", "FIELD", "METHOD", "PARAMETER", "CONSTRUCTOR",
                      "LOCAL_VARIABLE", "ANNOTATION_TYPE", "PACKAGE"};
@@ -52,7 +66,6 @@
         // Determines which repeat and order in source(ABMix).
         Boolean As= false, BDs=true, ABMix=false;
         int testrun=0;
-        // A repeats and/or B/D repeats, ABMix for order of As and Bs.
         Boolean [][] bRepeat = new Boolean[][]{{false,false,false},//no repeats
                                                {true,false,false}, //repeat @A
                                                {false,true,false}, //repeat @B
@@ -64,29 +77,29 @@
             for(String et : ETypes) {
                switch(et) {
                    case "METHOD":
-                       test( 8,  0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src1);
-                       test(10,  0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src2);
-                       test( 8,  0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src4);
-                       test(10,  0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src6);
-                       test( 0,  8, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, src1);
-                       test( 0, 10, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, src2);
-                       test( 0,  8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, src4);
-                       test( 0, 10, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, src6);
+                       test( 8,  0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src1);
+                       test(10,  0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src2);
+                       test( 6,  0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src3);
+                       test(10,  0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src5);
+                       test( 0,  8, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src1);
+                       test( 0, 10, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src2);
+                       test( 0,  6, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src3);
+                       test( 0, 10, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src5);
                        break;
                    case "CONSTRUCTOR":
                    case "FIELD":
-                       test( 8,  0, 4, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src1);
-                       test( 6,  0, 3, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src5);
-                       test( 9,  0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src7);
-                       test( 0,  8, 0, 4, As, BDs, ABMix, "RUNTIME", et, ++testrun, src1);
-                       test( 0,  6, 0, 3, As, BDs, ABMix, "RUNTIME", et, ++testrun, src5);
-                       test( 0,  9, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, src7);
+                       test( 8,  0, 4, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src1);
+                       test( 6,  0, 3, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src4);
+                       test( 9,  0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src6);
+                       test( 0,  8, 0, 4, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src1);
+                       test( 0,  6, 0, 3, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src4);
+                       test( 0,  9, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src6);
                        break;
                    default:/*TYPE,PARAMETER,LOCAL_VARIABLE,ANNOTATION_TYPE,PACKAGE*/
-                       test( 8,  0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src1);
-                       test( 6,  0, 3, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src5);
-                       test( 0,  8, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, src1);
-                       test( 0,  6, 0, 3, As, BDs, ABMix, "RUNTIME", et, ++testrun, src5);
+                       test( 8,  0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src1);
+                       test( 6,  0, 3, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src4);
+                       test( 0,  8, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src1);
+                       test( 0,  6, 0, 3, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src4);
                }
             }
         }
@@ -94,7 +107,7 @@
 
     public void test(int tinv, int tvis, int inv, int vis, Boolean Arepeats,
                      Boolean BDrepeats, Boolean ABmix, String rtn, String et2,
-                     Integer N, int source) throws Exception {
+                     Integer N, srce source) throws Exception {
         ++testcount;
         expected_tvisibles = tvis;
         expected_tinvisibles = tinv;
@@ -125,7 +138,8 @@
         //if sourcString() set hasInnerClass it also set innerClassname.
         if(hasInnerClass) {
             StringBuffer sb = new StringBuffer(classFile.getAbsolutePath());
-            classFile=new File(sb.insert(sb.lastIndexOf(".class"),innerClassname).toString());
+            classFile=new File(sb.insert(sb.lastIndexOf(".class"),
+                                         innerClassname).toString());
         }
         ClassFile cf = ClassFile.read(classFile);
 
@@ -152,7 +166,7 @@
     //
     String sourceString(String testname, String retentn, String annot2,
                         Boolean Arepeats, Boolean BDrepeats, Boolean ABmix,
-                        int src) {
+                        srce src) {
 
         String As = "@A", Bs = "@B", Ds = "@D";
         if(Arepeats) As = "@A @A";
@@ -201,11 +215,11 @@
 
             "@Retention("+retentn+")\n" +
             "@Target({TYPE_USE,TYPE_PARAMETER,_OTHER_})\n" +
-            "@interface DC { D[] value(); }\n\n");
+            "@interface DC { D[] value(); }\n");
 
         // Test case sources with sample generated source.
         switch(src) {
-            case 1: // repeating type annotations at class level
+            case src1: // repeating type annotations at class level
                     /*
                      * @A @B class Test1 {
                      * @A @B Test1(){}
@@ -218,21 +232,21 @@
                      * }}
                      */
                 source = new String(
-                "// (repeating) type annotations at class level. \n" +
-                "_As_ _Bs_ class " + testname + " {\n" +
-                "_As_ _Bs_ " + testname +"(){} \n" +
-                "_As_ _Bs_ Integer i1 = 0; \n" +
-                "String _As_ _Bs_ [] _As_ _Bs_ [] sa = null; \n" +
-                "// type usage in method body \n" +
-                "String test("+testname+" this, " +
-                   "String param, String ... vararg) { \n" +
-                "    Object o = new  String  [3]; \n" +
-                "    return (String) null; \n" +
-                "} \n" +
-                "} \n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
-                "\n\n";
+                    "// " + src.description + "\n" +
+                    "_As_ _Bs_ class " + testname + " {\n" +
+                    "_As_ _Bs_ " + testname +"(){} \n" +
+                    "_As_ _Bs_ Integer i1 = 0; \n" +
+                    "String _As_ _Bs_ [] _As_ _Bs_ [] sa = null; \n" +
+                    "// type usage in method body \n" +
+                    "String test("+testname+" this, " +
+                       "String param, String ... vararg) { \n" +
+                    "    Object o = new  String  [3]; \n" +
+                    "    return (String) null; \n" +
+                    "}\n" +
+                    "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                    "\n";
                 break;
-            case 2: // (repeating) type annotations on method.
+            case src2: // (repeating) type annotations on method.
                     /*
                      * class Test12 {
                      * Test12(){}
@@ -243,26 +257,26 @@
                      * }}
                      */
                 source = new String(
-                "// (repeating) type annotations on method. \n" +
-                "class " + testname + " {\n" +
-                testname +"(){} \n" +
-                "// type usage on method \n" +
-                "_As_ _Bs_ String test(_As_ _Bs_  "+testname+" this, " +
-                   "_As_ _Bs_  String param, _As_ _Bs_  String _As_ _Bs_  ... vararg) { \n" +
-                "    Object o = new String [3]; \n" +
-                "    return (String) null; \n" +
-                "} \n" +
-                "} \n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
-                "\n\n";
+                    "// " + src.description + "\n" +
+                    "class " + testname + " {\n" +
+                    testname +"(){} \n" +
+                    "// type usage on method \n" +
+                    "_As_ _Bs_ String test(_As_ _Bs_  "+testname+" this, " +
+                       "_As_ _Bs_  String param, _As_ _Bs_  String _As_ _Bs_  ... vararg) { \n" +
+                    "    Object o = new String [3]; \n" +
+                    "    return (String) null; \n" +
+                    "}\n" +
+                    "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                    "\n";
                 break;
-            case 4: //(repeating) annotations on wildcard, type arguments in anonymous class.
+            case src3: //(repeating) annotations on wildcard, type arguments in anonymous class.
                     /*
                      * class Test13<T extends Object> {
                      *     public T data = null;
                      *     T getData() { return data;}
                      *     String mtest( Test13<String> t){ return t.getData(); }
                      *     public void test() {
-                     *         mtest( new Test13<@A @B String>() {
+                     *         mtest( new Test13<String>() {
                      *                  void m1(List<@A @B ? extends @A @B  Object> lst) {}
                      *                  void m2() throws@A @B Exception { }
                      *                });
@@ -270,22 +284,23 @@
                      * }
                      */
                 source = new String( source +
-                "// (repeating) annotations on wildcard, type arguments in anonymous class. \n" +
-                "class " + testname + "<T extends Object> {\n" +
-                "    public T data = null;\n" +
-                "    T getData() { return data;}\n" +
-                "    String mtest( " + testname + "<String> t){ return t.getData(); }\n" +
-                "    public void test() {\n" +
-                "        mtest( new " + testname + "<_As_ _Bs_ String>() {\n" +
-                "                 void m1(List<_As_ _Bs_ ? extends _As_ _Bs_  Object> lst) {}\n" +
-                "                 void m2() throws_As_ _Bs_ Exception { }\n" +
-                "               });\n" +
-                "    }\n" +
-                "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) + "\n\n";
-                hasInnerClass=true;
-                innerClassname="$1";
+                    "// " + src.description + "\n" +
+                    "class " + testname + "<T extends Object> {\n" +
+                    "    public T data = null;\n" +
+                    "    T getData() { return data;}\n" +
+                    "    String mtest( " + testname + "<String> t){ return t.getData(); }\n" +
+                    "    public void test() {\n" +
+                    "        mtest( new " + testname + "<String>() {\n" +
+                    "                 void m1(List<_As_ _Bs_ ? extends _As_ _Bs_  Object> lst) {}\n" +
+                    "                 void m2() throws_As_ _Bs_ Exception { }\n" +
+                    "               });\n" +
+                    "    }\n" +
+                    "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                    "\n";
+                    hasInnerClass=true;
+                    innerClassname="$1";
             break;
-            case 5: // (repeating)annotations on type parameters, bounds and  type arguments on class decl.
+            case src4: // (repeating)annotations on type parameters, bounds and  type arguments on class decl.
                     /*
                      * @A @B @D
                      * class Test2<@A @B @C @D T extends @A @B Object> {
@@ -297,18 +312,18 @@
                      * }
                      */
                 source = new String( source +
-                "// (repeating)annotations on type parameters, bounds and  type arguments on class decl. \n" +
-                "_As_ _Bs_ _Ds_\n" +  //8004829: A and B on type parameter below.
-                "class " + testname + "<_As_ _Bs_ @C _Ds_ T extends _As_ _Bs_ Object> {\n" +
-                "    Map<List<String>, Integer> map =\n" +
-                "        new HashMap<List< String>, Integer>();\n" +
-                "    Map<List<String>,Integer> map2 = new HashMap<>();\n" +
-                "    String test(" + testname + "<T> this) { return null;}\n" +
-                "    <T> String genericMethod(T t) { return null; }\n" +
-                "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs).replace("_Ds_",Ds) +
-                "\n\n";
-            break;
-            case 6: // (repeating) annotations on type parameters, bounds and  type arguments on method.
+                    "// " + src.description + "\n" +
+                    "_As_ _Bs_ _Ds_\n" +  //8004829: A and B on type parameter below.
+                    "class " + testname + "<_As_ _Bs_ @C _Ds_ T extends _As_ _Bs_ Object> {\n" +
+                    "    Map<List<String>, Integer> map =\n" +
+                    "        new HashMap<List< String>, Integer>();\n" +
+                    "    Map<List<String>,Integer> map2 = new HashMap<>();\n" +
+                    "    String test(" + testname + "<T> this) { return null;}\n" +
+                    "    <T> String genericMethod(T t) { return null; }\n" +
+                    "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs).replace("_Ds_",Ds) +
+                    "\n";
+                break;
+            case src5: // (repeating) annotations on type parameters, bounds and  type arguments on method.
                     /*
                      * class Test14<T extends Object> {
                      *     Map<List<String>, Integer> map =
@@ -319,17 +334,17 @@
                      * }
                      */
                 source = new String( source +
-                "// (repeating) annotations on type parameters, bounds and  type arguments on method. \n" +
-                "class " + testname + "<T extends Object> {\n" +
-                "    Map<List<String>, Integer> map =\n" +
-                "        new HashMap<List<String>, Integer>();\n" +
-                "    Map<List<String>, Integer> map2 = new HashMap<>();\n" +
-                "    String test(_As_ _Bs_ " + testname + "<_Ds_ T> this) { return null;}\n" +
-                "    <@C _Ds_ T> _As_ _Bs_ String genericMethod(_As_ _Bs_ _Ds_ T t) { return null; }\n" +
-                "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs).replace("_Ds_",Ds) +
-                "\n\n";
-            break;
-            case 7: // repeating annotations on type parameters, bounds and  type arguments in method.
+                    "// " + src.description + "\n" +
+                    "class " + testname + "<T extends Object> {\n" +
+                    "    Map<List<String>, Integer> map =\n" +
+                    "        new HashMap<List<String>, Integer>();\n" +
+                    "    Map<List<String>, Integer> map2 = new HashMap<>();\n" +
+                    "    String test(_As_ _Bs_ " + testname + "<_Ds_ T> this) { return null;}\n" +
+                    "    <@C _Ds_ T> _As_ _Bs_ String genericMethod(_As_ _Bs_ _Ds_ T t) { return null; }\n" +
+                    "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs).replace("_Ds_",Ds) +
+                    "\n";
+                break;
+            case src6: // repeating annotations on type parameters, bounds and  type arguments in method.
                     /*
                      * class Test7{
                      *     <E extends Comparable> Map<List<E>, E > foo(E e) {
@@ -344,22 +359,22 @@
                      * }
                      */
                 source = new String( source +
-                "// (repeating)annotations on type parameters of class, method return value in method. \n" +
-                "class "+ testname + "{\n" +
-                "    <E extends Comparable> Map<List<E>, E > foo(E e) {\n" +
-                "        class maptest <_As_ _Bs_ _Ds_ E> {\n" +                  // inner class $1maptest
-                "            Map<List<_As_ _Bs_ _Ds_ E>,_As_ _Bs_ _Ds_ E> getMap() { \n" +
-                "                return new HashMap<List<E>,E>();\n" +
-                "            }\n" +
-                "        }\n" +
-                "        return new maptest<E>().getMap();\n" +
-                "   }\n" +
-                "   Map<List<String>,String> shm = foo(new String(\"hello\"));\n" +
-                "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs).replace("_Ds_",Ds) +
-                "\n\n";
-                hasInnerClass=true;
-                innerClassname="$1maptest";
-            break;
+                    "// " + src.description + "\n" +
+                    "class "+ testname + "{\n" +
+                    "    <E extends Comparable> Map<List<E>, E > foo(E e) {\n" +
+                    "        class maptest <_As_ _Bs_ _Ds_ E> {\n" +                  // inner class $1maptest
+                    "            Map<List<_As_ _Bs_ _Ds_ E>,_As_ _Bs_ _Ds_ E> getMap() { \n" +
+                    "                return new HashMap<List<E>,E>();\n" +
+                    "            }\n" +
+                    "        }\n" +
+                    "        return new maptest<E>().getMap();\n" +
+                    "   }\n" +
+                    "   Map<List<String>,String> shm = foo(new String(\"hello\"));\n" +
+                    "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs).replace("_Ds_",Ds) +
+                    "\n";
+                    hasInnerClass=true;
+                    innerClassname="$1maptest";
+                break;
         }
         return imports + source;
     }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java	Fri May 17 10:13:34 2013 -0700
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @bug 8005085 8005877 8004829 8005681 8006734 8006775
- * @ignore
+ * @bug 8005085 8005877 8004829 8005681 8006734 8006775 8006507
  * @summary Combinations of Target ElementTypes on (repeated)type annotations.
  */
 
@@ -32,9 +31,27 @@
 import java.io.File;
 
 public class CombinationsTargetTest2 extends ClassfileTestHelper {
-    // Helps identify test case in event of failure.
+
+    // Test count helps identify test case in event of failure.
     int testcount = 0;
-    int src3 = 3, src8 = 8, src9 = 9;
+
+    // Base test case template descriptions
+    enum srce  {
+        src1("(repeating) type annotations on on field in method body",true),
+        src2("(repeating) type annotations on type parameters, bounds and  type arguments", true),
+        src3("(repeating) type annotations on type parameters of class, method return value in method", true),
+        src4("(repeating) type annotations on field in anonymous class", false),
+        src5("(repeating) type annotations on field in anonymous class", false);
+
+        String description;
+        Boolean local;
+
+        srce(String desc, Boolean b) {
+            this.description = this + ": " +desc;
+            this.local = b;
+        }
+    }
+
 
     String[] ETypes={"TYPE", "FIELD", "METHOD", "PARAMETER", "CONSTRUCTOR",
                      "LOCAL_VARIABLE", "ANNOTATION_TYPE", "PACKAGE"};
@@ -51,31 +68,36 @@
         // Determines which repeat and order in source(ABMix).
         Boolean As= false, BDs=true, ABMix=false;
         int testrun=0;
-        // A repeats and/or B/D repeats, ABMix for order of As and Bs.
         Boolean [][] bRepeat = new Boolean[][]{{false,false,false},//no repeats
                                                {true,false,false}, //repeat @A
                                                {false,true,false}, //repeat @B
                                                {true,true,false},  //repeat both
                                                {false,false,true}  //repeat mix
         };
+
         for(Boolean[] bCombo : bRepeat) {
             As=bCombo[0]; BDs=bCombo[1]; ABMix=bCombo[2];
             for(String et : ETypes) {
                switch(et) {
                    case "METHOD":
-                       test( 8,  0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src3);
-                       test( 0,  8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, src3);
+                       test( 8, 0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src1);
+                       test( 0, 8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src1);
+                       test( 2, 0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src5);
+                       test( 0, 2, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src5);
                        break;
-                   case "CONSTRUCTOR":
                    case "FIELD":
-                       test( 8,  0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src3);
-                       test( 8,  0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src8);
-                       test( 6,  0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, src9);
-                       test( 0,  8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, src3);
-                       test( 0,  8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, src8);
-                       test( 0,  6, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, src9);
+                       test( 8, 0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src1);
+                       test( 8, 0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src2);
+                       test( 6, 0, 0, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src3);
+                       test( 2, 0, 2, 0, As, BDs, ABMix, "CLASS",   et, ++testrun, srce.src4);
+                       test( 0, 8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src1);
+                       test( 0, 8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src2);
+                       test( 0, 6, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src3);
+                       test( 0, 2, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src4);
                        break;
                    default:/*TYPE,PARAMETER,LOCAL_VARIABLE,ANNOTATION_TYPE,PACKAGE*/
+                       test( 0, 2, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src4);
+                       test( 0, 2, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src5);
                        break;
                }
             }
@@ -84,7 +106,7 @@
 
     public void test(int tinv, int tvis, int inv, int vis, Boolean Arepeats,
                      Boolean BDrepeats, Boolean ABmix, String rtn, String et2,
-                     Integer N, int source) throws Exception {
+                     Integer N, srce source) throws Exception {
         ++testcount;
         expected_tvisibles = tvis;
         expected_tinvisibles = tinv;
@@ -97,14 +119,19 @@
                 ", tvis=" + tvis + ", inv=" + inv + ", vis=" + vis +
                 ", Arepeats=" + Arepeats + ", BDrepeats=" + BDrepeats +
                 ", ABmix=" + ABmix + ", retention: " + rtn + ", anno2: " +
-                et2 + ", src=" + source;
+                et2 + ", src=" + source + "\n    " + source.description;
 
-// Uncomment this block to run the tests but skip failing scenarios.
-//        // 8005681 - skip cases with repeated annotations on new, array, cast.
-//        if((source==3 || source==8 || source==9) && (ABmix || (Arepeats && BDrepeats))) {
-//            System.out.println(testDef+"\n8005681-skip repeated annotations on new,array,cast");
-//            return;
-//        }
+        if(
+// 8005681 - src1,2,3 - skip cases with repeated annotations on new, array, cast.
+            (( source.equals(srce.src1) || source.equals(srce.src2) ||
+              source.equals(srce.src3)) && (ABmix || (Arepeats && BDrepeats)))
+ // 8008928 - src4,5 - this change cause crash with t-a on anon class)
+            || (source.equals(srce.src4) || source.equals(srce.src5))
+          ) {
+            System.out.println(testDef +
+                       "\n    8005681-skip repeated annotations on new,array,cast");
+            return;
+        }
 
         println(testDef);
         // Create test source and File.
@@ -123,6 +150,7 @@
         if(hasInnerClass) {
             StringBuffer sb = new StringBuffer(classFile.getAbsolutePath());
             classFile=new File(sb.insert(sb.lastIndexOf(".class"),innerClassname).toString());
+            println("classfile: " + classFile.getAbsolutePath());
         }
         ClassFile cf = ClassFile.read(classFile);
 
@@ -130,10 +158,16 @@
         test(cf);
 
         for (Field f : cf.fields) {
-            test(cf, f);
+            if(source.local)
+                test(cf, f, true);
+            else
+                test(cf,f);
         }
         for (Method m: cf.methods) {
-            test(cf, m);
+            if(source.local)
+                test(cf, m, true);
+            else
+                test(cf, m);
         }
         countAnnotations();
         if (errors > 0) {
@@ -149,7 +183,7 @@
     //
     String sourceString(String testname, String retentn, String annot2,
                         Boolean Arepeats, Boolean BDrepeats, Boolean ABmix,
-                        int src) {
+                        srce src) {
 
         String As = "@A", Bs = "@B", Ds = "@D";
         if(Arepeats) As = "@A @A";
@@ -198,7 +232,7 @@
 
         // Test case sources with sample generated source
         switch(src) {
-            case 3: // (repeating) type annotations on field in method body
+            case src1: // (repeating) type annotations on field in method body
                     /*
                      * class Test1 {
                      * Test1(){}
@@ -210,18 +244,19 @@
                      * }}
                       */
                 source = new String(
-                "class " + testname + " {\n" +
-                "" + testname +"(){} \n" +
-                "// type usage in method body \n" +
-                "String test("+testname+" this, " +
-                   "String param, String ... vararg) { \n" +
-                "    _As_ _Bs_\n    Object o = new _As_ _Bs_  String _As_ _Bs_  [3]; \n" +
-                "        return (_As_ _Bs_  String) null; \n" +
-                "} \n" +
-                "} \n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
-                "\n\n";
-                break;
-            case 8: // (repeating) annotations on type parameters, bounds and  type arguments in new statement.
+                    "// " + src.description + "\n" +
+                    "class " + testname + " {\n" +
+                    "" + testname +"(){} \n" +
+                    "// type usage in method body \n" +
+                    "String test("+testname+" this, " +
+                       "String param, String ... vararg) { \n" +
+                    "    _As_ _Bs_\n    Object o = new _As_ _Bs_  String _As_ _Bs_  [3]; \n" +
+                    "        return (_As_ _Bs_  String) null; \n" +
+                    "} \n" +
+                    "} \n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                    "\n\n";
+                    break;
+            case src2: // (repeating) annotations on type parameters, bounds and  type arguments in new statement.
                     /*
                      * class Test2<T extends Object> {
                      *     Map<List<String>, Integer> map =
@@ -232,17 +267,17 @@
                      * }
                      */
                 source = new String( source +
-                "// (repeating) annotations on type parameters, bounds and  type arguments. \n" +
-                "class " + testname + "<T extends Object> {\n" +
-                "    Map<List<String>, Integer> map =\n" +
-                "        new HashMap<_As_ _Bs_ List<_As_ _Bs_ String>, _As_ _Bs_ Integer>();\n" +
-                "    Map<List<String>, Integer> map2 = new _As_ _Bs_ HashMap<>();\n" +
-                "    String test(" + testname + "<T> this) { return null;}\n" +
-                "    <T> String genericMethod(T t) { return null; }\n" +
-                "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
-                "\n\n";
-            break;
-            case 9: // (repeating)annotations on type parameters of class, method return value in method.
+                    "// " + src.description + "\n" +
+                    "class " + testname + "<T extends Object> {\n" +
+                    "    Map<List<String>, Integer> map =\n" +
+                    "        new HashMap<_As_ _Bs_ List<_As_ _Bs_ String>, _As_ _Bs_ Integer>();\n" +
+                    "    Map<List<String>, Integer> map2 = new _As_ _Bs_ HashMap<>();\n" +
+                    "    String test(" + testname + "<T> this) { return null;}\n" +
+                    "    <T> String genericMethod(T t) { return null; }\n" +
+                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                    "\n\n";
+                break;
+            case src3: // (repeating)annotations on type parameters of class, method return value in method.
                     /*
                      * class Test3{
                      *     <E extends Comparable> Map<List<E>, E > foo(E e) {
@@ -258,24 +293,72 @@
                      * }
                      */
                 source = new String( source +
-                "// (repeating)annotations on type parameters of class, method return value in method. \n" +
-                "class "+ testname + "{\n" +
-                "    <E extends Comparable> Map<List<E>, E > foo(E e) {\n" +
-                "        class maptest <E> {\n" +                  // inner class $1maptest
-                "            Map<List<E>,E> getMap() { \n" +
-                "                Map<List<E>,E> Em = new HashMap<List<_As_ _Bs_ _Ds_ E>,_As_ _Bs_ _Ds_ E>();\n" +
-                "                return Em;\n" +
-                "            }\n" +
-                "        }\n" +
-                "        return new maptest<E>().getMap();\n" +
-                "   }\n" +
-                "   Map<List<String>,String> shm = foo(new String(\"hello\"));\n" +
-                "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs).replace("_Ds_",Ds) +
-                "\n\n";
-                hasInnerClass=true;
-                innerClassname="$1maptest";
-            break;
-
+                    "// " + src.description + "\n" +
+                    "class "+ testname + "{\n" +
+                    "    <E extends Comparable> Map<List<E>, E > foo(E e) {\n" +
+                    "        class maptest <E> {\n" +                  // inner class $1maptest
+                    "            Map<List<E>,E> getMap() { \n" +
+                    "                Map<List<E>,E> Em = new HashMap<List<_As_ _Bs_ _Ds_ E>,_As_ _Bs_ _Ds_ E>();\n" +
+                    "                return Em;\n" +
+                    "            }\n" +
+                    "        }\n" +
+                    "        return new maptest<E>().getMap();\n" +
+                    "   }\n" +
+                    "   Map<List<String>,String> shm = foo(new String(\"hello\"));\n" +
+                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs).replace("_Ds_",Ds) +
+                    "\n\n";
+                    hasInnerClass=true;
+                    innerClassname="$1maptest";
+                break;
+            case src4: // (repeating)annotations on field in anonymous class
+                    /*
+                     * class Test95{
+                     *     void mtest( Test95 t){  }
+                     *     public void test() {
+                     *         mtest( new Test95() {
+                     *             @A @A @B @B String data2 = "test";
+                     *         });
+                     *     }
+                     * }
+                     */
+                source = new String( source +
+                    "// " + src.description + "\n" +
+                    "class "+ testname + "{\n" +
+                    "    void mtest( "+ testname + " t){  }\n" +
+                    "    public void test() {\n" +
+                    "        mtest( new "+ testname + "() {\n" +
+                    "            _As_ _Bs_ String data2 = \"test\";\n" +
+                    "        });\n" +
+                    "    }\n" +
+                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                    "\n\n";
+                    hasInnerClass=true;
+                    innerClassname="$1";
+                break;
+            case src5: // (repeating)annotations on method in anonymous class
+                    /*
+                     * class Test120{
+                     *     void mtest( Test120 t){  }
+                     *     public void test() {
+                     *         mtest( new Test120() {
+                     *             @A @B @A @B String m2(){return null;};
+                     *         });
+                     *     }
+                     */
+                source = new String( source +
+                    "// " + src.description + "\n" +
+                    "class "+ testname + "{\n" +
+                    "    void mtest( "+ testname + " t){  }\n" +
+                    "    public void test() {\n" +
+                    "        mtest( new "+ testname + "() {\n" +
+                    "            _As_ _Bs_ String m2(){return null;};\n" +
+                    "        });\n" +
+                    "    }\n" +
+                    "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                    "\n\n";
+                    hasInnerClass=true;
+                    innerClassname="$1";
+                break;
         }
         return imports + source;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest3.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,539 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug 8005085 8005681 8008769 8010015
+ * @summary Check (repeating)type annotations on lambda usage.
+ * @run main CombinationsTargetTest3
+ */
+
+import com.sun.tools.classfile.*;
+import java.io.File;
+import java.util.Vector;
+
+public class CombinationsTargetTest3 extends ClassfileTestHelper {
+
+    // Helps identify test case in event of failure.
+    int testcount = 0;
+
+    // Known failure cases due to open bugs.
+    Vector<String> skippedTests = new Vector<>();
+    void printSkips() {
+        if(!skippedTests.isEmpty()) {
+            println(skippedTests.size() + " tests were skipped:");
+            for(String t : skippedTests)
+                println("    " + t);
+        }
+    }
+
+    // Test case descriptions and expected annotation counts.
+    enum srce  {
+        src1("type annotations on lambda expression as method arg.",4,0),
+        src2("type annotations on new in single line lambda expression",2,0),
+        src3("type annotations in lambda expression code block",4,0),
+        src4("type annotations in code block with recursion,cast",2,0),
+        src5("type annotations in lambda expression code block",4,0),
+        src6("type annotations on type parm in method reference",4,0),
+        src7("type annotations on inner class field of lambda expression",2,2),
+        src8("type annotations in inner class of lambda expression",4,2),
+        src9("type annotations on static method of interface",4,2);
+
+        String description;
+        // Expected annotation counts are same for Vis or Invis, but which one
+        // depends on retention type.
+        Integer[] exp = { 0, 0 };
+
+        // If class to test is inner class, this may be set in SourceString()
+        String innerClassname = null ;
+
+        // If class to test is not main or inner class; set in sourceString()
+        String altClassName = null;
+
+        srce(String desc, int e1, int e2) {
+            description = this + ": " +desc;
+            exp[0]=e1;
+            exp[1]=e2;
+        }
+    }
+
+    // Check for RuntimeInvisible or RuntimeVisible annotations.
+    String[] RType={"CLASS", "RUNTIME"};
+
+    // This can be a compile only test.
+    static boolean compileonly=false;
+
+    // Collect failure for end of test report()
+    Vector<String> vFailures = new Vector<>();
+
+    // pass/fail determined after all tests have run.
+    void report() {
+        if(vFailures.isEmpty()) {
+            printSkips();
+            println("PASS");
+        } else {
+           System.err.println("FAILED: There were failures:");
+           for(String f : vFailures)
+               System.err.println(f);
+           throw new RuntimeException("There were failures. See test log.");
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        if(args.length>0 && args[0].compareTo("compileonly")==0)
+            compileonly=true;
+        new CombinationsTargetTest3().run();
+    }
+
+    void run() throws Exception {
+        // Determines which repeat and order in source(ABMix).
+        Boolean As= false, BDs=true, ABMix=false;
+        int testrun=0;
+        // A repeats and/or B/D repeats, ABMix for order of As and Bs.
+        Boolean [][] bRepeat = new Boolean[][]{{false,false,false}, //no repeats
+                                               {true,false,false}, //repeat @A
+                                               {false,true,false}, //repeat @B
+                                               {true,true,false},  //repeat both
+                                               {false,false,true}  //repeat mix
+        };
+        // Added ElementType's. All set; not permuted (so far) for this test
+        String et = "TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE";
+
+        // test loop
+        for(Boolean[] bCombo : bRepeat) {
+            As=bCombo[0]; BDs=bCombo[1]; ABMix=bCombo[2];
+            for(srce src : srce.values())
+                for( String rtype : RType ) {
+                   switch( rtype ) {
+                       case "RUNTIME":
+                           test(0,src.exp[0],0,src.exp[1],As, BDs, ABMix,
+                                "RUNTIME", et, ++testrun, src);
+                           break;
+                       case "CLASS":
+                           test(src.exp[0],0,src.exp[1],0,As, BDs, ABMix,
+                                "CLASS", et, ++testrun, src);
+                           break;
+                }
+            }
+        }
+        report();
+    }
+
+    // Filter out skipped cases, compile, pass class file to test method,
+    // count annotations and asses results.
+    public void test(int tinv, int tvis, int inv, int vis, Boolean Arepeats,
+                     Boolean BDrepeats, Boolean ABmix, String rtn, String et2,
+                     Integer N, srce source) throws Exception {
+        ++testcount;
+        expected_tvisibles = tvis;
+        expected_tinvisibles = tinv;
+        expected_visibles = vis;
+        expected_invisibles = inv;
+        File testFile = null;
+        String tname="Test" + N.toString();
+        String testDef = "Test " + testcount + " parameters: tinv=" + tinv +
+                ", tvis=" + tvis + ", inv=" + inv + ", vis=" + vis +
+                ", Arepeats=" + Arepeats + ", BDrepeats=" + BDrepeats +
+                ", ABmix=" + ABmix + ", retention: " + rtn + ", anno2: " +
+                et2 + ", src=" + source;
+
+        // Skip failing cases with bug ID's
+        if ((source.equals(srce.src2) || source.equals(srce.src4) ||
+            source.equals(srce.src5)) &&
+            (ABmix || (Arepeats && BDrepeats))) {
+                skippedTests.add(testDef +
+                  "\n--8005681 repeated type-annotations on new/cast/array in" +
+                  " inner class in lambda expression.");
+            return;
+        }//8008769 Repeated type-annotations on type parm of local variable
+         else if (source.equals(srce.src6) &&
+                   (ABmix || (Arepeats && BDrepeats))) {
+            skippedTests.add(testDef +  "\n--8008769 Repeated " +
+                             "type-annotations on type parm of local variable");
+            return;
+        }
+
+        println(testDef);
+        // Create test source and File.
+        String sourceString = sourceString(tname, rtn, et2, Arepeats,
+                                           BDrepeats, ABmix, source);
+        testFile = writeTestFile(tname+".java", sourceString);
+        // Compile test source and read classfile.
+        File classFile = null;
+        try {
+            classFile = compile(testFile);
+            System.out.println("pass compile: " + tname + ".java");
+        } catch (Error err) {
+            System.err.println("fail compile. Source:\n" + sourceString);
+            throw err;
+        }
+        if(!compileonly) {
+            //check if innerClassname is set
+            String classdir = classFile.getAbsolutePath();
+            if(source.innerClassname != null) {
+                StringBuffer sb = new StringBuffer(classdir);
+                classFile=new File(sb.insert(sb.lastIndexOf(".class"),
+                                   source.innerClassname).toString());
+                source.innerClassname=null;
+            } else if (source.altClassName != null) {
+                classdir = classdir.substring(0,classdir.lastIndexOf("Test"));
+                classFile=new File(classdir.concat(source.altClassName));
+                source.innerClassname=null;
+            }
+            ClassFile cf = ClassFile.read(classFile);
+
+            println("Testing classfile: " + cf.getName());
+            //Test class,fields and method counts.
+            test(cf);
+
+            for (Field f : cf.fields) {
+                test(cf, f);
+                test(cf, f, true);
+            }
+            for (Method m: cf.methods) {
+                test(cf, m);
+                test(cf, m, true);
+            }
+
+            countAnnotations(); // sets errors=0 before counting.
+            if (errors > 0) {
+                System.err.println( testDef );
+                System.err.println( "Source:\n" + sourceString );
+                vFailures.add(testDef);
+            }
+        }
+        if(errors==0) println("Pass"); println("");
+    }
+
+    /*
+     * Source definitions for test cases.
+     * To add a test:
+     *   Add enum to srce(near top of file) with expected annotation counts.
+     *   Add source defintion below.
+     */
+    String sourceString(String testname, String retentn, String annot2,
+                        Boolean Arepeats, Boolean BDrepeats, Boolean ABmix,
+                        srce src) {
+
+        String As = "@A", Bs = "@B", Ds = "@D";
+        if(Arepeats) As = "@A @A";
+        if(BDrepeats) {
+            Bs = "@B @B";
+            Ds = "@D @D";
+        }
+        if(ABmix) { As = "@A @B"; Bs = "@A @B"; Ds = "@D @D"; }
+
+        // Source to check for TYPE_USE and TYPE_PARAMETER annotations.
+        // Source base (annotations) is same for all test cases.
+        String source = new String();
+        String imports = new String("import java.lang.annotation.*; \n" +
+            "import static java.lang.annotation.RetentionPolicy.*; \n" +
+            "import static java.lang.annotation.ElementType.*; \n" +
+            "import java.util.List; \n" +
+            "import java.util.ArrayList;\n\n");
+
+            String sourceBase = new String(
+            "@Retention("+retentn+") @Target({TYPE_USE,_OTHER_}) @Repeatable( AC.class ) @interface A { }\n" +
+            "@Retention("+retentn+") @Target({TYPE_USE,_OTHER_}) @interface AC { A[] value(); } \n" +
+            "@Retention("+retentn+") @Target({TYPE_USE,_OTHER_}) @Repeatable( BC.class ) @interface B { }\n" +
+            "@Retention("+retentn+") @Target({TYPE_USE,_OTHER_}) @interface BC { B[] value(); } \n" +
+            "@Retention("+retentn+") @Target({TYPE_USE,TYPE_PARAMETER,_OTHER_}) @Repeatable(DC.class) @interface D { }\n" +
+            "@Retention("+retentn+") @Target({TYPE_USE,TYPE_PARAMETER,_OTHER_}) @interface DC { D[] value(); }");
+
+        // Test case sources with sample generated source
+        switch(src) {
+            case src1: //(repeating) type annotations on lambda expressions.
+                /*
+                 * class Test1 {
+                 * Test1(){}
+                 * interface MapFun<T,R> {  R m( T n); }
+                 * void meth( MapFun<String,Integer> mf ) {
+                 *     assert( mf.m("four") == 4);
+                 * }
+                 * void test(Integer i) {
+                 *     // lambda expression as method arg
+                 *     meth( (@A @B String s) -> { @A @B Integer len = s.length(); return len; } );
+                 * }}
+                 */
+                source = new String( source +
+                "// " + src.description + "\n" +
+                "class " + testname + " {\n" +
+                "  " + testname +"(){} \n" +
+                "  interface MapFun<T,R> {  R m( T n); }\n\n" +
+                "  void meth( MapFun<String,Integer> mf ) {\n" +
+                "    assert( mf.m(\"four\") == 4);\n" +
+                "  }\n\n" +
+                "  void test(Integer i) {\n" +
+                "    // lambda expression as method arg\n" +
+                "    meth( (_As_ _Bs_ String s) -> { _As_ _Bs_ Integer len = s.length(); return len; } );\n" +
+                "}}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                "\n";
+                break;
+            case src2: //(repeating) type annotations on new in single line lambda expression.
+                /*
+                 * //case2: (repeating) type annotations on new in single lambda expressions.
+                 * class Test2{
+                 *   interface MapFun<T, R> {  R m( T n); }
+                 *   MapFun<Integer, String> its;
+                 * void test(Integer i) {
+                 *   its = a -> "~"+new @A @B Integer(a).toString()+"~";
+                 *   System.out.println("in: " + i + " out: " + its.m(i));
+                 * }}
+                 */
+                source = new String( source +
+                "// " + src.description + "\n" +
+                "class " + testname + "{\n" +
+                "  interface MapFun<T, R> {  R m( T n); }\n" +
+                "  MapFun<Integer, String> its;\n" +
+                "  void test(Integer i) {\n" +
+                "    its = a -> \"~\"+new _As_ _Bs_ Integer(a).toString()+\"~\";\n" +
+                "    System.out.println(\"in: \" + i + \" out: \" + its.m(i));\n" +
+                "  }\n" +
+                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                "\n";
+            break;
+            case src3: //(repeating) type annotations in lambda expression code block.
+                /*
+                 * class Test183{
+                 *   interface MapFun<T, R> {  R m( T n); }
+                 *   MapFun<List<Integer>, String> iLs;
+                 *   void testm(Integer i) {
+                 *       iLs = l -> { @A @B @A @B String ret = new String();
+                 *                    for( @A @B @A @B Integer i2 : l)
+                 *                        ret=ret.concat(i2.toString() + " ");
+                 *                    return ret; };
+                 *   List<Integer> li = new ArrayList<>();
+                 *   for(int j=0; j<i; j++) li.add(j);
+                 *   System.out.println(iLs.m(li) );
+                 * }}
+                 */
+                source = new String( source +
+                "// " + src.description + "\n" +
+                "class "+ testname + "{\n" +
+                "  interface MapFun<T, R> {  R m( T n); }\n" +
+                "  MapFun<List<Integer>, String> iLs;\n" +
+                "  void testm(Integer i) {\n" +
+                "    iLs = l -> { _As_ _Bs_ String ret = new String();\n" +
+                "                 for( _As_ _Bs_ Integer i2 : l)\n" +
+                "                   ret=ret.concat(i2.toString() + \" \");\n" +
+                "                 return ret; };\n" +
+                "  List<Integer> li = new ArrayList<>();\n" +
+                "  for(int j=0; j<i; j++) li.add(j);\n" +
+                "  System.out.println(iLs.m(li) );\n" +
+                "}\n" +
+                "\n" +
+                "    public static void main(String... args) {new " + testname + "().testm(5); }\n" +
+                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                "\n";
+            break;
+            case src4: //(repeating) type annotations in code block with recursion,cast
+                /*
+                 * class Test194{
+                 *   interface MapFun<T, R> {  R m( T n); }
+                 *   MapFun<Integer, Double>  nf;
+                 *   void testm(Integer i) {
+                 *       nf = j -> { return j == 1 ? 1.0 : (@A @B @A @B  Double)(nf.m(j-1) * j); };
+                 *       System.out.println( "nf.m(" + i + "): " + nf.m(i));
+                 *   }
+                 * }
+                 */
+                source = new String( source +
+                "// " + src.description + "\n" +
+                "class "+ testname + "{\n" +
+                "  interface MapFun<T, R> {  R m( T n); }\n" +
+                "  MapFun<Integer, Double>  nf;\n" +
+                "  void testm(Integer i) {\n" +
+                "    nf = j -> { return j == 1 ? 1.0 : (_As_ _Bs_  Double)(nf.m(j-1) * j); };\n" +
+                "    System.out.println( \"nf.m(\" + i + \"): \" + nf.m(i));\n" +
+                "  }\n" +
+                "  public static void main(String... args) {new " + testname + "().testm(5); }\n" +
+                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                "\n";
+            break;
+            case src5: //(repeating) type annotations in lambda expression code block.
+                   /*
+                    * class Test180 {
+                    *   interface MapFun<T, R> {  R m( T n); }
+                    *   MapFun<Integer,List<Integer>> iLi;
+                    *   void test(Integer i) {
+                    *     // type parameter use.
+                    *     iLi = n -> { List<@A @B @A @B Integer> LI = new ArrayList<@A @B @A @B Integer>(n);
+                    *                  for(int nn = n; nn >=0; nn--) LI.add(nn);
+                    *                  return LI; };
+                    *     List<Integer> li = iLi.m(i);
+                    *     for(Integer k : li) System.out.print(k);
+                    *   }
+                    * }
+                    */
+                source = new String( source +
+                "// " + src.description + "\n" +
+                "class "+ testname + "{\n" +
+                "  interface MapFun<T, R> {  R m( T n); }\n" +
+                "  MapFun<Integer,List<Integer>> iLi;\n" +
+                "  void test(Integer i) {\n" +
+                "    // type parameter use.\n" +
+                "    iLi = n -> { List<_As_ _Bs_ Integer> LI = new ArrayList<_As_ _Bs_ Integer>(n);\n" +
+                "                 for(int nn = n; nn >=0; nn--) LI.add(nn);\n" +
+                "                 return LI; };\n" +
+                "    List<Integer> li = iLi.m(i);\n" +
+                "    for(Integer k : li) System.out.print(k);\n" +
+                "}\n" +
+                "  public static void main(String... args) {new " + testname + "().test(5); }\n" +
+                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs).replace("_Ds_",Ds) +
+                "\n";
+            break;
+            case src6: //(repeating) type annotations on type parm in method reference.
+                /*
+                 * class Test240{
+                 *   interface PrintString { void print(String s); }
+                 *   public void printArray(Object[] oa, PrintString ps) {
+                 *       for(Object o : oa ) ps.print(o.toString());
+                 *   }
+                 *   public void test() {
+                 *       Integer[] intarray = {1,2,3,4,5};
+                 *       printArray(intarray, @A @B @A @B TPrint::<@A @B @A @B String>print);
+                 *   }
+                 * }
+                 * class TPrint {
+                 *    public static <T> void print(T t) { System.out.println( t.toString()); }
+                 * }
+                 */
+                source = new String( source +
+                "// " + src.description + "\n" +
+                "class "+ testname + "{\n" +
+                "  interface PrintString { void print(String s); }\n" +
+                "  public void printArray(Object[] oa, PrintString ps) {\n" +
+                "      for(Object o : oa ) ps.print(o.toString());\n" +
+                "  }\n" +
+                "  public void test() {\n" +
+                "    Integer[] intarray = {1,2,3,4,5};\n" +
+                "    printArray(intarray, _As_ _Bs_ TPrint::<_As_ _Bs_ String>print);\n" +
+                "  }\n" +
+                "  public static void main(String... args) {new " + testname + "().test(); }\n" +
+                "}\n\n" +
+                "class TPrint {\n" +
+                "  public static <T> void print(T t) { System.out.println( t.toString()); }\n" +
+                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                "\n";
+            break;
+            case src7: //(repeating)type annotations in inner class of lambda expression.
+                /*
+                 * class Test2{
+                 *   interface MapFun<T, R> {  R m( T n); }
+                 *   MapFun<Class<?>,String> cs;
+                 *   void test() {
+                 *     cs = c -> {
+                 *         class innerClass   {
+                 *           @A @B Class<?> icc = null;
+                 *           String getString() { return icc.toString(); }
+                 *         }
+                 *         return new innerClass().getString();
+                 *     };
+                 *     System.out.println("cs.m : " + cs.m(Integer.class));
+                 *   }
+                 * }
+                 */
+                source = new String( source +
+                "// " + src.description + "\n" +
+                "class "+ testname + "{\n" +
+                "  interface MapFun<T, R> {  R m( T n); }\n" +
+                "  MapFun<Class<?>,String> cs;\n" +
+                "  void test() {\n" +
+                "    cs = c -> {\n" +
+                "        class innerClass   {\n" +
+                "          _As_ _Bs_ Class<?> icc = null;\n" +
+                "          innerClass(Class<?> _c) { icc = _c; }\n" +
+                "          String getString() { return icc.toString(); }\n" +
+                "        }\n" +
+                "        return new innerClass(c).getString();\n" +
+                "    };\n" +
+                "    System.out.println(\"cs.m : \" + cs.m(Integer.class));\n" +
+                "  }\n" +
+                "\n" +
+                "    public static void main(String... args) {new " + testname + "().test(); }\n" +
+                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                "\n";
+                src.innerClassname="$1innerClass";
+            break;
+            case src8: //(repeating)type annotations in inner class of lambda expression.
+                /*
+                 * class Test2{
+                 *   interface MapFun<T, R> {  R m( T n); }
+                 *   MapFun<Class<?>,String> cs;
+                 *   void test() {
+                 *     cs = c -> {
+                 *         class innerClass   {
+                 *             Class<?> icc;
+                 *             innerClass(@A @B Class<?> _c) { icc = _c; }
+                 *             @A @B String getString() { return icc.toString(); }
+                 *         }
+                 *         return new innerClass(c).getString();
+                 *     };
+                 *     System.out.println("cs.m : " + cs.m(Integer.class));
+                 *   }
+                 * }
+                 */
+                source = new String( source +
+                "// " + src.description + "\n" +
+                "class "+ testname + "{\n" +
+                "  interface MapFun<T, R> {  R m( T n); }\n" +
+                "  MapFun<Class<?>,String> cs;\n" +
+                "  void test() {\n" +
+                "    cs = c -> {\n" +
+                "        class innerClass {\n" +
+                "            Class<?> icc;\n" +
+                "            innerClass(_As_ _Bs_ Class<?> _c) { icc = _c; }\n" +
+                "            _As_ _Bs_ String getString() { return icc.toString(); }\n" +
+                "        }\n" +
+                "        return new innerClass(c).getString();\n" +
+                "    };\n" +
+                "    System.out.println(\"cs.m : \" + cs.m(Integer.class));\n" +
+                "  }\n" +
+                "\n" +
+                "    public static void main(String... args) {new " + testname + "().test(); }\n" +
+                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                "\n";
+                src.innerClassname="$1innerClass";
+            break;
+            case src9: //(repeating)type annotations on static method of interface
+                /*
+                 *  class Test90{
+                 *    interface I  {
+                 *      static @A @B @A @B String m() { @A @B @A @B String ret = "I.m"; return ret; }
+                 *    }
+                 *  }
+                 */
+                source = new String( source +
+                "// " + src.description + "\n" +
+                "class "+ testname + "{\n" +
+                "  interface I  { \n" +
+                "    static _As_ _Bs_ String m() { _As_ _Bs_ String ret = \"I.m\"; return ret; }\n" +
+                "  }\n" +
+                "}\n\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
+                "\n";
+                src.innerClassname="$I";
+            break;
+        }
+        return imports + source;
+    }
+}
--- a/langtools/test/tools/javac/annotations/typeAnnotations/classfile/DeadCode.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/DeadCode.java	Fri May 17 10:13:34 2013 -0700
@@ -49,7 +49,7 @@
             test(cf, f);
         }
         for (Method m: cf.methods) {
-            test(cf, m);
+            test(cf, m, true);
         }
 
         countAnnotations();
--- a/langtools/test/tools/javac/annotations/typeAnnotations/classfile/NewTypeArguments.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/NewTypeArguments.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, 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
@@ -48,7 +48,7 @@
             test(cf, f);
         }
         for (Method m: cf.methods) {
-            test(cf, m);
+            test(cf, m, true);
         }
 
         countAnnotations();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/T8008762.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2009, 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug 8008762
+ * @ignore 8013409: test failures for type annotations
+ * @summary Type annotation on inner class in anonymous class
+ *          shows up as regular annotation
+ */
+import java.lang.annotation.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+
+import com.sun.tools.classfile.*;
+
+public class T8008762 extends ClassfileTestHelper{
+    public static void main(String[] args) throws Exception {
+        new T8008762().run();
+    }
+
+    public void run() throws Exception {
+        expected_tinvisibles = 0;
+        expected_tvisibles = 4;
+
+        ClassFile cf = getClassFile("T8008762$Test$1$InnerAnon.class");
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f, false);
+        }
+        for (Method m : cf.methods) {
+            test(cf, m, false);
+        }
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    /*********************** Test class *************************/
+    static class Test {
+        Object mtest( Test t){ return null; }
+        public void test() {
+          mtest( new Test() {
+                class InnerAnon { // Test1$1$InnerAnon.class
+                  @A @B String ai_data = null;
+                  @A @B String ai_m(){ return null; };
+                }
+               InnerAnon IA = new InnerAnon();
+            });
+        }
+        @Retention(RUNTIME) @Target(TYPE_USE) @interface A { }
+        @Retention(RUNTIME) @Target(TYPE_USE) @interface B { }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/T8008769.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2009, 2013, 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.
+ */
+/*
+ * @test
+ * @summary Repeated type-annotations on type parm of local variable
+ *          are not written to classfile.
+ * @bug 8008769
+ */
+import java.lang.annotation.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+import com.sun.tools.classfile.*;
+
+public class T8008769 extends ClassfileTestHelper{
+    public static void main(String[] args) throws Exception {
+        new T8008769().run();
+    }
+
+    public void run() throws Exception {
+        expected_tvisibles = 4;
+        ClassFile cf = getClassFile("T8008769$Test.class");
+        for (Method m : cf.methods) {
+            test(cf, m, true);
+        }
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    /*********************** Test class *************************/
+    static class Test<T> {
+        public void test() {
+            Test<@A @B String>    t0 = new Test<>(); // 2 ok
+            Test<@B @B String>    t1 = new Test<>(); // 1 missing
+            Test<@A @A @A String> t2 = new Test<>(); // 1 missing
+       }
+    }
+    @Retention(RUNTIME) @Target(TYPE_USE) @Repeatable( AC.class ) @interface A { }
+    @Retention(RUNTIME) @Target(TYPE_USE) @Repeatable( BC.class ) @interface B { }
+    @Retention(RUNTIME) @Target(TYPE_USE) @interface AC { A[] value(); }
+    @Retention(RUNTIME) @Target(TYPE_USE) @interface BC { B[] value(); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/T8010015.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2009, 2013, 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.
+ */
+
+/*
+ * @test
+ * @summary Wrong classfile attribution in inner class of lambda expression.
+ * @bug 8010015
+ */
+
+import java.lang.annotation.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * A type-annotations on a field in an inner class not in a lambda expression
+ * results in RuntimeTypeAnnotations_attibute and RuntimeAnnotations_attribute.
+ * On a field in an innner class in a lambda expression, it leaves off the
+ * RuntimeAnnotations_attribute.
+ */
+public class T8010015 extends ClassfileTestHelper{
+    public static void main(String[] args) throws Exception {
+        new T8010015().run();
+    }
+
+    public void run() throws Exception {
+        expected_tvisibles = 1;
+        expected_visibles = 1;
+        ClassFile cf = getClassFile("T8010015$Test$1innerClass.class");
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    /*********************** Test class **************************/
+    interface MapFun<T, R> { R m( T n); }
+    static class Test {
+        MapFun<Class<?>,String> cs;
+        void test() {
+            cs = c -> {
+                     class innerClass {
+                         @A Class<?> icc = null;
+                         innerClass(Class<?> _c) { icc = _c; }
+                         String getString() { return icc.toString(); }
+                     }
+                     return new innerClass(c).getString();
+            };
+            System.out.println("cs.m : " + cs.m(Integer.class));
+        }
+
+    public static void main(String... args) {new Test().test(); }
+    }
+    @Retention(RUNTIME) @Target({TYPE_USE,FIELD}) @interface A { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/TestNewCastArray.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,375 @@
+/*
+ * Copyright (c) 2013 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.
+ */
+
+/*
+ * @test
+ * @bug 8005681
+ * @summary Repeated annotations on new,array,cast.
+ */
+import java.lang.annotation.*;
+import java.io.*;
+import java.util.List;
+import com.sun.tools.classfile.*;
+
+import java.lang.annotation.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+
+public class TestNewCastArray {
+    int errors = 0;
+    List<String> failedTests = new java.util.LinkedList<>();
+
+    // 'b' tests fail with only even numbers of annotations (8005681).
+    String[] testclasses = {"Test1",
+        "Test2a", "Test3a", "Test4a", "Test5a",
+        "Test2b", "Test3b", "Test4b", "Test5b"
+    };
+
+    public static void main(String[] args) throws Exception {
+        new TestNewCastArray().run();
+    }
+
+    void check(String testcase, int expected, int actual) {
+        String res = testcase + ": (expected) " + expected + ", " + actual + " (actual): ";
+        if(expected == actual) {
+            res = res.concat("PASS");
+        } else {
+            errors++;
+            res = res.concat("FAIL");
+            failedTests.add(res);
+        }
+        System.out.println(res);
+    }
+
+    void report() {
+        if(errors!=0) {
+            System.err.println("Failed tests: " + errors +
+                                   "\nfailed test cases:\n");
+            for(String t: failedTests)
+                System.err.println("  " + t);
+           throw new RuntimeException("FAIL: There were test failures.");
+           } else
+            System.out.println("PASS");
+    }
+
+    void test(String clazz, String ttype, ClassFile cf, Method m, Field f,
+              String name, boolean codeattr) {
+        int actual = 0;
+        int expected = 0, cexpected = 0;
+        int index = 0;
+        String memberName = null;
+        Attribute attr = null;
+        Code_attribute cAttr = null;
+        String testcase = "undefined";
+        try {
+        switch(ttype) {
+            case "METHOD":
+                index = m.attributes.getIndex(cf.constant_pool, name);
+                memberName = m.getName(cf.constant_pool);
+                if(index != -1)
+                    attr = m.attributes.get(index);
+                break;
+            case "MCODE":
+                memberName = m.getName(cf.constant_pool);
+                //fetch index of and code attribute and annotations from code attribute.
+                index = m.attributes.getIndex(cf.constant_pool, Attribute.Code);
+                if(index!= -1) {
+                    attr = m.attributes.get(index);
+                    assert attr instanceof Code_attribute;
+                    cAttr = (Code_attribute)attr;
+                    index = cAttr.attributes.getIndex(cf.constant_pool, name);
+                    if(index!= -1)
+                        attr = cAttr.attributes.get(index);
+                }
+                break;
+            case "FIELD":
+                index = f.attributes.getIndex(cf.constant_pool, name);
+                memberName = f.getName(cf.constant_pool);
+                if(index != -1)
+                    attr = f.attributes.get(index);
+                break;
+            case "CODE":
+                memberName = f.getName(cf.constant_pool);
+                //fetch index of and code attribute and annotations from code attribute.
+                index = cf.attributes.getIndex(cf.constant_pool, Attribute.Code);
+                if(index!= -1) {
+                    attr = cf.attributes.get(index);
+                    assert attr instanceof Code_attribute;
+                    cAttr = (Code_attribute)attr;
+                    index = cAttr.attributes.getIndex(cf.constant_pool, name);
+                    if(index!= -1)
+                        attr = cAttr.attributes.get(index);
+                }
+                break;
+            default:
+                break;
+        }
+        } catch(ConstantPoolException cpe) { cpe.printStackTrace(); }
+        testcase = clazz+" "+ttype + ": " + memberName + ", " + name;
+        if(index != -1) {
+            //count RuntimeTypeAnnotations
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr =
+                    (RuntimeTypeAnnotations_attribute)attr;
+                actual += tAttr.annotations.length;
+        }
+        if(memberName.compareTo("<init>")==0) memberName=clazz+memberName;
+        switch ( memberName ) {
+            //METHOD:
+            case "Test1<init>": expected=0; break;
+            case "testr22_22": expected=4; break;
+            case "testr11_11": expected=4; break;
+            case "testr12_21": expected=4; break;
+            case "testr20_02": expected=2; break;
+
+            case "Test2a<init>": cexpected=0; break;
+            case "test00_00_11_11": cexpected=4; break;
+            case "test21_12_21_12": cexpected=8; break;
+            case "test_new1": cexpected=2; break;
+            case "test_new2": cexpected=2; break;
+            case "test_cast1": cexpected=2; break;
+            case "test_cast2": cexpected=2; break;
+
+            case "Test2b<init>": cexpected=0; break;
+            case "test20_02_20_02": cexpected=4; break;
+            case "test22_22_22_22": cexpected=8; break;
+            case "test_new3": cexpected=1; break;
+            case "test_new4": cexpected=1; break;
+            case "test_new5": cexpected=2; break;
+            case "test_cast3": cexpected=1; break;
+            case "test_cast4": cexpected=2; break;
+
+            case "Test3a<init>": cexpected=10; break;
+            case "SA_21_12c": cexpected = 0; break;
+            case "SA_01_10c": expected = 0; break;
+            case "SA_11_11c": expected = 0; break;
+
+            case "Test3b<init>": cexpected=6; break;
+            case "SA_22_22c": cexpected = 0; break;
+            case "SA_20_02c": cexpected = 0; break;
+
+            case "Test3c<init>": cexpected=8; break;
+            case "SA_10_10": cexpected = 0; break;
+            case "SA_10_01": cexpected = 0; break;
+            case "SA_21_12": cexpected = 0; break;
+
+            case "Test3d<init>": cexpected=6; break;
+            case "SA_20_02": cexpected = 0; break;
+            case "SA_22_22": cexpected = 0; break;
+
+            case "Test4a<init>": cexpected=4; break;
+            case "nS_21": cexpected = 0; break;
+            case "nS_12": cexpected = 0; break;
+
+            case "Test4b<init>": cexpected=4; break;
+            case "nS20":  cexpected = 0; break;
+            case "nS02":  cexpected = 0; break;
+            case "nS22":  cexpected = 0; break;
+
+            case "Test5a<init>": cexpected=4; break;
+            case "ci11": expected = 0; break;
+            case "ci21": expected = 0; break;
+
+            case "Test5b<init>": cexpected=3; break;
+            case "ci2":  expected = 0; break;
+            case "ci22": expected = 0; break;
+
+            default: expected = 0; break;
+        }
+        if(codeattr)
+            check(testcase, cexpected, actual);
+        else
+            check(testcase, expected, actual);
+    }
+
+    public void run() {
+        ClassFile cf = null;
+        InputStream in = null;
+        for( String clazz : testclasses) {
+            String testclazz = "TestNewCastArray$" + clazz + ".class";
+            System.out.println("Testing " + testclazz);
+            try {
+                in = getClass().getResource(testclazz).openStream();
+                cf = ClassFile.read(in);
+                in.close();
+            } catch(Exception e) { e.printStackTrace();  }
+
+            if(clazz.startsWith("Test1")) {
+                for (Field f: cf.fields)
+                    test(clazz, "FIELD", cf, null, f, Attribute.RuntimeVisibleTypeAnnotations, false);
+                for (Method m: cf.methods)
+                    test(clazz, "METHOD", cf, m, null, Attribute.RuntimeVisibleTypeAnnotations, false);
+            } else {
+                for (Field f: cf.fields)
+                    test(clazz, "CODE", cf, null, f, Attribute.RuntimeVisibleTypeAnnotations, true);
+                for (Method m: cf.methods)
+                    test(clazz, "MCODE", cf, m, null, Attribute.RuntimeVisibleTypeAnnotations, true);
+            }
+        }
+        report();
+    }
+
+    //////// test class //////////////////////////
+    // "Test1" not in code attribute.
+    // on arrays on and in method return
+    static class Test1 {
+        Test1(){}
+        // OK expect 5, got 5
+        String @A @A @B @B[] @A @A @B @B [] testr22_22(Test1 this, String param, String ... vararg) {
+            String [][] sarray = new String [2][2];
+            return sarray;
+        }
+        // OK expect 5, got 5
+        String @A @B [] @A @B [] testr11_11(Test1 this, String param, String ... vararg) {
+            String [][] sarray = new String [2][2];
+            return sarray;
+        }
+        // OK expect 5, got 5
+        String @A @B @B []@B @B @A[] testr12_21(Test1 this, String param, String ... vararg) {
+            String [][] sarray = new String [2][2];
+            return sarray;
+        }
+        // OK expect 3, got 3
+        String @A @A [] @B @B [] testr20_02(Test1 this, String param, String ... vararg) {
+            String [][] sarray = new String [2][2];
+            return sarray;
+        }
+    }
+
+    // Inside method body (in method's code attribute)
+    static class Test2a {
+        Test2a(){}
+        Object o = new Integer(1);
+        // expect 4
+        String[][] test00_00_11_11(Test2a this, String param, String ... vararg) {
+            String [] [] sarray = new String @A @B[2] @A @B [2];
+            return sarray;
+        }
+
+        // expect 8
+        String[][] test21_12_21_12(Test2a this, String param, String ... vararg) {
+            String @A @A @B [] @A @B @B [] sarray = new String @A @A @B[2] @A @B @B [2];
+            return sarray;
+        }
+
+        void test_new1() { String nS_21 = new @A @A @B String("Hello");   }
+        void test_new2() { String nS_12 = new @A @B @B String("Hello");   }
+        void test_cast1() { String tcs11 = (@A @B String)o;      }
+        void test_cast2() { String tcs21 = (@A @A @B String)o;   }
+    }
+
+    static class Test2b {
+        Test2b(){}
+        Object o = new Integer(1);
+        // expect 4
+        String[][] test20_02_20_02(Test2b this, String param, String ... vararg) {
+            String @A @A [] @B @B [] sarray = new String @A @A[2] @B @B [2];
+            return sarray;
+        }
+
+        // expect 8
+        String[][] test22_22_22_22(Test2b this, String param, String ... vararg) {
+            String @A @A @B @B [] @A @A @B @B [] sarray = new String @A @A @B @B [2] @A @A @B @B [2];
+            return sarray;
+        }
+
+        void test_new3() { String nS20 = new @A @A String("Hello");       }
+        void test_new4() { String nS02 = new @B @B String("Hello");       }
+        void test_new5() { String nS22 = new @A @A @B @B String("Hello"); }
+        void test_cast3() { String tcs2 =  (@A @A String)o;      }
+        void test_cast4() { String tcs22 = (@A @A @B @B String)o;}
+    }
+
+    // array levels
+    static class Test3a {
+        Test3a(){}
+        // expect 4+2+4=10
+        String [][] SA_21_12c  = new  String @A @A @B [2] @A @B @B[2];
+        String [][] SA_01_10c  = new  String @B [2] @A [2];
+        String [][] SA_11_11c = new  String @A @B [2] @A @B [2];
+    }
+
+    static class Test3b {
+        Test3b(){}
+        // expect 4+2=6
+        String [][] SA_22_22c  = new  String @A @A @B @B[2] @A @A @B @B[2];
+        String [][] SA_20_02c  = new  String @A @A [2] @B @B[2];
+    }
+    static class Test3c {
+        Test3c(){}
+        // OK expect 4
+        String @A [] @A[] SA_10_10  = new  String [2][2];
+        String @A [] @B[] SA_10_01  = new  String [2][2];
+        String @A @A @B[] @A @B @B [] SA_21_12  = new  String [2][2];
+    }
+
+    static class Test3d {
+        Test3d(){}
+        // OK expect 4
+        String @A @A [] @B @B [] SA_20_02  = new  String [2][2];
+        String @A @A @B @B[] @A @A @B @B [] SA_22_22  = new  String [2][2];
+    }
+
+    // on new
+    static class Test4a {
+        Test4a(){}
+        // expect 2+2=4
+        String nS_21 = new @A @A @B String("Hello");
+        String nS_12 = new @A @B @B String("Hello");
+    }
+
+    static class Test4b {
+        Test4b(){}
+        // expect 1+1+2=4
+        String nS20 = new @A @A String("Hello");
+        String nS02 = new @B @B String("Hello");
+        String nS22 = new @A @A @B @B String("Hello");
+    }
+
+    // Cast expressions
+    static class Test5a {
+        Test5a(){}
+        Object o = new Integer(1);
+        // expect 2+2=4
+        Integer ci11 = (@A @B Integer)o;       // OK expect 3, got 3
+        Integer ci21 = (@A @A @B Integer)o;    // OK expect 3, got 3
+    }
+
+    static class Test5b {
+        Test5b(){}
+        Object o = new Integer(1);
+        // Cast expressions
+        // expect 1+2=3
+        Integer ci2 =  (@A @A Integer)o;       // FAIL expect 2, got 1
+        Integer ci22 = (@A @A @B @B Integer)o; // FAIL expect 3, got 1
+    }
+
+@Retention(RUNTIME) @Target({TYPE_USE}) @Repeatable( AC.class ) @interface A { }
+@Retention(RUNTIME) @Target({TYPE_USE}) @Repeatable( BC.class ) @interface B { }
+@Retention(RUNTIME) @Target({FIELD}) @Repeatable( FC.class ) @interface F { }
+@Retention(RUNTIME) @Target({TYPE_USE}) @interface AC { A[] value(); }
+@Retention(RUNTIME) @Target({TYPE_USE}) @interface BC { B[] value(); }
+@Retention(RUNTIME) @Target({FIELD}) @interface FC { F[] value(); }
+
+}
+
--- a/langtools/test/tools/javac/annotations/typeAnnotations/classfile/TypeCasts.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/TypeCasts.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, 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
@@ -50,7 +50,7 @@
             test(cf, f);
         }
         for (Method m: cf.methods) {
-            test(cf, m);
+            test(cf, m, true);
         }
 
         countAnnotations();
--- a/langtools/test/tools/javac/annotations/typeAnnotations/classfile/Wildcards.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/Wildcards.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, 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
@@ -48,7 +48,7 @@
             test(cf, f);
         }
         for (Method m: cf.methods) {
-            test(cf, m);
+            test(cf, m,false);
         }
 
         countAnnotations();
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.java	Fri May 17 10:13:34 2013 -0700
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @bug 8006733 8006775
- * @ignore
+ * @ignore 8013409: test failures for type annotations
  * @summary A static outer class cannot be annotated.
  * @author Werner Dietl
  * @compile/fail/ref=CantAnnotateStaticClass.out -XDrawDiagnostics CantAnnotateStaticClass.java
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/LazyConstantValue.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/LazyConstantValue.java	Fri May 17 10:13:34 2013 -0700
@@ -27,7 +27,7 @@
  * @summary Type annotations in a lazy constant need to be attributed
  *   in the correct order.
  * @author Werner Dietl
- * @compile LazyConstantValue.java
+ * @compile/ref=LazyConstantValue.out LazyConstantValue.java
  */
 
 import java.lang.annotation.*;
@@ -40,5 +40,9 @@
     static final String[] lcv = new @TA String[0];
 }
 
+class ClassC {
+    static final Object o = (@TA Object) null;
+}
+
 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
 @interface TA {}
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/LintCast.out	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/LintCast.out	Fri May 17 10:13:34 2013 -0700
@@ -1,11 +1,11 @@
 LintCast.java:15:21: compiler.warn.redundant.cast: java.lang.String
 LintCast.java:21:27: compiler.warn.redundant.cast: java.util.List<java.lang.String>
-LintCast.java:27:20: compiler.warn.redundant.cast: (@A :: int[])
+LintCast.java:27:20: compiler.warn.redundant.cast: int @A []
 LintCast.java:39:24: compiler.warn.redundant.cast: java.lang.String
 LintCast.java:40:26: compiler.warn.redundant.cast: java.lang.String
-LintCast.java:45:23: compiler.warn.redundant.cast: (@A :: java.lang.Object[])
+LintCast.java:45:23: compiler.warn.redundant.cast: java.lang.Object @A []
 LintCast.java:49:27: compiler.warn.redundant.cast: java.util.List<java.lang.String>
-LintCast.java:53:27: compiler.warn.redundant.cast: java.util.List<java.lang.String>
+LintCast.java:53:27: compiler.warn.redundant.cast: java.util.List<@A java.lang.String>
 LintCast.java:57:21: compiler.warn.redundant.cast: java.lang.Object
 LintCast.java:61:27: compiler.warn.redundant.cast: LintCast.Outer.Inner
 10 warnings
\ No newline at end of file
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.java	Fri May 17 10:13:34 2013 -0700
@@ -6,7 +6,7 @@
  * @compile/fail/ref=StaticMethods.out -XDrawDiagnostics StaticMethods.java
  */
 class StaticMethods {
-  static void main(@A StaticMethods this) { }
+  static void main(StaticMethods this) { }
 }
 
 @interface A { }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.out	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.out	Fri May 17 10:13:34 2013 -0700
@@ -1,2 +1,2 @@
-StaticMethods.java:9:37: compiler.err.annotation.type.not.applicable
+StaticMethods.java:9:34: compiler.err.non-static.cant.be.ref: kindname.variable, this
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8008751.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @summary type-annotation on array level in nested class results in NPE
+ * @bug 8008751
+ * @compile T8008751.java
+ */
+import java.lang.annotation.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+import java.util.List;
+
+class T8008751 {
+    Object mtest( T8008751 t){ return null;  }
+    public void test() {
+       mtest( new T8008751() {
+                class InnerAnon {
+                    @A("ok") String s = (@A("ok") String)( new @A("ok") Object());
+                    @A("ok") Object @A("NPE")[] [] ia_sa1 = null;
+                }
+                // If not instanciated, no crash.
+                InnerAnon IA = new InnerAnon();
+           });
+   }
+}
+@Retention(RUNTIME) @Target(TYPE_USE)  @interface A { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8009360.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug 8009360
+ * @summary AssertionError from type annotation on member of anonymous class
+ * @compile T8009360.java
+ */
+import java.lang.annotation.*;
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+
+class Test1<T> {
+    Object mtest( Test1<T> t){ return null; }
+    public void test() {
+        mtest( new Test1<T>() {
+                @A String data1 = "test";    // ok
+                @A @A String data2 = "test"; // ok
+                @A @B String data3 = "test"; // was AssertionError
+                @B @C String data4 = "test"; // was AssertionError
+           });
+   }
+}
+
+@Target({TYPE_USE,FIELD}) @Repeatable( AC.class) @interface A { }
+@Target({TYPE_USE,FIELD}) @interface AC { A[] value(); }
+@Target({TYPE_USE}) @interface B { }
+@Target({TYPE_USE, FIELD}) @interface C { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8011722.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug 8011722
+ * @summary AssertionError from type annotations on qualified type
+ * @compile T8011722.java
+ */
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+public class T8011722 {
+    class InnerException extends Exception { }
+    void foo() throws @C T8011722.@C InnerException {    }
+}
+
+@Target(ElementType.TYPE_USE) @interface C { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 1234567
+ * @summary ensure that declaration annotations are not allowed on
+ *   new array expressions
+ * @author Werner Dietl
+ * @compile/fail/ref=DeclarationAnnotation.out -XDrawDiagnostics DeclarationAnnotation.java
+ */
+class DeclarationAnnotation {
+    Object e1 = new @DA int[5];
+    Object e2 = new @DA String[42];
+    Object e3 = new @DA Object();
+
+    // The declaration annotation is only allowed for
+    // an anonymous class creation.
+    Object ok = new @DA Object() { };
+}
+
+@interface DA { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,4 @@
+DeclarationAnnotation.java:10:21: compiler.err.annotation.type.not.applicable
+DeclarationAnnotation.java:11:21: compiler.err.annotation.type.not.applicable
+DeclarationAnnotation.java:12:21: compiler.err.annotation.type.not.applicable
+3 errors
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DeclarationAnnotation.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 1234567
+ * @summary ensure that declaration annotations are not allowed on
+ *   method receiver types
+ * @author Werner Dietl
+ * @compile/fail/ref=DeclarationAnnotation.out -XDrawDiagnostics DeclarationAnnotation.java
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+class DeclarationAnnotation {
+    void bad(@DA DeclarationAnnotation this) {}
+    void good(@TA DeclarationAnnotation this) {}
+}
+
+@interface DA { }
+
+@Target(ElementType.TYPE_USE)
+@interface TA { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DeclarationAnnotation.out	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,2 @@
+DeclarationAnnotation.java:14:14: compiler.err.annotation.type.not.applicable
+1 error
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/Nesting.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/Nesting.java	Fri May 17 10:13:34 2013 -0700
@@ -28,6 +28,11 @@
  * @author Werner Dietl
  * @compile Nesting.java
  */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE_USE)
 @interface A { }
 
 class Nesting {
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/StaticThings.out	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/StaticThings.out	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
-StaticThings.java:52:32: compiler.err.annotation.type.not.applicable
-StaticThings.java:54:37: compiler.err.annotation.type.not.applicable
-StaticThings.java:33:26: compiler.err.annotation.type.not.applicable
-StaticThings.java:36:28: compiler.err.annotation.type.not.applicable
-4 errors
\ No newline at end of file
+StaticThings.java:33:26: compiler.err.non-static.cant.be.ref: kindname.variable, this
+StaticThings.java:36:28: compiler.err.non-static.cant.be.ref: kindname.variable, this
+StaticThings.java:52:32: compiler.err.non-static.cant.be.ref: kindname.variable, this
+StaticThings.java:54:37: compiler.err.non-static.cant.be.ref: kindname.variable, this
+4 errors
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.java	Fri May 17 10:13:34 2013 -0700
@@ -29,6 +29,10 @@
  * @compile/fail/ref=WrongType.out -XDrawDiagnostics WrongType.java
  */
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE_USE)
 @interface A {}
 
 class WrongType {
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.out	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.out	Fri May 17 10:13:34 2013 -0700
@@ -1,9 +1,9 @@
-WrongType.java:51:15: compiler.err.cant.resolve.location: kindname.class, XYZ, , , (compiler.misc.location: kindname.class, WrongType, null)
-WrongType.java:61:27: compiler.err.doesnt.exist: Outer
-WrongType.java:62:31: compiler.err.cant.resolve.location: kindname.class, XY, , , (compiler.misc.location: kindname.class, WrongType, null)
-WrongType.java:44:23: compiler.err.incorrect.receiver.type
-WrongType.java:46:23: compiler.err.incorrect.receiver.type
-WrongType.java:59:33: compiler.err.incorrect.receiver.type
-WrongType.java:60:31: compiler.err.incorrect.receiver.type
-WrongType.java:66:28: compiler.err.incorrect.receiver.type
-8 errors
\ No newline at end of file
+WrongType.java:48:16: compiler.err.incorrect.receiver.type: WrongType, java.lang.Object
+WrongType.java:50:16: compiler.err.incorrect.receiver.type: WrongType, java.lang.Object
+WrongType.java:55:15: compiler.err.cant.resolve.location: kindname.class, XYZ, , , (compiler.misc.location: kindname.class, WrongType, null)
+WrongType.java:63:23: compiler.err.incorrect.receiver.type: WrongType.Inner, WrongType
+WrongType.java:64:24: compiler.err.incorrect.receiver.type: WrongType.Inner, java.lang.Object
+WrongType.java:65:27: compiler.err.doesnt.exist: Outer
+WrongType.java:66:31: compiler.err.cant.resolve.location: kindname.class, XY, , , (compiler.misc.location: kindname.class, WrongType, null)
+WrongType.java:70:24: compiler.err.incorrect.receiver.type: WrongType.Generics<X>, WrongType.Generics<Y>
+8 errors
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.java	Fri May 17 10:13:34 2013 -0700
@@ -5,10 +5,15 @@
  * @author Mahmood Ali
  * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
  */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
 class MissingAnnotationValue {
   void test() {
     new @A String();
   }
 }
 
+@Target(ElementType.TYPE_USE)
 @interface A { int field(); }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.out	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.out	Fri May 17 10:13:34 2013 -0700
@@ -1,2 +1,2 @@
-MissingAnnotationValue.java:10:9: compiler.err.annotation.missing.default.value: A, field
+MissingAnnotationValue.java:14:9: compiler.err.annotation.missing.default.value: A, field
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DeclarationAnnotation.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 1234567
+ * @summary ensure that declaration annotations are not allowed on
+ *   wildcards
+ * @author Werner Dietl
+ * @compile/fail/ref=DeclarationAnnotation.out -XDrawDiagnostics DeclarationAnnotation.java
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+import java.util.List;
+
+class DeclarationAnnotation {
+    List<@DA ? extends Object> bad;
+    List<@TA ? extends Object> good;
+}
+
+@interface DA { }
+
+@Target(ElementType.TYPE_USE)
+@interface TA { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DeclarationAnnotation.out	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,2 @@
+DeclarationAnnotation.java:15:10: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AnonymousClass.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+import java.lang.annotation.*;
+
+/*
+ * @test
+ * @bug 1234567
+ * @summary new type annotation location: anonymous class creation
+ * @author Werner Dietl
+ * @compile AnonymousClass.java
+ */
+class AnonymousClass {
+    Object o1 = new @TA Object() { };
+    // Declaration annotations are also allowed.
+    Object o2 = new @TA @DA Object() { };
+}
+
+@interface DA { }
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@interface TA { }
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@interface TB { }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/Lambda.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/Lambda.java	Fri May 17 10:13:34 2013 -0700
@@ -50,6 +50,13 @@
         return LambdaImpl::<@TA Object, @TB Object>new;
     }
 
+    interface LambdaInt2 {
+        void lambda(Object p1, Object p2);
+    }
+
+    LambdaInt2 getLambda() {
+        return (@TA Object x, @TB Object y) -> { @TA Object l = null; System.out.println("We have: " + (@TB Object) x); };
+    }
 }
 
 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
--- a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/MultiCatch.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/MultiCatch.java	Fri May 17 10:13:34 2013 -0700
@@ -25,7 +25,6 @@
 
 /*
  * @test
- * @ignore // syntax not sure yet.
  * @bug 8006775
  * @summary new type annotation location: multicatch
  * @author Werner Dietl
@@ -40,6 +39,8 @@
       e.toString();
     }
   }
+  /* Disabled: there is no syntax to annotate all components
+   * of the multicatch.
   void exception02() {
     try {
         System.out.println("Hello 2!");
@@ -47,18 +48,24 @@
       e.toString();
     }
   }
+  */
 }
 
 class ModifiedVars {
-    /*
-  void exception() {
+  void exception01() {
     try {
-      arrays();
-    } catch (final @A Exception e) {
+        System.out.println("Hello 1!");
+    } catch (final @B NullPointerException | @C IllegalArgumentException e) {
       e.toString();
     }
   }
-    */
+  void exception02() {
+    try {
+        System.out.println("Hello 1!");
+    } catch (@Decl @B NullPointerException | @C IllegalArgumentException e) {
+      e.toString();
+    }
+  }
 }
 
 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@@ -67,5 +74,5 @@
 @interface B { }
 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
 @interface C { }
-@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
-@interface D { }
+
+@interface Decl { }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -54,7 +54,6 @@
                " } }";
     }
 
-    /* TODO: Outer.this annotation support.
     @TADescriptions({
         @TADescription(annotation = "TA", type = METHOD_RECEIVER),
         @TADescription(annotation = "TB", type = METHOD_RETURN),
@@ -69,5 +68,21 @@
                " @TD Inner(@TC Test Test.this, @TE int b) {}" +
                " } }";
     }
-    */
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RECEIVER),
+        @TADescription(annotation = "TB", type = METHOD_RECEIVER, genericLocation = {1, 0}),
+        @TADescription(annotation = "TC", type = METHOD_RETURN),
+        @TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0}),
+        @TADescription(annotation = "TE", type = METHOD_RETURN),
+        @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
+    })
+    @TestClass("Outer$Middle$Inner")
+    public String innerClass3() {
+        return "class Outer { class Middle { class Inner {" +
+               " @TC Inner(@TA Outer. @TB Middle Middle.this) {}" +
+               " @TE Inner(@TD Middle Outer.Middle.this, @TF int b) {}" +
+               " } } }";
+    }
+
 }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java	Fri May 17 10:13:34 2013 -0700
@@ -207,7 +207,7 @@
 
         if (isSnippet) {
             // Have a few common nested types for testing
-            sb.append("class Outer { class Inner {} }");
+            sb.append("class Outer { class Inner {} class Middle { class MInner {} } }");
             sb.append("class SOuter { static class SInner {} }");
             sb.append("class GOuter<X, Y> { class GInner<X, Y> {} }");
         }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java	Fri May 17 10:13:34 2013 -0700
@@ -47,11 +47,43 @@
         @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
         @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
     })
-    public String multipleExceptions() {
+    public String multipleExceptions1() {
         return "void multipleExceptions() { " +
             "try { new Object(); } catch(@TA Exception e) { }" +
             "try { new Object(); } catch(@TB Exception e) { }" +
             "try { new Object(); } catch(@TC Exception e) { }" +
             " }";
     }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
+        @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
+        @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
+    })
+    public String multipleExceptions2() {
+        return "void multipleExceptions() { " +
+            "  try { new Object(); " +
+            "    try { new Object(); " +
+            "      try { new Object(); } catch(@TA Exception e) { }" +
+            "    } catch(@TB Exception e) { }" +
+            "  } catch(@TC Exception e) { }" +
+            "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
+        @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
+        @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
+    })
+    public String multipleExceptions3() {
+        return "void multipleExceptions() { " +
+            "  try { new Object(); " +
+            "  } catch(@TA Exception e1) { "+
+            "    try { new Object(); " +
+            "    } catch(@TB Exception e2) {" +
+            "      try { new Object(); } catch(@TC Exception e3) { }" +
+            "    }" +
+            "  }" +
+            "}";
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Initializers.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
+
+/*
+ * @test
+ * @bug 1234567
+ * @summary Test population of reference info for instance and class initializers
+ * @author Werner Dietl
+ * @compile -g Driver.java ReferenceInfoUtil.java Initializers.java
+ * @run main Driver Initializers
+ */
+public class Initializers {
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = NEW,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String instanceInit1() {
+        return "class Test { { Object o = new @TA ArrayList<@TB String>(); } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = NEW,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TD", type = NEW,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String instanceInit2() {
+        return "class Test { Object f = new @TA ArrayList<@TB String>(); " +
+                " { Object o = new @TC ArrayList<@TD String>(); } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = NEW,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String staticInit1() {
+        return "class Test { static { Object o = new @TA ArrayList<@TB String>(); } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = NEW,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TD", type = NEW,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TF", type = NEW,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String staticInit2() {
+        return "class Test { Object f = new @TA ArrayList<@TB String>(); " +
+                " static Object g = new @TC ArrayList<@TD String>(); " +
+                " static { Object o = new @TE ArrayList<@TF String>(); } }";
+    }
+
+    // TODO: test interaction with several constructors, especially non-initial constuctors.
+    // I don't think this kind of test is possible here.
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST,
+                typeIndex = 0, offset = ReferenceInfoUtil.IGNORE_VALUE),
+    })
+    public String lazyConstantCast1() {
+        return "class Test { public static final Object o = (@TA Object) null; }";
+    }
+
+}
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java	Fri May 17 10:13:34 2013 -0700
@@ -259,4 +259,30 @@
                 "}";
     }
 
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                paramIndex = 1),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                paramIndex = 1, genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TD", type = LOCAL_VARIABLE,
+                lvarOffset = ReferenceInfoUtil.IGNORE_VALUE,
+                lvarLength = ReferenceInfoUtil.IGNORE_VALUE,
+                lvarIndex = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TE", type = CAST,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0)
+    })
+    public String returnLambdaExpr1() {
+        return
+                "interface LambdaInt {" +
+                "  void lambda(Object p1, List<Object> p2);" +
+                "}" +
+                "class Test {" +
+                "  LambdaInt getLambda() {" +
+                "    return (@TA Object x, @TB List<@TC Object> y) -> { @TD Object l = null; System.out.println((@TE Object) l); };" +
+                "  }" +
+                "}";
+    }
 }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodThrows.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodThrows.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, 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
@@ -54,4 +54,24 @@
     public String interfaceMethod() {
         return "interface Test { void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception; }";
     }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = THROWS, typeIndex = 0,
+                       genericLocation = {}),
+        @TADescription(annotation = "TB", type = THROWS, typeIndex = 0,
+                       genericLocation = {1, 0}),
+        @TADescription(annotation = "TC", type = THROWS, typeIndex = 0,
+                       genericLocation = {1, 0, 1, 0}),
+        @TADescription(annotation = "TD", type = THROWS, typeIndex = 1,
+                       genericLocation = {}),
+        @TADescription(annotation = "TE", type = THROWS, typeIndex = 1,
+                       genericLocation = {1, 0}),
+        @TADescription(annotation = "TF", type = THROWS, typeIndex = 1,
+                       genericLocation = {1, 0, 1, 0})
+    })
+    public String NestedTypes() {
+        return "class Outer { class Middle { class Inner1 extends Exception {}" +
+                "  class Inner2 extends Exception{} } }" +
+                "class Test { void test() throws @TA Outer.@TB Middle.@TC Inner1, @TD Outer.@TE Middle.@TF Inner2 { } }";
+    }
 }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/MultiCatch.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/MultiCatch.java	Fri May 17 10:13:34 2013 -0700
@@ -26,7 +26,6 @@
 /*
  * @test
  * @bug 8006732 8006775
- * @ignore
  * @summary Test population of reference info for multicatch exception parameters
  * @author Werner Dietl
  * @compile -g Driver.java ReferenceInfoUtil.java MultiCatch.java
@@ -53,4 +52,16 @@
             "try { new Object(); } catch (@TA NullPointerException | @TB IndexOutOfBoundsException | @TC IllegalArgumentException e) { e.toString(); } }";
     }
 
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
+        @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
+        @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2),
+        @TADescription(annotation = "TD", type = EXCEPTION_PARAMETER, exceptionIndex = 2),
+        @TADescription(annotation = "TE", type = EXCEPTION_PARAMETER, exceptionIndex = 3),
+    })
+    public String multiCatch3() {
+        return "void multiCatch3() { " +
+            "try { new Object(); } catch (NullPointerException e1) {}" +
+            "try { new Object(); } catch (@TA @TB NullPointerException | @TC @TD IndexOutOfBoundsException | @TE IllegalArgumentException e2) { e2.toString(); } }";
+    }
 }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -831,4 +831,48 @@
                 "  }\n" +
                 "}}\n";
     }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_EXTENDS,
+                genericLocation = {}, typeIndex = -1),
+        @TADescription(annotation = "TB", type = CLASS_EXTENDS,
+                genericLocation = {3, 0}, typeIndex = -1),
+        @TADescription(annotation = "TC", type = CLASS_EXTENDS,
+                genericLocation = {3, 1}, typeIndex = -1),
+        @TADescription(annotation = "TD", type = CLASS_EXTENDS,
+                genericLocation = {1, 0}, typeIndex = -1),
+        @TADescription(annotation = "TE", type = CLASS_EXTENDS,
+                genericLocation = {1, 0, 3, 0}, typeIndex = -1),
+        @TADescription(annotation = "TF", type = CLASS_EXTENDS,
+                genericLocation = {1, 0, 3, 1}, typeIndex = -1)
+    })
+    @TestClass("GOuter$GInner$Test")
+    public String testExtends1() {
+        return "class GOuter<A, B> {\n" +
+                "  class GInner<X, Y> {\n" +
+                "    class Test extends @TA GOuter<@TB String, @TC String>.@TD GInner<@TE String, @TF String> {}" +
+                "  }" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER,
+                genericLocation = {}, paramIndex = 0),
+        @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND,
+                genericLocation = {}, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TC", type = FIELD,
+                genericLocation = {}),
+        @TADescription(annotation = "TD", type = FIELD,
+                genericLocation = {3, 0})
+    })
+    @TestClass("Test$1Nested")
+    public String testNestedInMethod1() {
+        return "class Test {\n" +
+                "  void foobar() {\n" +
+                "    class Nested<@TA X extends @TB Object> {\n" +
+                "      @TC List<@TD Object> f;\n" +
+                "    }\n" +
+                "  }" +
+                "}";
+    }
 }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/NewObjects.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/NewObjects.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, 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
@@ -75,4 +75,81 @@
         return "void eqtestObjectGeneric() { if (null == new @TA ArrayList<@TB String >()); }";
     }
 
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0}),
+        @TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String returnNewArray1() {
+        return "Object returnNewArray1() { return new @TA String @TB[1]; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0, 0, 0}),
+        @TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0}),
+    })
+    public String returnNewArray2() {
+        return "Object returnNewArray2() { return new @TA String @TB [1] @TC [2]; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0, 0, 0}),
+        @TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0, 0, 0, 1, 0}),
+        @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TD", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0}),
+    })
+    public String returnNewArray3() {
+        return "Object returnNewArray3() { return new @TA Outer. @TB Inner @TC [1] @TD [2]; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0, 0, 0}),
+        @TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0, 0, 0, 1, 0}),
+        @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0}),
+        @TADescription(annotation = "TD", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0}),
+    })
+    public String returnNewArray4() {
+        return "Object returnNewArray4() { return new @TA Outer. @TB Middle. @TC MInner @TD [1] @TE [2]; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {3, 0, 0, 0, 0, 0}),
+        @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0}),
+        @TADescription(annotation = "TD", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0}),
+        @TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {3, 0}),
+        @TADescription(annotation = "TF", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {3, 0, 0, 0}),
+    })
+    public String returnNewArray5() {
+        return "Object returnNewArray5() { return new @TA ArrayList<@TB Outer. @TC Middle. @TD MInner @TE [] @TF []>(); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0, 0, 0}),
+        @TADescription(annotation = "TB", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = {0, 0, 0, 0, 1, 0}),
+        @TADescription(annotation = "TC", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TD", type = FIELD, offset = ReferenceInfoUtil.IGNORE_VALUE,
+        genericLocation = {0, 0}),
+    })
+    public String arrayField() {
+        return "@TA Outer. @TB Inner @TC [] @TD [] f;";
+    }
 }
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/ReferenceInfoUtil.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/ReferenceInfoUtil.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, 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
@@ -28,6 +28,7 @@
 
 import com.sun.tools.classfile.Attribute;
 import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Code_attribute;
 import com.sun.tools.classfile.TypeAnnotation;
 import com.sun.tools.classfile.Field;
 import com.sun.tools.classfile.Method;
@@ -90,6 +91,20 @@
             RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
             annos.addAll(Arrays.asList(tAttr.annotations));
         }
+
+        int cindex = m.attributes.getIndex(cf.constant_pool, Attribute.Code);
+        if (cindex != -1) {
+            Attribute cattr = m.attributes.get(cindex);
+            assert cattr instanceof Code_attribute;
+            Code_attribute cAttr = (Code_attribute)cattr;
+            index = cAttr.attributes.getIndex(cf.constant_pool, name);
+            if (index != -1) {
+                Attribute attr = cAttr.attributes.get(index);
+                assert attr instanceof RuntimeTypeAnnotations_attribute;
+                RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+                annos.addAll(Arrays.asList(tAttr.annotations));
+            }
+        }
     }
 
     // test the result of Attributes.getIndex according to expectations
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Test.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,33 @@
+
+import java.util.*;
+import java.lang.annotation.*;
+
+class Test<K> { GOuter<@TC Object, String> entrySet() { return null; } }
+
+@interface A {}
+@interface B {}
+@interface C {}
+@interface D {}
+@interface E {}
+@interface F {}
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TA {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TB {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TC {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TD {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TE {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TF {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TG {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TH {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TI {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TJ {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TK {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TL {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TM {}
+
+@Repeatable(RTAs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTA {}
+@Repeatable(RTBs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTB {}
+@ContainerFor(RTA.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTAs { RTA[] value(); }
+@ContainerFor(RTB.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTBs { RTB[] value(); }
+@Target(value={ElementType.TYPE,ElementType.FIELD,ElementType.METHOD,ElementType.PARAMETER,ElementType.CONSTRUCTOR,ElementType.LOCAL_VARIABLE})
+@interface Decl {}
--- a/langtools/test/tools/javac/api/6406133/T6406133.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6406133/T6406133.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -27,6 +27,8 @@
  * @summary Compiler API ignores locale settings
  * @author  Maurizio Cimadamore
  * @library ../lib
+ * @build ToolTester
+ * @run main T6406133
  */
 
 import javax.tools.*;
--- a/langtools/test/tools/javac/api/6410643/T6410643.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6410643/T6410643.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,8 @@
  * @summary JSR 199: The method JavaCompilerTool.run fails to handle null arguments
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
+ * @run main T6410643
  */
 
 import javax.tools.JavaFileObject;
--- a/langtools/test/tools/javac/api/6411310/T6411310.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6411310/T6411310.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
  * @summary JSR 199: FileObject should support user-friendly names via getName()
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile T6411310.java
  * @run main T6411310
  */
--- a/langtools/test/tools/javac/api/6411333/T6411333.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6411333/T6411333.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
  * @summary Ensure 6400208, 6400225, and 6400267 are tested
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile T6411333.java
  * @run main T6411333
  */
--- a/langtools/test/tools/javac/api/6412656/T6412656.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6412656/T6412656.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,8 @@
  * @summary JSR 199: pass annotation processor instances to compiler
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
+ * @run main T6412656
  */
 
 import java.util.Set;
--- a/langtools/test/tools/javac/api/6415780/T6415780.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6415780/T6415780.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -28,6 +28,8 @@
  * @author  igor.tseytin@...
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
+ * @run main T6415780
  */
 
 import static javax.tools.StandardLocation.CLASS_PATH;
--- a/langtools/test/tools/javac/api/6418694/T6418694.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6418694/T6418694.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
  * @summary JSR 199: JavaFileManager.hasLocation(Location)
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile T6418694.java
  * @run main T6418694
  */
--- a/langtools/test/tools/javac/api/6421111/T6421111.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6421111/T6421111.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
  * @summary NullPointerException thrown when retrieving bounds for the type parameter
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile -Xlint:all T6421111.java
  * @run main T6421111
  */
--- a/langtools/test/tools/javac/api/6421756/T6421756.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6421756/T6421756.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
  * @summary 6421756 JSR 199: In the method JavaCompilerTool.getTask 'options' can be supplied in the place of 'classes'
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile T6421756.java
  * @run main T6421756
  */
--- a/langtools/test/tools/javac/api/6422215/T6422215.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6422215/T6422215.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,8 @@
  * @summary JSR 199: What happens if a directory is missing
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
+ * @run main T6422215
  */
 
 import java.io.File;
--- a/langtools/test/tools/javac/api/6422327/T6422327.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6422327/T6422327.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,8 @@
  * @summary JSR 199: JavaCompilerTool can compile and generate '.class' of non '.java' files
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
+ * @run main T6422327
  */
 
 import java.io.File;
--- a/langtools/test/tools/javac/api/6423003/T6423003.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6423003/T6423003.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
  * @summary JSR 199: confusing help message with compiler API
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile T6423003.java
  * @run main T6423003
  */
--- a/langtools/test/tools/javac/api/6431257/T6431257.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6431257/T6431257.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
  * @summary JSR 199: Changes to JavaFileManager to support JSR 269 Filer API
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile T6431257.java package-info.java
  * @run main T6431257 foo.bar.baz foo/bar/baz
  */
--- a/langtools/test/tools/javac/api/6437349/T6437349.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6437349/T6437349.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
  * @bug     6437349
  * @summary JSR 199: JavaFileObject.isNameCompatible() will give true with some incompatible kinds
  * @library ../lib
+ * @build ToolTester
  * @compile T6437349.java
  * @run main T6437349
  */
--- a/langtools/test/tools/javac/api/6437999/T6437999.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6437999/T6437999.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
  * @summary Unit test for encoding argument to standard file manager
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile T6437999.java
  * @run main T6437999
  */
--- a/langtools/test/tools/javac/api/6440333/T6440333.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6440333/T6440333.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
  * @summary SimpleJavaFileObject.toString() generates URI with some extra message
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile T6440333.java
  * @run main T6440333
  */
--- a/langtools/test/tools/javac/api/6440528/T6440528.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6440528/T6440528.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
  * @summary javac deposits package-info.class in bogus directory
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile T6440528.java
  * @run main T6440528
  */
--- a/langtools/test/tools/javac/api/6468404/T6468404.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6468404/T6468404.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -28,6 +28,7 @@
  * @author  jesse.glick@...
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile T6468404.java
  * @run main T6468404
  */
--- a/langtools/test/tools/javac/api/6731573/T6731573.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6731573/T6731573.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -27,6 +27,8 @@
  * @summary diagnostic output should optionally include source line
  * @author  Maurizio Cimadamore
  * @library ../lib
+ * @build ToolTester
+ * @run main T6731573
  */
 
 import java.io.*;
--- a/langtools/test/tools/javac/api/6733837/T6733837.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/6733837/T6733837.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -27,6 +27,8 @@
  * @summary Compiler API ignores locale settings
  * @author  Maurizio Cimadamore
  * @library ../lib
+ * @build ToolTester
+ * @run main T6733837
  */
 
 import java.io.StringWriter;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/TestGetElementReference.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug 8012929
+ * @summary Trees.getElement should work not only for declaration trees, but also for use-trees
+ * @build TestGetElementReference
+ * @run main TestGetElementReference
+ */
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.*;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.lang.model.element.Element;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class TestGetElementReference {
+
+    public static void main(String... args) throws IOException {
+        File source = new File(System.getProperty("test.src", "."), "TestGetElementReferenceData.java").getAbsoluteFile();
+        StandardJavaFileManager fm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
+        DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
+        JavacTask ct = (JavacTask) ToolProvider.getSystemJavaCompiler().getTask(null, null, diagnostics, Arrays.asList("-Xjcov", "-source", "1.8"), null, fm.getJavaFileObjects(source));
+        Trees trees = Trees.instance(ct);
+        CompilationUnitTree cut = ct.parse().iterator().next();
+
+        ct.analyze();
+
+        for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
+            if (d.getKind() == Diagnostic.Kind.ERROR) {
+                throw new IllegalStateException("Should have been attributed without errors: " + diagnostics.getDiagnostics());
+            }
+        }
+
+        Pattern p = Pattern.compile("/\\*getElement:(.*?)\\*/");
+        Matcher m = p.matcher(cut.getSourceFile().getCharContent(false));
+
+        while (m.find()) {
+            TreePath tp = pathFor(trees, cut, m.start() - 1);
+            Element found = trees.getElement(tp);
+            String expected = m.group(1);
+            String actual = found != null ? found.getKind() + ":" + symbolToString(found) : "<null>";
+
+            if (!expected.equals(actual)) {
+                throw new IllegalStateException("expected=" + expected + "; actual=" + actual);
+            }
+        }
+    }
+
+    private static TreePath pathFor(final Trees trees, final CompilationUnitTree cut, final int pos) {
+        final TreePath[] result = new TreePath[1];
+
+        new TreePathScanner<Void, Void>() {
+            @Override public Void scan(Tree node, Void p) {
+                if (   node != null
+                    && trees.getSourcePositions().getStartPosition(cut, node) <= pos
+                    && pos <= trees.getSourcePositions().getEndPosition(cut, node)) {
+                    result[0] = new TreePath(getCurrentPath(), node);
+                    return super.scan(node, p);
+                }
+                return null;
+            }
+        }.scan(cut, null);
+
+        return result[0];
+    }
+
+    private static String symbolToString(Element el) {
+        switch (el.getKind()) {
+            case METHOD: return symbolToString(el.getEnclosingElement()) + "." + el.toString();
+            case CONSTRUCTOR: return symbolToString(el.getEnclosingElement().getEnclosingElement()) + "." + el.toString();
+            default:
+                return el.toString();
+        }
+    }
+
+    static class TestFileObject extends SimpleJavaFileObject {
+        private final String text;
+        public TestFileObject(String text) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+        @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/TestGetElementReferenceData.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2013, 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 test;
+/*getElement:PACKAGE:test*/
+import java.lang.annotation.*;
+import static test.TestGetElementReferenceData.Sub.*;
+
+public class TestGetElementReferenceData {
+
+    private static void test() {
+        StringBuilder/*getElement:CLASS:java.lang.StringBuilder*/ sb = new/*getElement:CONSTRUCTOR:java.lang.StringBuilder()*/ StringBuilder();
+        sb/*getElement:LOCAL_VARIABLE:sb*/.append/*getElement:METHOD:java.lang.StringBuilder.append(int)*/(0);
+        sb.reverse( /*getElement:METHOD:java.lang.StringBuilder.reverse()*/);
+        java.util.List< /*getElement:INTERFACE:java.util.List*/ String> l;
+        utility/*getElement:METHOD:test.TestGetElementReferenceData.Base.utility()*/();
+        target(TestGetElementReferenceData :: test/*getElement:METHOD:test.TestGetElementReferenceData.test()*/);
+    }
+    private static void target(Runnable r) { r.run(); }
+    public static class Base {
+        public static void utility() {}
+    }
+    public static class Sub extends @TypeAnnotation( /*getElement:ANNOTATION_TYPE:test.TestGetElementReferenceData.TypeAnnotation*/) Base {
+    }
+   @Deprecated( /*getElement:ANNOTATION_TYPE:java.lang.Deprecated*/)
+    public static class TypeParam<TT/*getElement:TYPE_PARAMETER:TT*/> {
+    }
+    @Target(ElementType.TYPE_USE)
+    @interface TypeAnnotation {
+    }
+}
--- a/langtools/test/tools/javac/api/TestJavacTaskScanner.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java	Fri May 17 10:13:34 2013 -0700
@@ -27,6 +27,7 @@
  * @summary Additional functionality test of task and JSR 269
  * @author  Peter von der Ah\u00e9
  * @library ./lib
+ * @build ToolTester
  * @run main TestJavacTaskScanner TestJavacTaskScanner.java
  */
 
@@ -110,7 +111,8 @@
         DeclaredType type = (DeclaredType)task.parseType("List<String>", clazz);
         for (Element member : elements.getAllMembers((TypeElement)type.asElement())) {
             TypeMirror mt = types.asMemberOf(type, member);
-            System.out.format("%s : %s -> %s%n", member.getSimpleName(), member.asType(), mt);
+            System.out.format("type#%d: %s : %s -> %s%n",
+                numParseTypeElements, member.getSimpleName(), member.asType(), mt);
             numParseTypeElements++;
         }
     }
@@ -122,7 +124,8 @@
 
     private void testGetAllMembers(TypeElement clazz) {
         for (Element member : elements.getAllMembers(clazz)) {
-            System.out.format("%s : %s%n", member.getSimpleName(), member.asType());
+            System.out.format("elem#%d: %s : %s%n",
+                numAllMembers, member.getSimpleName(), member.asType());
             numAllMembers++;
         }
     }
@@ -160,7 +163,7 @@
         StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, encoding);
         try {
             fm.setLocation(SOURCE_PATH,  Arrays.asList(test_src));
-            fm.setLocation(CLASS_PATH,   Arrays.asList(test_classes, javac_classes));
+            fm.setLocation(CLASS_PATH,   join(test_class_path, Arrays.asList(javac_classes)));
             fm.setLocation(CLASS_OUTPUT, Arrays.asList(test_classes));
         } catch (IOException e) {
             throw new AssertionError(e);
--- a/langtools/test/tools/javac/api/guide/Test.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/guide/Test.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, 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
@@ -27,6 +27,7 @@
  * @summary Various bugs fixed while writing Compiler API Guide
  * @author  Peter von der Ah\u0081
  * @library ../lib
+ * @build ToolTester
  * @compile Test.java
  * @run main Test
  */
--- a/langtools/test/tools/javac/api/lib/ToolTester.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/api/lib/ToolTester.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.Charset;
-import java.util.Arrays;
+import java.util.*;
 import javax.tools.*;
 
 import static javax.tools.StandardLocation.CLASS_PATH;
@@ -34,6 +34,8 @@
 public class ToolTester {
     public final File test_src     = new File(System.getProperty("test.src", "."));
     public final File test_classes = new File(System.getProperty("test.classes", "."));
+    public final List<File> test_class_path = pathToFiles(System.getProperty("test.class.path"),
+                                     Arrays.asList(test_classes));
     public final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
     public final StandardJavaFileManager fm = getFileManager(tool, null, null);
     public JavaCompiler.CompilationTask task = null;
@@ -43,11 +45,36 @@
         StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, encoding);
         try {
             fm.setLocation(SOURCE_PATH,  Arrays.asList(test_src));
-            fm.setLocation(CLASS_PATH,   Arrays.asList(test_classes));
+            fm.setLocation(CLASS_PATH,   test_class_path);
             fm.setLocation(CLASS_OUTPUT, Arrays.asList(test_classes));
         } catch (IOException e) {
             throw new AssertionError(e);
         }
         return fm;
     }
+
+    protected List<File> pathToFiles(String path, List<File> defaultPath) {
+        List<File> files = new ArrayList<>();
+        for (String f: path.split(File.pathSeparator)) {
+            if (f.isEmpty())
+                continue;
+            File file = new File(f);
+            if (file.exists())
+                files.add(file);
+        }
+        if (files.isEmpty())
+            files.addAll(defaultPath);
+        return files;
+    }
+
+    protected <T> List<T> join(List<T> a, List<T> b) {
+        if (a.isEmpty())
+            return b;
+        if (b.isEmpty())
+            return a;
+        List<T> result = new ArrayList<>();
+        result.addAll(a);
+        result.addAll(b);
+        return result;
+    }
 }
--- a/langtools/test/tools/javac/defaultMethods/defaultMethodExecution/DefaultMethodRegressionTests.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/defaultMethods/defaultMethodExecution/DefaultMethodRegressionTests.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -25,7 +25,7 @@
 
 /**
  * @test
- * @ignore 8004360
+ * @ignore 8007517: DefaultMethodRegressionTests.java fail in TL
  * @bug 8003639
  * @summary convert lambda testng tests to jtreg and add them
  * @run testng DefaultMethodRegressionTests
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ArrayAndReceiver.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+// key: compiler.err.array.and.receiver
+// key: compiler.err.expected
+// key: compiler.err.expected3
+// key: compiler.err.illegal.start.of.type
+
+class ArrayAndReceiver {
+    void m(ArrayAndReceiver this[]) { }
+}
--- a/langtools/test/tools/javac/diags/examples/BadArgTypesInLambda.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/diags/examples/BadArgTypesInLambda.java	Fri May 17 10:13:34 2013 -0700
@@ -24,6 +24,9 @@
 // key: compiler.err.cant.apply.symbol
 // key: compiler.misc.no.conforming.assignment.exists
 // key: compiler.misc.bad.arg.types.in.lambda
+// key: compiler.err.prob.found.req
+// key: compiler.misc.inconvertible.types
+// options: -Xdiags:verbose
 
 class BadArgTypesInLambda {
     interface SAM {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/CompressedDiags.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+// key: compiler.err.prob.found.req
+// key: compiler.misc.inconvertible.types
+// key: compiler.note.compressed.diags
+// key: compiler.note.note
+// key: compiler.misc.count.error
+// key: compiler.err.error
+// run: backdoor
+
+class CompressedDiags {
+
+    void m(String s) { }
+
+    void test() {
+        m(1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncorrectConstructorReceiverName.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+// key: compiler.err.incorrect.constructor.receiver.name
+
+class IncorrectConstructorReceiverName {
+    class Inner {
+        Inner(IncorrectConstructorReceiverName this) { }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncorrectConstructorReceiverType.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+// key: compiler.err.incorrect.constructor.receiver.type
+
+class IncorrectConstructorReceiverType {
+    class Inner {
+        Inner(Object IncorrectConstructorReceiverType.this) { }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncorrectReceiverName.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012, 2013, 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.
+ */
+
+// key: compiler.err.incorrect.receiver.name
+
+class IncorrectReceiverName {
+    class Inner {
+        void m(Inner IncorrectReceiverName.this) { }
+    }
+}
--- a/langtools/test/tools/javac/diags/examples/KindnameConstructor.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/diags/examples/KindnameConstructor.java	Fri May 17 10:13:34 2013 -0700
@@ -28,6 +28,7 @@
 // key: compiler.misc.inconvertible.types
 // key: compiler.misc.count.error
 // key: compiler.err.error
+// options: -Xdiags:verbose
 // run: backdoor
 
 class KindnameConstructor {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ProbFoundReqFragment.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+// key: compiler.err.prob.found.req
+// key: compiler.misc.prob.found.req
+// key: compiler.misc.inconvertible.types
+// key: compiler.misc.invalid.mref
+// key: compiler.misc.kindname.method
+// key: compiler.misc.count.error
+// key: compiler.err.error
+// run: backdoor
+
+class ProbFoundReqFragment {
+
+    interface I {
+        void g(int i);
+    }
+
+    void m(String s) { }
+
+    void test() {
+        I i = this::m;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ReceiverParameterNotApplicableConstructor.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+// key: compiler.err.receiver.parameter.not.applicable.constructor.toplevel.class
+
+class ReceiverParameterNotApplicableConstructor {
+    ReceiverParameterNotApplicableConstructor(ReceiverParameterNotApplicableConstructor this) { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/VarargsAndReceiver.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+// key: compiler.err.varargs.and.receiver
+
+class VarargsAndReceiver {
+    void m(VarargsAndReceiver... this) { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doctree/DocTreePathScannerTest.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug 8009724
+ * @summary adding DocTreePath and DocTreePathScanner
+ */
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.DocTree.Kind;
+import com.sun.source.doctree.DocTreeVisitor;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.DocTreePath;
+import com.sun.source.util.DocTreePathScanner;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.tools.javac.api.JavacTool;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import javax.lang.model.element.Name;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+public class DocTreePathScannerTest {
+    public static void main(String... args) throws Exception {
+        DocTreePathScannerTest t = new DocTreePathScannerTest();
+        t.run();
+    }
+
+    void run() throws Exception {
+        List<File> files = new ArrayList<File>();
+        File testSrc = new File(System.getProperty("test.src"));
+        for (File f: testSrc.listFiles()) {
+            if (f.isFile() && f.getName().endsWith(".java"))
+                files.add(f);
+        }
+
+        JavacTool javac = JavacTool.create();
+        StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
+
+        Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
+
+        JavacTask t = javac.getTask(null, fm, null, null, null, fos);
+        DocTrees trees = DocTrees.instance(t);
+
+        Iterable<? extends CompilationUnitTree> units = t.parse();
+
+        DeclScanner ds = new DeclScanner(trees);
+        for (CompilationUnitTree unit: units) {
+            ds.scan(unit, null);
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    class DeclScanner extends TreePathScanner<Void, Void> {
+        DocTrees trees;
+        DocTreePathScanner<Void,Void> cs;
+
+        DeclScanner(DocTrees trees) {
+            this.trees = trees;
+            cs = new CommentPathScanner();
+        }
+
+        @Override
+        public Void visitClass(ClassTree tree, Void ignore) {
+            super.visitClass(tree, ignore);
+            visitDecl(tree, tree.getSimpleName());
+            return null;
+        }
+
+        @Override
+        public Void visitMethod(MethodTree tree, Void ignore) {
+            super.visitMethod(tree, ignore);
+            visitDecl(tree, tree.getName());
+            return null;
+        }
+
+        @Override
+        public Void visitVariable(VariableTree tree, Void ignore) {
+            super.visitVariable(tree, ignore);
+            visitDecl(tree, tree.getName());
+            return null;
+        }
+
+        void visitDecl(Tree tree, Name name) {
+            TreePath path = getCurrentPath();
+            DocCommentTree dc = trees.getDocCommentTree(path);
+            if (dc != null)
+                cs.scan(new DocTreePath(path, dc), null);
+        }
+    }
+
+    class CommentPathScanner extends DocTreePathScanner<Void, Void> {
+        CommentPathScanner() {}
+
+        @Override
+        public Void scan(final DocTree tree, Void ignore) {
+            if (tree != null) {
+                DocTree previous = null;
+                for (DocTree current : getCurrentPath()) {
+                    if (previous != null) {
+                        final List<DocTree> children = new ArrayList<>();
+                        current.accept(new DocTreeScanner<Void, Void>() {
+                            @Override public Void scan(DocTree node, Void p) {
+                                children.add(node);
+                                return null;
+                            }
+                        }, null);
+
+                        if (!children.contains(previous)) {
+                            error("Invalid DocTreePath for: " + tree);
+                        }
+                    }
+
+                    previous = current;
+                }
+            }
+            return super.scan(tree, ignore);
+        }
+    }
+
+}
--- a/langtools/test/tools/javac/doctree/ReferenceTest.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/doctree/ReferenceTest.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -36,6 +36,8 @@
 import com.sun.source.doctree.ReferenceTree;
 import com.sun.source.doctree.SeeTree;
 import com.sun.source.doctree.TextTree;
+import com.sun.source.util.DocTreePath;
+import com.sun.source.util.DocTreePathScanner;
 import com.sun.source.util.DocTreeScanner;
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.TreePath;
@@ -125,7 +127,7 @@
         return true;
     }
 
-    class DocCommentScanner extends DocTreeScanner<Void, Void> {
+    class DocCommentScanner extends DocTreePathScanner<Void, Void> {
         TreePath path;
         DocCommentTree dc;
 
@@ -135,7 +137,7 @@
 
         void scan() {
             dc = trees.getDocCommentTree(path);
-            scan(dc, null);
+            scan(new DocTreePath(path, dc), null);
         }
 
         @Override
@@ -158,7 +160,7 @@
         void checkReference(ReferenceTree tree, List<? extends DocTree> label) {
             String sig = tree.getSignature();
 
-            Element found = trees.getElement(path, tree);
+            Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree));
             if (found == null) {
                 System.err.println(sig + " NOT FOUND");
             } else {
--- a/langtools/test/tools/javac/generics/7034511/T7034511a.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/generics/7034511/T7034511a.java	Fri May 17 10:13:34 2013 -0700
@@ -1,11 +1,13 @@
 /*
  * @test /nodynamiccopyright/
- * @ignore backing out 7034511, see 7040883
+ * @ignore 7041019 Bogus type-variable substitution with array types with dependencies on accessibility check
  * @bug     7034511 7040883
  * @summary Loophole in typesafety
  * @compile/fail/ref=T7034511a.out -XDrawDiagnostics T7034511a.java
  */
 
+// backing out 7034511, see 7040883
+
 class T7034511a {
 
     interface A<T> {
--- a/langtools/test/tools/javac/generics/7034511/T7034511b.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/generics/7034511/T7034511b.java	Fri May 17 10:13:34 2013 -0700
@@ -1,11 +1,13 @@
 /*
  * @test /nodynamiccopyright/
- * @ignore backing out 7034511, see 7040883
+ * @ignore 7041019 Bogus type-variable substitution with array types with dependencies on accessibility check
  * @bug     7034511 7040883
  * @summary Loophole in typesafety
  * @compile/fail/ref=T7034511b.out -XDrawDiagnostics T7034511b.java
  */
 
+// backing out 7034511, see 7040883
+
 class T7034511b {
     static class MyList<E> {
         E toArray(E[] e) { return null; }
--- a/langtools/test/tools/javac/generics/OverrideBridge.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/generics/OverrideBridge.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,11 +24,13 @@
 /*
  * @test
  * @bug 6337171 6996415
- * @ignore fix has been disabled as a consequence of 6996415
+ * @ignore 6996758: Investigate better override bridges strategy
  * @summary  javac should create bridge methods when type variable bounds restricted
  * @run main OverrideBridge
  */
 
+// fix, and test, has been disabled as a consequence of 6996415
+
 import java.io.*;
 import java.net.URI;
 import java.util.ArrayList;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaInterfaceStaticField.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8006140
+ * @summary Javac NPE compiling Lambda expression on initialization expression of static field in interface
+ * @compile LambdaInterfaceStaticField.java
+ */
+
+interface LambdaInterfaceStaticField {
+  interface I {
+     int m();
+  }
+  public static final I fld = () -> 5;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaWithInterfaceSuper.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug 8010006
+ * @summary NPE in javac with interface super in lambda
+ * @compile LambdaWithInterfaceSuper.java
+ */
+
+class LambdaWithInterfaceSuper {
+
+    interface Sup {
+        default void m() {}
+    }
+
+    interface I extends Sup {
+        default void m() {
+            Runnable r = ()-> { Sup.super.m(); };
+            r.run();
+       }
+    }
+}
--- a/langtools/test/tools/javac/lambda/MethodReference66.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/lambda/MethodReference66.java	Fri May 17 10:13:34 2013 -0700
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 8009299
+ * @ignore 8013875: Incorrect vtable index being set during methodHandle creation for static
  * @summary Javac crashes when compiling method reference to static interface method
  * @run main/othervm -Xverify:none MethodReference66
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference67.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8012685
+ * @summary Spurious raw types warning when using unbound method references
+ * @compile/fail/ref=MethodReference67.out -Werror -Xlint:rawtypes -XDrawDiagnostics MethodReference67.java
+ */
+import java.util.*;
+
+class MethodReference67 {
+    interface Foo<X> {
+        void m(List<X> lx, X x);
+    }
+
+    void test() {
+        Foo<String> fs1 = List::add; //no raw warnings here!
+        Foo fs2 = List::add;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference67.out	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,7 @@
+MethodReference67.java:16:9: compiler.warn.raw.class.use: MethodReference67.Foo, MethodReference67.Foo<X>
+MethodReference67.java:16:19: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
+- compiler.err.warnings.and.werror
+- compiler.note.unchecked.filename: MethodReference67.java
+- compiler.note.unchecked.recompile
+1 error
+2 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/NoWarnOnImplicitParams.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8013222
+ * @summary Javac issues spurious raw type warnings when lambda has implicit parameter types
+ * @compile/fail/ref=NoWarnOnImplicitParams.out -Xlint:rawtypes -Werror -XDrawDiagnostics NoWarnOnImplicitParams.java
+ */
+import java.util.List;
+
+class NoWarnOnImplicitParams {
+
+    public void testRawMerge(List<String> ls) {
+        R12 r12_1 = l->"Foo";
+        R12 r12_2 = (List l)->"Foo";
+    }
+
+    interface R1 {
+        Object m(List<String> ls);
+    }
+
+    @SuppressWarnings("rawtypes")
+    interface R2 {
+        String m(List l);
+    }
+
+    interface R12 extends R1, R2 {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/NoWarnOnImplicitParams.out	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,4 @@
+NoWarnOnImplicitParams.java:13:22: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
+- compiler.err.warnings.and.werror
+1 error
+1 warning
--- a/langtools/test/tools/javac/lambda/TargetType36.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType36.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @ignore
+ * @ignore 8013404: Test awaits spec clarification
  * @bug 8003280
  * @summary Add lambda tests
  *  check that target type of cast is propagated to conditional subexpressions
--- a/langtools/test/tools/javac/lambda/TargetType53.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType53.java	Fri May 17 10:13:34 2013 -0700
@@ -26,7 +26,7 @@
  * @bug 8007464
  * @summary Add graph inference support
  *          smoke test for graph inference
- * @ignore  awaits stream API: 800NNNN
+ * @ignore  8008682: Core stream API classes
  * @compile TargetType53.java
  */
 import java.util.*;
--- a/langtools/test/tools/javac/lambda/TargetType54.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType54.java	Fri May 17 10:13:34 2013 -0700
@@ -26,7 +26,7 @@
  * @bug 8007464
  * @summary Add graph inference support
  *          smoke test for graph inference
- * @ignore  awaits stream API: 800NNNN
+ * @ignore  8008682: Core stream API classes
  * @compile TargetType54.java
  */
 import java.util.stream.*;
--- a/langtools/test/tools/javac/lambda/TargetType58.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType58.java	Fri May 17 10:13:34 2013 -0700
@@ -26,7 +26,7 @@
  * @bug 8007464
  * @summary Add graph inference support
  *          more smoke tests for graph inference
- * @ignore  awaits stream API: 800NNNN
+ * @ignore  8008682: Core stream API classes
  * @compile TargetType58.java
  */
 import java.util.*;
--- a/langtools/test/tools/javac/lambda/TargetType59.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType59.java	Fri May 17 10:13:34 2013 -0700
@@ -26,7 +26,7 @@
  * @bug 8007464
  * @summary Add graph inference support
  *          more smoke tests for graph inference
- * @ignore  awaits stream API: 800NNNN
+ * @ignore  8008682: Core stream API classes
  * @compile TargetType59.java
  */
 import java.util.*;
--- a/langtools/test/tools/javac/lambda/TargetType62.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType62.java	Fri May 17 10:13:34 2013 -0700
@@ -26,7 +26,7 @@
  * @bug 8007464
  * @summary Add graph inference support
  *          check that new wildcards inference strategy doesn't run into 7190296
- * @ignore  awaits stream API: 800NNNN
+ * @ignore  8008682: Core stream API classes
  * @compile TargetType62.java
  */
 import java.util.*;
--- a/langtools/test/tools/javac/lambda/TargetType66.out	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType66.out	Fri May 17 10:13:34 2013 -0700
@@ -1,4 +1,4 @@
 TargetType66.java:22:9: compiler.err.ref.ambiguous: g, kindname.method, g(TargetType66.SAM1), TargetType66, kindname.method, g(TargetType66.SAM2), TargetType66
-TargetType66.java:23:9: compiler.err.cant.apply.symbols: kindname.method, g, @578,{(compiler.misc.inapplicable.method: kindname.method, TargetType66, g(TargetType66.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.bad.arg.types.in.lambda: java.lang.String))),(compiler.misc.inapplicable.method: kindname.method, TargetType66, g(TargetType66.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.bad.arg.types.in.lambda: java.lang.Integer)))}
+TargetType66.java:23:9: compiler.err.cant.apply.symbols: kindname.method, g, @578,{(compiler.misc.inapplicable.method: kindname.method, TargetType66, g(TargetType66.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.bad.arg.types.in.lambda: java.lang.String, (compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Character))))),(compiler.misc.inapplicable.method: kindname.method, TargetType66, g(TargetType66.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.bad.arg.types.in.lambda: java.lang.Integer, (compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.Character)))))}
 TargetType66.java:24:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Character)
 3 errors
--- a/langtools/test/tools/javac/lambda/bytecode/TestLambdaBytecode.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/lambda/bytecode/TestLambdaBytecode.java	Fri May 17 10:13:34 2013 -0700
@@ -306,7 +306,7 @@
     String makeIndyType(int id) {
         StringBuilder buf = new StringBuilder();
         buf.append("(");
-        if (!mk2.isStatic() || mk1.inInterface()) {
+        if (!mk2.isStatic()) {
             buf.append(String.format("LTest%d;", id));
         }
         buf.append(")Ljava/lang/Runnable;");
--- a/langtools/test/tools/javac/lambda/lambdaExecution/InInterface.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/lambda/lambdaExecution/InInterface.java	Fri May 17 10:13:34 2013 -0700
@@ -26,6 +26,7 @@
 /**
  * @test
  * @bug 8003639
+ * @ignore 8013875: Incorrect vtable index being set during methodHandle creation for static
  * @summary convert lambda testng tests to jtreg and add them
  * @run testng InInterface
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/TreeMakerParamsIsGoofy.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/**
+ * @test
+ * @bug 8014023
+ * @summary When a method reference to a local class constructor is contained
+ *          in a method whose number of parameters matches the number of
+ *          constructor parameters compilation fails
+ * @compile TreeMakerParamsIsGoofy.java
+ * @run main TreeMakerParamsIsGoofy
+ */
+
+public class TreeMakerParamsIsGoofy {
+
+    interface III { }
+
+    interface UO {
+        III m(III x);
+    }
+
+    public static void main(String[] args) {
+        class BA implements III {
+            BA(III b) {
+            }
+        }
+
+        ts(BA::new);
+    }
+
+    static void ts(UO ba) {
+    }
+}
--- a/langtools/test/tools/javac/lib/DPrinter.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/lib/DPrinter.java	Fri May 17 10:13:34 2013 -0700
@@ -469,6 +469,7 @@
                     indent(+1);
                     printSymbol("tsym", type.tsym, Details.SUMMARY);
                     printObject("constValue", type.constValue(), Details.SUMMARY);
+                    printObject("annotations", type.getAnnotationMirrors(), Details.SUMMARY);
                     type.accept(typeVisitor, null);
                     indent(-1);
             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Pos11.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2010, 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug     8013163
+ * @author  sogoel
+ * @summary Test multiple nested multi-catch blocks with Exception hierarchies
+ * @run main Pos11
+ */
+
+/*
+ * For this test, exception hierarchy used:
+ *
+ *           Throwable
+ *             /   \
+ *      Exception  Error
+ *       |    |      |
+ *       A    B      D
+ *            |
+ *            C
+ *            |
+ *            E
+ * As an exception is thrown within a nested try-catch block, outer catch blocks
+ * will catch an exception or its child exceptions, so the same exception can
+ * be caught and rethrown multiple times.
+ */
+
+public class Pos11 {
+
+    public static String results = "";
+    public static String sExpected = "-AB:A-AB:B-CD:C-AB:C-CD:D-Throwable:D-CD:E" +
+            "-AB:E-Exception:Exception-Throwable:Exception";
+
+    enum TestExceptions {
+        A("A"),
+        B("B"),
+        C("C"),
+        D("D"),
+        E("E"),
+        U("U");
+
+        String exType;
+        TestExceptions(String type) {
+            this.exType = type;
+        }
+    }
+
+    public static void main(String... args) {
+        Pos11 pos11 = new Pos11();
+        for(TestExceptions t : TestExceptions.values()) {
+            pos11.rethrower(t.exType);
+        }
+        if (results.compareTo(sExpected) != 0)
+            throw new RuntimeException("FAIL: final strings did not match:\n"
+                    + results + "!=\n" + sExpected);
+        System.out.println("PASS");
+    }
+
+    void rethrower(String T) {
+        try { /* try1 */
+            try { /* try2 */
+                try { /* try3 */
+                    try { /* try4 */
+                        switch (T) {
+                        case "A":
+                            throw new A();
+                        case "B":
+                            throw new B();
+                        case "C":
+                            throw new C();
+                        case "D":
+                            throw new D();
+                        case "E":
+                            throw new E();
+                        default:
+                            throw new Exception(
+                                    new Throwable());
+                        }
+                    } catch ( final C|D cd) {
+                        results=results.concat("-CD:" + cd.getClass().getSimpleName());
+                        throw cd;
+                    }
+                } catch (final A|B ab) {
+                    results=results.concat("-AB:" + ab.getClass().getSimpleName());
+                }
+            } catch (final Exception e ) {
+                results=results.concat("-Exception:" + e.getClass().getSimpleName());
+                throw e;
+            }
+        } catch (Throwable t) {
+            results=results.concat("-Throwable:" + t.getClass().getSimpleName());
+        }
+    }
+
+    // Test Exception
+    static class A extends Exception {}
+
+    // Test Exception
+    static class B extends Exception {}
+
+    // Test Exception
+    static class C extends B {}
+
+    // Not a descendant of Exception
+    static class D extends Error {}
+
+    // Test Exception
+    static class E extends C {}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Pos12.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2010, 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug     8013163
+ * @author  sogoel
+ * @summary Child exception can be caught in a parents catch block but not sibling exceptions.
+ * @run main Pos12
+ */
+
+/*
+ * For this test:
+ *    RuntimeException
+ *    |
+ *    A
+ *   / \
+ *  Ab Ac
+ * This test throws an Ab and catches it as an A(parent).
+ * The exception, although catch as an A, is rethrown and eventually
+ * caught as an Ab. Before that it is NOT caught as an Ac.
+ */
+
+public class Pos12 {
+
+    public static void main(String... args) {
+        try {
+            new Pos12().test();
+        } catch (A exception) {
+            try {
+                try {
+                    throw exception; // used to throw A, now throws Ab
+                } catch (Ac cException) { // This should NOT catch sibling exception Ab
+                    throw new RuntimeException("FAIL: Should not be caught in catch Ac");
+                }
+            } catch (Ab | Ac bcException) {
+                if (bcException instanceof Ac) {
+                    throw new RuntimeException("FAIL: Sibling exception Ab not caught as expected");
+                } else if (bcException instanceof Ab) {
+                    System.out.println("PASS");
+                }
+            }
+        }
+    }
+
+    public void test() { throw new Ab(); }
+
+    static class A extends RuntimeException {}
+
+    // Test class
+    static class Ab extends A {}
+
+    // Test class
+    static class Ac extends A {}
+}
+
--- a/langtools/test/tools/javac/nativeHeaders/NativeHeaderTest.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/nativeHeaders/NativeHeaderTest.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7150368 8003412
+ * @bug 7150368 8003412 8000407
  * @summary javac should include basic ability to generate native headers
  */
 
@@ -125,17 +125,6 @@
     }
 
     @Test
-    void oldAnnoTest(RunKind rk, GenKind gk) throws Exception {
-        List<File> files = new ArrayList<File>();
-        files.add(createFile("p/C.java",
-                "@javax.tools.annotation.GenerateNativeHeader class C { }"));
-
-        Set<String> expect = createSet("C.h");
-
-        test(rk, gk, files, expect);
-    }
-
-    @Test
     void annoTest(RunKind rk, GenKind gk) throws Exception {
         List<File> files = new ArrayList<File>();
         files.add(createFile("p/C.java",
@@ -147,18 +136,6 @@
     }
 
     @Test
-    void oldAnnoNestedClassTest(RunKind rk, GenKind gk) throws Exception {
-        List<File> files = new ArrayList<File>();
-        files.add(createFile("p/C.java",
-                "class C { @javax.tools.annotation.GenerateNativeHeader class Inner { } }"));
-
-        Set<String> expect = createSet("C_Inner.h");
-        if (gk == GenKind.FULL) expect.add("C.h");
-
-        test(rk, gk, files, expect);
-    }
-
-    @Test
     void annoNestedClassTest(RunKind rk, GenKind gk) throws Exception {
         List<File> files = new ArrayList<File>();
         files.add(createFile("p/C.java",
--- a/langtools/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7150368 8003412
+ * @bug 7150368 8003412 8000407
  * @summary javac should include basic ability to generate native headers
  */
 
--- a/langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass2.java	Thu May 16 12:16:07 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-
-import javax.tools.annotation.GenerateNativeHeader;
-
-@GenerateNativeHeader
-public class TestClass2 {
-    byte b;
-    short s;
-    int i;
-    long l;
-    float f;
-    double d;
-    Object o;
-    String t;
-}
--- a/langtools/test/tools/javac/nativeHeaders/javahComparison/TestClass3.java	Thu May 16 12:16:07 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-
-import javax.tools.annotation.GenerateNativeHeader;
-
-@GenerateNativeHeader
-public class TestClass3 {
-    public int tc3;
-
-    public class Inner1 {
-        public int tc3i1;
-
-        public class Inner1A {
-            public int tc3i1i1a;
-        }
-
-        public class Inner1B {
-            public int tc3i1i1b;
-        }
-    }
-
-    public class Inner2 {
-        public int tc321;
-
-        public class Inner2A {
-            public int tc3i2i2a;
-        }
-
-        public class Inner2B {
-            public int tc3i2i2b;
-        }
-    }
-}
-
--- a/langtools/test/tools/javac/plugin/showtype/Test.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/plugin/showtype/Test.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -23,7 +23,7 @@
 
 /**
  *  @test
- *  @bug 8001098 8004961
+ *  @bug 8001098 8004961 8004082
  *  @summary Provide a simple light-weight "plug-in" mechanism for javac
  */
 
--- a/langtools/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedA1Test.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedA1Test.java	Fri May 17 10:13:34 2013 -0700
@@ -22,13 +22,13 @@
  */
 
 /*
- * @ignore
  * @test
  * @bug     8004822
  * @author  mnunez
  * @summary Language model api test basics for repeating annotations
  * @library /tools/javac/lib
  * @library supportingAnnotations
+ * @ignore  8013407: test failures for repeating annotations
  * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
  * @compile -processor ElementRepAnnoTester -proc:only
  * MixRepeatableAndOfficialContainerInheritedA1Test.java
--- a/langtools/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedB1Test.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedB1Test.java	Fri May 17 10:13:34 2013 -0700
@@ -22,13 +22,13 @@
  */
 
 /*
- * @ignore
  * @test
  * @bug     8004822
  * @author  mnunez
  * @summary Language model api test basics for repeating annotations
  * @library /tools/javac/lib
  * @library supportingAnnotations
+ * @ignore  8013407: test failures for repeating annotations
  * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
  * @compile -processor ElementRepAnnoTester -proc:only
  * MixRepeatableAndOfficialContainerInheritedB1Test.java
--- a/langtools/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedB2Test.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedB2Test.java	Fri May 17 10:13:34 2013 -0700
@@ -22,13 +22,13 @@
  */
 
 /*
- * @ignore
  * @test
  * @bug     8004822
  * @author  mnunez
  * @summary Language model api test basics for repeating annotations
  * @library /tools/javac/lib
  * @library supportingAnnotations
+ * @ignore  8013407: test failures for repeating annotations
  * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
  * @compile -processor ElementRepAnnoTester -proc:only
  * MixRepeatableAndOfficialContainerInheritedB2Test.java
--- a/langtools/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOverrideATest.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOverrideATest.java	Fri May 17 10:13:34 2013 -0700
@@ -22,13 +22,13 @@
  */
 
 /*
- * @ignore
  * @test
  * @bug     8004822
  * @author  mnunez
  * @summary Language model api test basics for repeating annotations
  * @library /tools/javac/lib
  * @library supportingAnnotations
+ * @ignore  8013407: test failures for repeating annotations
  * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
  * @compile -processor ElementRepAnnoTester -proc:only RepeatableOverrideATest.java
  */
--- a/langtools/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOverrideBTest.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOverrideBTest.java	Fri May 17 10:13:34 2013 -0700
@@ -22,13 +22,13 @@
  */
 
 /*
- * @ignore
  * @test
  * @bug     8004822
  * @author  mnunez
  * @summary Language model api test basics for repeating annotations
  * @library /tools/javac/lib
  * @library supportingAnnotations
+ * @ignore  8013407: test failures for repeating annotations
  * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
  * @compile -processor ElementRepAnnoTester -proc:only RepeatableOverrideBTest.java
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/type/BasicAnnoTests.java	Fri May 17 10:13:34 2013 -0700
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug     1234567
+ * @summary Annotations on types
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor DPrinter BasicAnnoTests
+ * @compile/process -processor BasicAnnoTests -proc:only BasicAnnoTests.java
+ */
+
+import java.io.PrintWriter;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.AnnotatedConstruct;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.AnnotationValue;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.ArrayType;
+import javax.lang.model.type.ExecutableType;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.type.TypeVariable;
+import javax.lang.model.type.WildcardType;
+import javax.tools.Diagnostic.Kind;
+
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+
+/**
+ * The test scans this file looking for test cases annotated with @Test.
+ */
+public class BasicAnnoTests extends JavacTestingAbstractProcessor {
+    DPrinter dprinter;
+    PrintWriter out;
+    boolean verbose = true;
+
+    @Override
+    public void init(ProcessingEnvironment pEnv) {
+        super.init(pEnv);
+        dprinter = new DPrinter(((JavacProcessingEnvironment) pEnv).getContext());
+        out = dprinter.out;
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        TestElementScanner s = new TestElementScanner();
+        for (Element e: roundEnv.getRootElements()) {
+            s.scan(e);
+        }
+        return true;
+    }
+
+    void error(Element e, String msg) {
+        messager.printMessage(Kind.ERROR, msg, e);
+        errors++;
+    }
+
+    int errors;
+
+    /**
+     * Scan an element looking for declarations annotated with @Test.
+     * Run a TestTypeScanner on the annotations that are found.
+     */
+    class TestElementScanner extends ElementScanner<Void,Void> {
+        public Void scan(Element elem, Void ignore) {
+            AnnotationMirror test = getAnnotation(elem, Test.class.getName().replace('$', '.'));
+            if (test != null) {
+                out.println("Test: " + elem + " " + test);
+                TestTypeScanner s = new TestTypeScanner(elem, test);
+                s.scan(elem.asType(), null);
+                if (getPosn(test) >= s.count)
+                    error(elem, "position " + getPosn(test) + " not found");
+                if (!s.found) {
+                    dprinter.printSymbol("element", (Symbol) elem);
+                    dprinter.printType("type", (Type) elem.asType());
+                }
+                out.println();
+            }
+            return super.scan(elem, ignore);
+        }
+    }
+
+    /**
+     * Scan the type of an element, looking for an annotation
+     * to match the expected annotation specified in the @Test annotation.
+     */
+    class TestTypeScanner extends TypeScanner<Void, Void> {
+        Element elem;
+        AnnotationMirror test;
+        int count = 0;
+        boolean found = false;
+
+        TestTypeScanner(Element elem, AnnotationMirror test) {
+            this.elem = elem;
+            this.test = test;
+        }
+
+        @Override
+        Void scan(TypeMirror t, Void ignore) {
+            if (t == null)
+                return DEFAULT_VALUE;
+            if (verbose)
+                out.println("scan " + count + ": " + t);
+            if (count == getPosn(test)) {
+                String annoType = getAnnoType(test);
+                AnnotationMirror anno = getAnnotation(t, annoType);
+                if (anno == null) {
+                    error(elem, "annotation not found on " + count + ": " + t);
+                } else {
+                    String v = getValue(anno, "value").toString();
+                    if (v.equals(getExpect(test))) {
+                        out.println("found " + anno + " as expected");
+                        found = true;
+                    } else {
+                        error(elem, "Unexpected value: " + v + ", expected: " + getExpect(test));
+                    }
+                }
+            }
+            count++;
+            return super.scan(t, ignore);
+        }
+    }
+
+    /** Get the position value from an @Test annotation mirror. */
+    static int getPosn(AnnotationMirror test) {
+        AnnotationValue v = getValue(test, "posn");
+        return (Integer) v.getValue();
+    }
+
+    /** Get the expect value from an @Test annotation mirror. */
+    static String getExpect(AnnotationMirror test) {
+        AnnotationValue v = getValue(test, "expect");
+        return (String) v.getValue();
+    }
+
+    /** Get the annoType value from an @Test annotation mirror. */
+    static String getAnnoType(AnnotationMirror test) {
+        AnnotationValue v = getValue(test, "annoType");
+        TypeMirror m = (TypeMirror) v.getValue();
+        return m.toString();
+    }
+
+    /**
+     * Get a specific annotation mirror from an annotated construct.
+     */
+    static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) {
+        for (AnnotationMirror m: e.getAnnotationMirrors()) {
+            TypeElement te = (TypeElement) m.getAnnotationType().asElement();
+            if (te.getQualifiedName().contentEquals(name)) {
+                return m;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Get a specific value from an annotation mirror.
+     */
+    static AnnotationValue getValue(AnnotationMirror anno, String name) {
+        Map<? extends ExecutableElement, ? extends AnnotationValue> map = anno.getElementValues();
+        for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> e: map.entrySet()) {
+            if (e.getKey().getSimpleName().contentEquals(name)) {
+                return e.getValue();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * The Language Model API does not provide a type scanner, so provide
+     * one sufficient for our needs.
+     */
+    static class TypeScanner<R, P> extends SimpleTypeVisitor<R, P> {
+        @Override
+        public R visitArray(ArrayType t, P p) {
+            scan(t.getComponentType(), p);
+            return super.visitArray(t, p);
+        }
+
+        @Override
+        public R visitExecutable(ExecutableType t, P p) {
+            scan(t.getReceiverType());
+            //out.println("  params: " + t.getParameterTypes());
+            scan(t.getParameterTypes(), p);
+            //out.println("  return: " + t.getReturnType());
+            scan(t.getReturnType(), p);
+            //out.println("  throws: " + t.getThrownTypes());
+            scan(t.getThrownTypes(), p);
+            return super.visitExecutable(t, p);
+        }
+
+        @Override
+        public R visitTypeVariable(TypeVariable t, P p) {
+            scan(t.getLowerBound(), p);
+            scan(t.getUpperBound(), p);
+            return super.visitTypeVariable(t, p);
+        }
+
+        @Override
+        public R visitWildcard(WildcardType t, P p) {
+            scan(t.getExtendsBound(), p);
+            scan(t.getSuperBound(), p);
+            return super.visitWildcard(t, p);
+        }
+
+        R scan(TypeMirror t) {
+            return scan(t, null);
+        }
+
+        R scan(TypeMirror t, P p) {
+            return (t == null) ? DEFAULT_VALUE : t.accept(this, p);
+        }
+
+        R scan(Iterable<? extends TypeMirror> iter, P p) {
+            if (iter == null)
+                return DEFAULT_VALUE;
+            R result = DEFAULT_VALUE;
+            for (TypeMirror t: iter)
+                result = scan(t, p);
+            return result;
+        }
+    }
+
+    /** Annotation to identify test cases. */
+    @interface Test {
+        /** Where to look for the annotation, expressed as a scan index. */
+        int posn();
+        /** The annotation to look for. */
+        Class<? extends Annotation> annoType();
+        /** The string representation of the annotation's value. */
+        String expect();
+    }
+
+    /** Type annotation to use in test cases. */
+    @Target(ElementType.TYPE_USE)
+    public @interface TA {
+        int value();
+    }
+
+    @Test(posn=0, annoType=TA.class, expect="1")
+    public @TA(1) int f1;
+
+    @Test(posn=0, annoType=TA.class, expect="2")
+    public int @TA(2) [] f2;
+
+    @Test(posn=1, annoType=TA.class, expect="3")
+    public @TA(3) int [] f3;
+
+    @Test(posn=1, annoType=TA.class, expect="4")
+    public int m1(@TA(4) float a) throws Exception { return 0; }
+
+    @Test(posn=2, annoType=TA.class, expect="5")
+    public @TA(5) int m2(float a) throws Exception { return 0; }
+
+    @Test(posn=3, annoType=TA.class, expect="6")
+    public int m3(float a) throws @TA(6) Exception { return 0; }
+}
--- a/langtools/test/tools/javac/profiles/ProfileOptionTest.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/profiles/ProfileOptionTest.java	Fri May 17 10:13:34 2013 -0700
@@ -179,7 +179,7 @@
                 javax.xml.XMLConstants.class);
 
         init(Profile.COMPACT3,
-                javax.script.Bindings.class,
+                javax.sql.rowset.Predicate.class,
                 com.sun.security.auth.PolicyFile.class); // specifically included in 3
 
         init(Profile.DEFAULT,
--- a/langtools/test/tools/javac/tree/SourceTreeScannerTest.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javac/tree/SourceTreeScannerTest.java	Fri May 17 10:13:34 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
--- a/langtools/test/tools/javap/output/RepeatingTypeAnnotations.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javap/output/RepeatingTypeAnnotations.java	Fri May 17 10:13:34 2013 -0700
@@ -121,280 +121,307 @@
      */
 
     @TestCase
-    @ignore // 8008082:missing type annotation for cast
     public static class TC1 extends RepeatingTypeAnnotations {
         public TC1() {
-            setSrc("    static String so = \"hello world\";",
+            setSrc(" /* TC1 */ ",
+                   "    static String so = \"hello world\";",
                    "    public @A @A @A Object o = (@A @A @A String) Test.so;");
             verify("RuntimeInvisibleTypeAnnotations",
                    "0: #25(#26=[@#27(),@#27(),@#27()]): FIELD",
-                   "1: #25(#26=[@#27(),@#27(),@#27()]): CAST, offset=5");
+                   "0: #25(#26=[@#27(),@#27(),@#27()]): CAST, offset=5, type_index=0");
         }
     }
 
     @TestCase
     public static class TC2 extends RepeatingTypeAnnotations {
         public TC2() {
-            setSrc("    static String so = \"hello world\";",
+            setSrc(" /* TC2 */ ",
+                   "    static String so = \"hello world\";",
                    "    public @A @B @A Object o = (@B @A @B String) Test.so;");
             verify("RuntimeInvisibleTypeAnnotations",
                    "0: #25(#26=[@#27(),@#27()]): FIELD",
                    "1: #28(): FIELD",
-                   "2: #29(#26=[@#28(),@#28()]): CAST, offset=5",
-                   "3: #27(): CAST, offset=5");
+                   "0: #36(#26=[@#28(),@#28()]): CAST, offset=5, type_index=0",
+                   "1: #27(): CAST, offset=5, type_index=0");
         }
     }
 
     @TestCase
     public static class TC3 extends RepeatingTypeAnnotations {
         public TC3() {
-            setSrc("    static String so = \"hello world\";",
+            setSrc(" /* TC3 */ ",
+                   "    static String so = \"hello world\";",
                    "    public @A @A @C Object o = (@B @C @B String) Test.so;");
-            verify("RuntimeInvisibleTypeAnnotations",
+            verify("RuntimeVisibleTypeAnnotations",
+                   "RuntimeInvisibleTypeAnnotations",
                    "0: #25(): FIELD",
-                   "1: #25(): CAST, offset=5",
-                   "RuntimeVisibleTypeAnnotations",
                    "0: #27(#28=[@#29(),@#29()]): FIELD",
-                   "1: #30(#28=[@#31(),@#31()]): CAST, offset=5");
+                   "0: #25(): CAST, offset=5, type_index=0",
+                   "0: #37(#28=[@#38(),@#38()]): CAST, offset=5, type_index=0");
         }
     }
 
     @TestCase
     public static class TC4 extends RepeatingTypeAnnotations {
         public TC4() {
-            setSrc("    static String so = \"hello world\";",
+            setSrc(" /* TC4 */ ",
+                   "    static String so = \"hello world\";",
                    "    public @A @B @C Object o = (@C @B @A String) Test.so;");
             verify("RuntimeInvisibleTypeAnnotations",
                    "RuntimeVisibleTypeAnnotations",
                    "0: #25(): FIELD",
-                   "1: #25(): CAST, offset=5",
                    "0: #27(): FIELD",
                    "1: #28(): FIELD",
-                   "2: #28(): CAST, offset=5",
-                   "3: #27(): CAST, offset=5");
+                   "0: #25(): CAST, offset=5, type_index=0",
+                   "0: #28(): CAST, offset=5, type_index=0",
+                   "1: #27(): CAST, offset=5, type_index=0");
         }
     }
 
     @TestCase
-    @ignore // 8008082:missing type annotation for cast
     public static class TC5 extends RepeatingTypeAnnotations {
         public TC5() {
-            setSrc("    static String so = \"hello world\";",
+            setSrc(" /* TC5 */ ",
+                   "    static String so = \"hello world\";",
                    "    public static @A @A @A Object o = (@B @B @B String) Test.so;");
             verify("RuntimeInvisibleTypeAnnotations",
                    "0: #25(#26=[@#27(),@#27(),@#27()]): FIELD",
-                   "1: #28(#26=[@#29(),@#29(),@#29()]): CAST, offset=5, type_index=0");
+                   "0: #36(#26=[@#37(),@#37(),@#37()]): CAST, offset=5, type_index=0");
         }
     }
 
     @TestCase
     public static class TC6 extends RepeatingTypeAnnotations {
         public TC6() {
-            setSrc("    static String so = \"hello world\";",
+            setSrc(" /* TC6 */ ",
+                   "    static String so = \"hello world\";",
                    "    public static @A @B @A Object o = (@B @A @B String) Test.so;");
             verify("RuntimeInvisibleTypeAnnotations",
                    "0: #25(#26=[@#27(),@#27()]): FIELD",
                    "1: #28(): FIELD",
-                   "2: #29(#26=[@#28(),@#28()]): CAST, offset=5",
-                   "3: #27(): CAST, offset=5");
+                   "0: #37(#26=[@#28(),@#28()]): CAST, offset=5, type_index=0",
+                   "1: #27(): CAST, offset=5, type_index=0");
         }
     }
 
     @TestCase
     public static class TC7 extends RepeatingTypeAnnotations {
         public TC7() {
-            setSrc("    static String so = \"hello world\";",
+            setSrc(" /* TC7 */ ",
+                   "    static String so = \"hello world\";",
                    "    public static @A @A @C Object o = (@B @C @B String) Test.so;");
-            verify("RuntimeInvisibleTypeAnnotations",
-                   "RuntimeVisibleTypeAnnotations",
+            verify("RuntimeVisibleTypeAnnotations",
+                   "RuntimeInvisibleTypeAnnotations",
                    "0: #25(): FIELD",
-                   "1: #25(): CAST, offset=5",
                    "0: #27(#28=[@#29(),@#29()]): FIELD",
-                   "1: #30(#28=[@#31(),@#31()]): CAST, offset=5");
+                   "0: #25(): CAST, offset=5, type_index=0",
+                   "0: #38(#28=[@#39(),@#39()]): CAST, offset=5, type_index=0");
         }
     }
 
     @TestCase
     public static class TC8 extends RepeatingTypeAnnotations {
         public TC8() {
-            setSrc("    static String so = \"hello world\";",
+            setSrc(" /* TC8 */ ",
+                   "    static String so = \"hello world\";",
                    "    public static @A @B @C Object o = (@C @B @A String) Test.so;");
-            verify("RuntimeInvisibleTypeAnnotations",
-                   "RuntimeVisibleTypeAnnotations",
+
+            verify("RuntimeVisibleTypeAnnotations",
+                   "RuntimeInvisibleTypeAnnotations",
                    "0: #25(): FIELD",
-                   "1: #25(): CAST, offset=5",
                    "0: #27(): FIELD",
                    "1: #28(): FIELD",
-                   "2: #28(): CAST, offset=5",
-                   "3: #27(): CAST, offset=5");
+                   "0: #25(): CAST, offset=5, type_index=0",
+                   "0: #28(): CAST, offset=5, type_index=0",
+                   "1: #27(): CAST, offset=5, type_index=0");
         }
     }
 
     @TestCase
-    @ignore // 8008082:missing type annotation for cast
     public static class TC9 extends RepeatingTypeAnnotations {
         public TC9() {
-            setSrc("    public Test(@A @A @A Object o, @A int i, long l) {",
+            setSrc(" /* TC9 */ ",
+                   "    public Test(@A @A @A Object o, @A int i, long l) {",
                    "        @A @A @A String ls = (@B @B @B String) o;",
                    "    }");
             verify("RuntimeInvisibleTypeAnnotations",
-                   "0: #34(#35=[@#36(),@#36(),@#36()]): METHOD_FORMAL_PARAMETER, param_index=0",
-                   "1: #36(): METHOD_FORMAL_PARAMETER, param_index=1",
-                   "2: #37(#35=[@#38(),@#38(),@#38()]): CAST, offset=4, type_index=0",
-                   "3: #34(#35=[@#36(),@#36(),@#36()]): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}");
+                   "0: #34(#35=[@#36(),@#36(),@#36()]): CAST, offset=4, type_index=0",
+                   "1: #37(#35=[@#38(),@#38(),@#38()]): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
+                   "RuntimeInvisibleTypeAnnotations",
+                   "0: #37(#35=[@#38(),@#38(),@#38()]): METHOD_FORMAL_PARAMETER, param_index=0",
+                   "1: #38(): METHOD_FORMAL_PARAMETER, param_index=1");
         }
     }
 
     @TestCase
     public static class TC10 extends RepeatingTypeAnnotations {
         public TC10() {
-            setSrc("    public Test(@A @A @B Object o, @A @B int i, long l) {",
+            setSrc(" /* TC10 */ ",
+                   "    public Test(@A @A @B Object o, @A @B int i, long l) {",
                    "        @A @A @B String ls = (@B @A @B String) o;",
                    "    }");
-            verify("RuntimeInvisibleTypeAnnotations:",
-                   "0: #34(#35=[@#36(),@#36()]): METHOD_FORMAL_PARAMETER, param_index=0",
-                   "1: #37(): METHOD_FORMAL_PARAMETER, param_index=0",
-                   "2: #36(): METHOD_FORMAL_PARAMETER, param_index=1",
-                   "3: #37(): METHOD_FORMAL_PARAMETER, param_index=1",
-                   "4: #38(#35=[@#37(),@#37()]): CAST, offset=4, type_index=0",
-                   "5: #36(): CAST, offset=4, type_index=0",
-                   "6: #34(#35=[@#36(),@#36()]): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
-                   "7: #37(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}");
+            verify("RuntimeInvisibleTypeAnnotations",
+                   "0: #34(#35=[@#36(),@#36()]): CAST, offset=4, type_index=0",
+                   "1: #37(): CAST, offset=4, type_index=0",
+                   "2: #38(#35=[@#37(),@#37()]): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
+                   "3: #36(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
+                   "RuntimeInvisibleTypeAnnotations",
+                   "0: #38(#35=[@#37(),@#37()]): METHOD_FORMAL_PARAMETER, param_index=0",
+                   "1: #36(): METHOD_FORMAL_PARAMETER, param_index=0",
+                   "2: #37(): METHOD_FORMAL_PARAMETER, param_index=1",
+                   "3: #36(): METHOD_FORMAL_PARAMETER, param_index=1");
         }
     }
 
     @TestCase
     public static class TC11 extends RepeatingTypeAnnotations {
         public TC11() {
-            setSrc("    public Test(@C @C @A Object o, @A @B int i, long l) {",
+            setSrc(" /* TC11 */ ",
+                   "    public Test(@C @C @A Object o, @A @B int i, long l) {",
                    "        @C @C @A String ls = (@A @A @C String) o;",
                    "    }");
-            verify("RuntimeInvisibleTypeAnnotations",
-                   "RuntimeVisibleTypeAnnotations",
-                   "0: #34(#35=[@#36(),@#36()]): METHOD_FORMAL_PARAMETER, param_index=0",
-                   "1: #36(): CAST, offset=4",
-                   "2: #34(#35=[@#36(),@#36()]): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
-                   "0: #38(): METHOD_FORMAL_PARAMETER, param_index=0",
-                   "1: #38(): METHOD_FORMAL_PARAMETER, param_index=1",
-                   "2: #39(): METHOD_FORMAL_PARAMETER, param_index=1",
-                   "3: #40(#35=[@#38(),@#38()]): CAST, offset=4",
-                   "4: #38(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}");
+            verify("RuntimeVisibleTypeAnnotations",
+                   "RuntimeInvisibleTypeAnnotations",
+                   "0: #34(): CAST, offset=4, type_index=0",
+                   "1: #35(#36=[@#34(),@#34()]): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
+                   "0: #38(#36=[@#39(),@#39()]): CAST, offset=4, type_index=0",
+                   "1: #39(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
+                   "0: #35(#36=[@#34(),@#34()]): METHOD_FORMAL_PARAMETER, param_index=0",
+                   "0: #39(): METHOD_FORMAL_PARAMETER, param_index=0",
+                   "1: #39(): METHOD_FORMAL_PARAMETER, param_index=1",
+                   "2: #40(): METHOD_FORMAL_PARAMETER, param_index=1");
         }
     }
 
     @TestCase
     public static class TC12 extends RepeatingTypeAnnotations {
         public TC12() {
-            setSrc("    public Test(@A @B @C Object o, @A @C int i, long l) {",
+            setSrc(" /* TC12 */ ",
+                   "    public Test(@A @B @C Object o, @A @C int i, long l) {",
                    "        @A @B @C String ls = (@C @A @B String) o;",
                    "    }");
-            verify("RuntimeInvisibleTypeAnnotations",
-                   "RuntimeVisibleTypeAnnotations",
+            verify("RuntimeVisibleTypeAnnotations",
+                   "0: #34(): CAST, offset=4, type_index=0",
+                   "1: #34(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
+                   "RuntimeInvisibleTypeAnnotations",
+                   "0: #36(): CAST, offset=4, type_index=0",
+                   "1: #37(): CAST, offset=4, type_index=0",
+                   "2: #36(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
+                   "3: #37(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
                    "0: #34(): METHOD_FORMAL_PARAMETER, param_index=0",
                    "1: #34(): METHOD_FORMAL_PARAMETER, param_index=1",
-                   "2: #34(): CAST, offset=4",
-                   "3: #34(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
                    "0: #36(): METHOD_FORMAL_PARAMETER, param_index=0",
                    "1: #37(): METHOD_FORMAL_PARAMETER, param_index=0",
-                   "2: #36(): METHOD_FORMAL_PARAMETER, param_index=1",
-                   "3: #36(): CAST, offset=4",
-                   "4: #37(): CAST, offset=4",
-                   "5: #36(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}",
-                   "6: #37(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}");
+                   "2: #36(): METHOD_FORMAL_PARAMETER, param_index=1");
         }
     }
 
     @TestCase
-    @ignore // 8008082:missing type annotation for cast
     public static class TC13 extends RepeatingTypeAnnotations {
         public TC13() {
-            setSrc("    public @A @A @A String foo(@A @A @A Object o, @A int i, long l) {",
+            setSrc(" /* TC13 */ ",
+                   "    public @A @A @A String foo(@A @A @A Object o, @A int i, long l) {",
                    "        @A @A @A String ls = (@B @B @B String) o;",
                    "        return (@A @A @A String) o;",
                    "    }");
             verify("RuntimeInvisibleTypeAnnotations",
-                   "0: #36(#37=[@#38(),@#38(),@#38()]): METHOD_RETURN",
-                   "1: #36(#37=[@#38(),@#38(),@#38()]): METHOD_FORMAL_PARAMETER, param_index=0",
-                   "2: #38(): METHOD_FORMAL_PARAMETER, param_index=1",
-                   "3: #39(#37=[@#40(),@#40(),@#40()]): CAST, offset=0, type_index=0",
-                   "4: #36(#37=[@#38(),@#38(),@#38()]): CAST, offset=6, type_index=0",
-                   "5: #36(#37=[@#38(),@#38(),@#38()]): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}");
+                   "0: #36(#37=[@#38(),@#38(),@#38()]): CAST, offset=0, type_index=0",
+                   "1: #39(#37=[@#40(),@#40(),@#40()]): CAST, offset=6, type_index=0",
+                   "2: #39(#37=[@#40(),@#40(),@#40()]): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
+                    "RuntimeInvisibleTypeAnnotations",
+                   "0: #39(#37=[@#40(),@#40(),@#40()]): METHOD_RETURN",
+                   "1: #39(#37=[@#40(),@#40(),@#40()]): METHOD_FORMAL_PARAMETER, param_index=0",
+                   "2: #40(): METHOD_FORMAL_PARAMETER, param_index=1");
         }
     }
 
     @TestCase
     public static class TC14 extends RepeatingTypeAnnotations {
         public TC14() {
-            setSrc("    public @A @B @B String foo(@A @A @B Object o, @A @B int i, long l) {",
+            setSrc(" /* TC14 */ ",
+                   "    public @A @B @B String foo(@A @A @B Object o, @A @B int i, long l) {",
                    "        @A @A @B String ls = (@B @A @B String) o;",
                    "        return (@A @B @B String) o;",
                    "    }");
-            verify("RuntimeInvisibleTypeAnnotations",
-                    "0: #36(): METHOD_RETURN",
-                    "1: #37(#38=[@#39(),@#39()]): METHOD_RETURN",
-                    "2: #40(#38=[@#36(),@#36()]): METHOD_FORMAL_PARAMETER, param_index=0",
-                    "3: #39(): METHOD_FORMAL_PARAMETER, param_index=0",
-                    "4: #36(): METHOD_FORMAL_PARAMETER, param_index=1",
-                    "5: #39(): METHOD_FORMAL_PARAMETER, param_index=1",
-                    "6: #37(#38=[@#39(),@#39()]): CAST, offset=0",
-                    "7: #36(): CAST, offset=0",
-                    "8: #36(): CAST, offset=6",
-                    "9: #37(#38=[@#39(),@#39()]): CAST, offset=6",
-                    "10: #40(#38=[@#36(),@#36()]): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
-                    "11: #39(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}");
+           verify(
+                    "RuntimeInvisibleTypeAnnotations:",
+                    "0: #36(#37=[@#38(),@#38()]): CAST, offset=0, type_index=0",
+                    "1: #39(): CAST, offset=0, type_index=0",
+                  "2: #39(): CAST, offset=6, type_index=0",
+                  "3: #36(#37=[@#38(),@#38()]): CAST, offset=6, type_index=0",
+                  "4: #40(#37=[@#39(),@#39()]): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
+                  "5: #38(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
+                    "RuntimeInvisibleTypeAnnotations:",
+                  "0: #39(): METHOD_RETURN",
+                  "1: #36(#37=[@#38(),@#38()]): METHOD_RETURN",
+                  "2: #40(#37=[@#39(),@#39()]): METHOD_FORMAL_PARAMETER, param_index=0",
+                  "3: #38(): METHOD_FORMAL_PARAMETER, param_index=0",
+                  "4: #39(): METHOD_FORMAL_PARAMETER, param_index=1",
+                    "5: #38(): METHOD_FORMAL_PARAMETER, param_index=1"
+                 );
         }
     }
 
     @TestCase
     public static class TC15 extends RepeatingTypeAnnotations {
         public TC15() {
-            setSrc("    public @A @A @C String foo(@C @C @A Object o, @A @B int i, long l) {",
+            setSrc(" /* TC15 */ ",
+                   "    public @A @A @C String foo(@C @C @A Object o, @A @B int i, long l) {",
                    "        @C @C @A String ls = (@A @A @C String) o;",
                    "        return (@C @B @B String) o;",
                    "    }");
-            verify("RuntimeInvisibleTypeAnnotations",
-                    "RuntimeVisibleTypeAnnotations",
-                    "0: #36(): METHOD_RETURN",
-                    "1: #37(#38=[@#36(),@#36()]): METHOD_FORMAL_PARAMETER, param_index=0",
-                    "2: #36(): CAST, offset=0",
-                    "3: #36(): CAST, offset=6",
-                    "4: #37(#38=[@#36(),@#36()]): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
-                    "0: #40(#38=[@#41(),@#41()]): METHOD_RETURN",
-                    "1: #41(): METHOD_FORMAL_PARAMETER, param_index=0",
-                    "2: #41(): METHOD_FORMAL_PARAMETER, param_index=1",
-                    "3: #42(): METHOD_FORMAL_PARAMETER, param_index=1",
-                    "4: #40(#38=[@#41(),@#41()]): CAST, offset=0",
-                    "5: #43(#38=[@#42(),@#42()]): CAST, offset=6",
-                    "6: #41(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}");
+            verify(
+                    "RuntimeVisibleTypeAnnotations:",
+                    "0: #36(): CAST, offset=0, type_index=0",
+                   "1: #36(): CAST, offset=6, type_index=0",
+                   "2: #37(#38=[@#36(),@#36()]): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
+                    "RuntimeInvisibleTypeAnnotations:",
+                    "0: #40(#38=[@#41(),@#41()]): CAST, offset=0, type_index=0",
+                   "1: #42(#38=[@#43(),@#43()]): CAST, offset=6, type_index=0",
+                   "2: #41(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
+                    "RuntimeVisibleTypeAnnotations:",
+                   "0: #36(): METHOD_RETURN",
+                   "1: #37(#38=[@#36(),@#36()]): METHOD_FORMAL_PARAMETER, param_index=0",
+                    "RuntimeInvisibleTypeAnnotations:",
+                   "0: #40(#38=[@#41(),@#41()]): METHOD_RETURN",
+                   "1: #41(): METHOD_FORMAL_PARAMETER, param_index=0",
+                   "2: #41(): METHOD_FORMAL_PARAMETER, param_index=1",
+                    "3: #43(): METHOD_FORMAL_PARAMETER, param_index=1"
+                    );
         }
     }
 
     @TestCase
     public static class TC16 extends RepeatingTypeAnnotations {
         public TC16() {
-            setSrc("    public @A @B @C String foo(@A @B @C Object o, @A @C int i, long l) {",
+            setSrc(" /* TC16 */ ",
+                   "    public @A @B @C String foo(@A @B @C Object o, @A @C int i, long l) {",
                    "        @A @B @C String ls = (@C @A @B String) o;",
                    "        return (@B @A @C String) o;",
                    "    }");
-            verify("RuntimeInvisibleTypeAnnotations",
-                   "RuntimeVisibleTypeAnnotations",
+            verify(
+                    "RuntimeVisibleTypeAnnotations:",
+                    "0: #36(): CAST, offset=0, type_index=0",
+                   "1: #36(): CAST, offset=6, type_index=0",
+                   "2: #36(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
+                    "RuntimeInvisibleTypeAnnotations:",
+                    "0: #38(): CAST, offset=0, type_index=0",
+                    "1: #39(): CAST, offset=0, type_index=0",
+                   "2: #39(): CAST, offset=6, type_index=0",
+                   "3: #38(): CAST, offset=6, type_index=0",
+                   "4: #38(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
+                   "5: #39(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
+                    "RuntimeVisibleTypeAnnotations:",
                    "0: #36(): METHOD_RETURN",
                    "1: #36(): METHOD_FORMAL_PARAMETER, param_index=0",
                    "2: #36(): METHOD_FORMAL_PARAMETER, param_index=1",
-                   "3: #36(): CAST, offset=0",
-                   "4: #36(): CAST, offset=6",
-                   "5: #36(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
+                    "RuntimeInvisibleTypeAnnotations:",
                    "0: #38(): METHOD_RETURN",
                    "1: #39(): METHOD_RETURN",
                    "2: #38(): METHOD_FORMAL_PARAMETER, param_index=0",
                    "3: #39(): METHOD_FORMAL_PARAMETER, param_index=0",
-                   "4: #38(): METHOD_FORMAL_PARAMETER, param_index=1",
-                   "5: #38(): CAST, offset=0",
-                   "6: #39(): CAST, offset=0",
-                   "7: #39(): CAST, offset=6",
-                   "8: #38(): CAST, offset=6",
-                   "9: #38(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}",
-                   "10: #39(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}");
+                    "4: #38(): METHOD_FORMAL_PARAMETER, param_index=1"
+                  );
         }
     }
 }
--- a/langtools/test/tools/javap/output/Tester.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javap/output/Tester.java	Fri May 17 10:13:34 2013 -0700
@@ -128,8 +128,8 @@
 
     /**
      * Individual test-cases failing due to product bugs, may temporarily
-     * be excluded by marking them like  this:
-     * @ignore // 1234567:bug synopsis
+     * be excluded by marking them like this, (where "at-" is replaced by "@")
+     * at-ignore // 1234567: bug synopsis
      */
     @Retention(RetentionPolicy.RUNTIME)
     @interface ignore { }
--- a/langtools/test/tools/javap/typeAnnotations/NewArray.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javap/typeAnnotations/NewArray.java	Fri May 17 10:13:34 2013 -0700
@@ -27,10 +27,11 @@
 /*
  * @test NewArray
  * @bug 6843077
- * @summary test that all type annotations are present in the classfile
+ * @summary Test type annotations on local array are in method's code attribute.
  */
 
 public class NewArray {
+
     public static void main(String[] args) throws Exception {
         new NewArray().run();
     }
@@ -40,10 +41,6 @@
         File classFile = compileTestFile(javaFile);
 
         ClassFile cf = ClassFile.read(classFile);
-        test(cf);
-        for (Field f : cf.fields) {
-            test(cf, f);
-        }
         for (Method m: cf.methods) {
             test(cf, m);
         }
@@ -55,66 +52,34 @@
         System.out.println("PASSED");
     }
 
-    void test(ClassFile cf) {
-        test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
-        test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
-    }
-
     void test(ClassFile cf, Method m) {
         test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
         test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
     }
 
-    void test(ClassFile cf, Field m) {
-        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
-        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
-    }
-
     // test the result of Attributes.getIndex according to expectations
     // encoded in the method's name
-    void test(ClassFile cf, String name, boolean visible) {
-        int index = cf.attributes.getIndex(cf.constant_pool, name);
-        if (index != -1) {
-            Attribute attr = cf.attributes.get(index);
-            assert attr instanceof RuntimeTypeAnnotations_attribute;
-            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
-            all += tAttr.annotations.length;
-            if (visible)
-                visibles += tAttr.annotations.length;
-            else
-                invisibles += tAttr.annotations.length;
-        }
-    }
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        Attribute attr = null;
+        Code_attribute cAttr = null;
+        RuntimeTypeAnnotations_attribute tAttr = null;
 
-    // test the result of Attributes.getIndex according to expectations
-    // encoded in the method's name
-    void test(ClassFile cf, Method m, String name, boolean visible) {
-        int index = m.attributes.getIndex(cf.constant_pool, name);
-        if (index != -1) {
-            Attribute attr = m.attributes.get(index);
-            assert attr instanceof RuntimeTypeAnnotations_attribute;
-            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
-            all += tAttr.annotations.length;
-            if (visible)
-                visibles += tAttr.annotations.length;
-            else
-                invisibles += tAttr.annotations.length;
-        }
-    }
-
-    // test the result of Attributes.getIndex according to expectations
-    // encoded in the method's name
-    void test(ClassFile cf, Field m, String name, boolean visible) {
-        int index = m.attributes.getIndex(cf.constant_pool, name);
-        if (index != -1) {
-            Attribute attr = m.attributes.get(index);
-            assert attr instanceof RuntimeTypeAnnotations_attribute;
-            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
-            all += tAttr.annotations.length;
-            if (visible)
-                visibles += tAttr.annotations.length;
-            else
-                invisibles += tAttr.annotations.length;
+        int index = m.attributes.getIndex(cf.constant_pool, Attribute.Code);
+        if(index!= -1) {
+            attr = m.attributes.get(index);
+            assert attr instanceof Code_attribute;
+            cAttr = (Code_attribute)attr;
+            index = cAttr.attributes.getIndex(cf.constant_pool, name);
+            if(index!= -1) {
+                attr = cAttr.attributes.get(index);
+                assert attr instanceof RuntimeTypeAnnotations_attribute;
+                tAttr = (RuntimeTypeAnnotations_attribute)attr;
+                all += tAttr.annotations.length;
+                if (visible)
+                    visibles += tAttr.annotations.length;
+                else
+                    invisibles += tAttr.annotations.length;
+               }
         }
     }
 
@@ -124,14 +89,12 @@
         out.println("import java.lang.annotation.*;");
         out.println("import java.util.*;");
         out.println("class Test { ");
-        out.println("  @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})");
-        out.println("  @interface A { }");
-
-        out.println(" void test() {");
-        out.println("  Object a = new @A String @A [5] @A  [];");
-        out.println("  Object b = new @A String @A [5] @A [3];");
-        out.println("  Object c = new @A String @A [] @A [] {};");
-        out.println(" }");
+        out.println("  @Target(ElementType.TYPE_USE) @interface A { }");
+        out.println("  void test() {");
+        out.println("    Object a = new @A String @A [5] @A  [];");
+        out.println("    Object b = new @A String @A [5] @A [3];");
+        out.println("    Object c = new @A String @A [] @A [] {};");
+        out.println("  }");
         out.println("}");
 
         out.close();
--- a/langtools/test/tools/javap/typeAnnotations/Presence.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javap/typeAnnotations/Presence.java	Fri May 17 10:13:34 2013 -0700
@@ -91,17 +91,40 @@
     // test the result of Attributes.getIndex according to expectations
     // encoded in the method's name
     void test(ClassFile cf, Method m, String name, boolean visible) {
+        Attribute attr = null;
+        Code_attribute cAttr = null;
+        RuntimeTypeAnnotations_attribute tAttr = null;
+
+        // collect annotations attributes on method
         int index = m.attributes.getIndex(cf.constant_pool, name);
         if (index != -1) {
-            Attribute attr = m.attributes.get(index);
+            attr = m.attributes.get(index);
             assert attr instanceof RuntimeTypeAnnotations_attribute;
-            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            tAttr = (RuntimeTypeAnnotations_attribute)attr;
             all += tAttr.annotations.length;
             if (visible)
                 visibles += tAttr.annotations.length;
             else
                 invisibles += tAttr.annotations.length;
         }
+        // collect annotations from method's code attribute
+        index = m.attributes.getIndex(cf.constant_pool, Attribute.Code);
+        if(index!= -1) {
+            attr = m.attributes.get(index);
+            assert attr instanceof Code_attribute;
+            cAttr = (Code_attribute)attr;
+            index = cAttr.attributes.getIndex(cf.constant_pool, name);
+            if(index!= -1) {
+                attr = cAttr.attributes.get(index);
+                assert attr instanceof RuntimeTypeAnnotations_attribute;
+                tAttr = (RuntimeTypeAnnotations_attribute)attr;
+                all += tAttr.annotations.length;
+                if (visible)
+                    visibles += tAttr.annotations.length;
+                else
+                    invisibles += tAttr.annotations.length;
+               }
+        }
     }
 
     // test the result of Attributes.getIndex according to expectations
@@ -121,12 +144,12 @@
     }
 
     File writeTestFile() throws IOException {
-        File f = new File("Test.java");
+        File f = new File("TestPresence.java");
         PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
         out.println("import java.util.*;");
         out.println("import java.lang.annotation.*;");
 
-        out.println("class Test<@Test.A T extends @Test.A List<@Test.A String>> { ");
+        out.println("class TestPresence<@TestPresence.A T extends @TestPresence.A List<@TestPresence.A String>> { ");
         out.println("  @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})");
         out.println("  @interface A { }");
 
@@ -134,7 +157,7 @@
 
         out.println("  <@A TM extends @A List<@A String>>");
         out.println("  Map<@A String, @A List<@A String>>");
-        out.println("  method(@A Test<T> this, List<@A String> @A [] param1, String @A [] @A ... param2)");
+        out.println("  method(@A TestPresence<T> this, List<@A String> @A [] param1, String @A [] @A ... param2)");
         out.println("  throws @A Exception {");
         out.println("    @A String lc1 = null;");
         out.println("    @A List<@A String> lc2 = null;");
--- a/langtools/test/tools/javap/typeAnnotations/TypeCasts.java	Thu May 16 12:16:07 2013 -0700
+++ b/langtools/test/tools/javap/typeAnnotations/TypeCasts.java	Fri May 17 10:13:34 2013 -0700
@@ -41,10 +41,6 @@
         File classFile = compileTestFile(javaFile);
 
         ClassFile cf = ClassFile.read(classFile);
-        test(cf);
-        for (Field f : cf.fields) {
-            test(cf, f);
-        }
         for (Method m: cf.methods) {
             test(cf, m);
         }
@@ -56,68 +52,37 @@
         System.out.println("PASSED");
     }
 
-    void test(ClassFile cf) {
-        test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
-        test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
-    }
-
     void test(ClassFile cf, Method m) {
         test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
         test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
     }
 
-    void test(ClassFile cf, Field m) {
-        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
-        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
-    }
-
-    // test the result of Attributes.getIndex according to expectations
-    // encoded in the method's name
-    void test(ClassFile cf, String name, boolean visible) {
-        int index = cf.attributes.getIndex(cf.constant_pool, name);
-        if (index != -1) {
-            Attribute attr = cf.attributes.get(index);
-            assert attr instanceof RuntimeTypeAnnotations_attribute;
-            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
-            all += tAttr.annotations.length;
-            if (visible)
-                visibles += tAttr.annotations.length;
-            else
-                invisibles += tAttr.annotations.length;
-        }
-    }
 
     // test the result of Attributes.getIndex according to expectations
     // encoded in the method's name
     void test(ClassFile cf, Method m, String name, boolean visible) {
-        int index = m.attributes.getIndex(cf.constant_pool, name);
-        if (index != -1) {
-            Attribute attr = m.attributes.get(index);
-            assert attr instanceof RuntimeTypeAnnotations_attribute;
-            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
-            all += tAttr.annotations.length;
-            if (visible)
-                visibles += tAttr.annotations.length;
-            else
-                invisibles += tAttr.annotations.length;
+        Attribute attr = null;
+        Code_attribute cAttr = null;
+
+        int index = m.attributes.getIndex(cf.constant_pool, Attribute.Code);
+        if(index!= -1) {
+            attr = m.attributes.get(index);
+            assert attr instanceof Code_attribute;
+            cAttr = (Code_attribute)attr;
+            index = cAttr.attributes.getIndex(cf.constant_pool, name);
+            if(index!= -1) {
+                attr = cAttr.attributes.get(index);
+                assert attr instanceof RuntimeTypeAnnotations_attribute;
+                RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+                all += tAttr.annotations.length;
+                if (visible)
+                    visibles += tAttr.annotations.length;
+                else
+                    invisibles += tAttr.annotations.length;
+               }
         }
     }
 
-    // test the result of Attributes.getIndex according to expectations
-    // encoded in the method's name
-    void test(ClassFile cf, Field m, String name, boolean visible) {
-        int index = m.attributes.getIndex(cf.constant_pool, name);
-        if (index != -1) {
-            Attribute attr = m.attributes.get(index);
-            assert attr instanceof RuntimeTypeAnnotations_attribute;
-            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
-            all += tAttr.annotations.length;
-            if (visible)
-                visibles += tAttr.annotations.length;
-            else
-                invisibles += tAttr.annotations.length;
-        }
-    }
 
 
     File writeTestFile() throws IOException {
@@ -125,8 +90,7 @@
         PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
         out.println("import java.lang.annotation.*;");
         out.println("class Test { ");
-        out.println("  @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})");
-        out.println("  @interface A { }");
+        out.println("  @Target(ElementType.TYPE_USE) @interface A { }");
 
         out.println("  void emit() {");
         out.println("    Object o = null;");